Docker Cookbook


Using Cluster IP Services for Dynamic Linking of Containers | 149



Download 6,31 Mb.
Pdf ko'rish
bet126/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   122   123   124   125   126   127   128   129   ...   260
Bog'liq
Docker Cookbook

5.8 Using Cluster IP Services for Dynamic Linking of Containers | 149


Figure 5-2. Using a Kubernetes cluster
The calling code can find the IP for a service in two ways: environment variables and
DNS. The environment variables created for services are similar to Docker link vari‐
ables. For example, suppose you have a service called 
redis
that exposes port 
6379
:
REDIS_MASTER_SERVICE_HOST=10.0.0.11
REDIS_MASTER_SERVICE_PORT=6379
REDIS_MASTER_PORT=tcp://10.0.0.11:6379
REDIS_MASTER_PORT_6379_TCP=tcp://10.0.0.11:6379
REDIS_MASTER_PORT_6379_TCP_PROTO=tcp
REDIS_MASTER_PORT_6379_TCP_PORT=6379
REDIS_MASTER_PORT_6379_TCP_ADDR=10.0.0.11
Much preferred, however, is to use DNS to find your services. When DNS support is
configured on a Kubernetes cluster, each service will also be given a resolvable name.
In this example, assuming the default namespace of 
default
and a DNS domain root
of 
cluster.local
, the service will be exposed as 
redis.default.cluster.local
.
However, when working within a single namespace, users can simply use the name of
the service: 
redis
.
See Also

WordPress example in the Kubernetes documentation
• Documentation on Kubernetes 
Services
150 | Chapter 5: Kubernetes


5.9 Creating a Single-Node Kubernetes Cluster Using
Docker Compose
Problem
You know how to create a Kubernetes cluster by running the various cluster compo‐
nents (e.g., API server, scheduler, kubelet) as 
systemd
units. But why not take advan‐
tage of Docker itself to run these components? It would simplify deployment of the
cluster. To test this deployment scenario, you want to run a one-node Kubernetes
cluster locally using only Docker containers.
Solution
The Kubernetes documentation has a good 
resource
 about this scenario. This recipe
goes one step further and takes advantage of Docker Compose (see 
Recipe 7.1
). To get
started, you will need a Docker host and Docker Compose installed. You can clone
the repository that comes with this book and use the Vagrantfile provided:
$ git clone https://github.com/how2dock/docbook.git
$ cd docbook/ch05/docker
$ tree
.
├── Vagrantfile
├── k8s.yml
└── kubectl
The Vagrantfile contains a small bootstrap script that will install Docker in the virtual
machine as well as Docker Compose. The 
k8s.yml
is the 
docker-compose
definition
to start all the components of Kubernetes as containers. Bring up the machine and
run 
docker-compose
; all the required images will be downloaded and the containers
will start:
$ vagrant up
$ vagrant ssh
$ cd /vagrant
$ docker-compose -f k8s.yml up -d
$ docker ps
CONTAINER ID IMAGE COMMAND
64e0073615c5 gcr.io/google_containers/... "/hyperkube controll ...
9603f3b5b186 gcr.io/google_containers/... "/hyperkube schedule ...
3ce44e77989f gcr.io/google_containers/... "/hyperkube apiserve ...
1b0bcbb56d59 kubernetes/pause:go "/pause" ...
0b0c3e2735a9 kubernetes/etcd:2.0.5.1 "/usr/local/bin/etcd ...
459c45ef9389 gcr.io/google_containers/... "/hyperkube proxy -- ...
005c5ac1de0e gcr.io/google_containers/... "/hyperkube kubelet ...

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   122   123   124   125   126   127   128   129   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish