Docker Cookbook


ELB: Creating a Dynamic Load-Balancer with Confd



Download 6,31 Mb.
Pdf ko'rish
bet239/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   235   236   237   238   239   240   241   242   ...   260
Bog'liq
Docker Cookbook

10.3 ELB: Creating a Dynamic Load-Balancer with Confd
and Registrator
Problem
You want to build a dynamic load-balancer that gets dynamically reconfigured when
containers come and go.
Solution
The solution is based on 
registrator
(see 
Recipe 7.13
), which acts as a service-
discovery mechanism, and 
confd
, which gets information from the key-value store
used by 
registrator
and writes configuration files based on templates.
To illustrate this, you will build a simple one-node setup. A simple 
hostname
applica‐
tion will run in multiple containers. An Nginx load-balancer will front these contain‐
ers to distribute the load among the containers. These containers will get automati‐
cally registered in a Consul key-value store, thanks to 
registrator
. Then 
confd
will
pull information from Consul to write an Nginx configuration file. The load-balancer
(i.e., Nginx) will then get restarted using the new configuration. 
Figure 10-3
illus‐
trates this example.
308 | Chapter 10: Application Use Cases


Figure 10-3. Dynamic load-balancing schematic
To get started, you will reproduce the steps explained in 
Recipe 7.13
. You will start a
Consul-based key-value store via a single container.
In production deployments, you will want to use a multinode
key-value store running separately from the nodes running your
application.
This is done easily with the Docker image 
progrium/consul
, like so:
$ docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp
-h cookbook progrium/consul -server
-bootstrap -ui-dir /ui
Then you will start the 
registrator
container and set the registry URI to 
consul://
192.168.33.10:8500/elb
. The IP address of your Docker host will be different.
$ docker run -d -v /var/run/docker.sock:/tmp/docker.sock
-h 192.168.33.10 gliderlabs/registrator
-ip 192.168.33.10 consul://192.168.33.10:8500/elb
Next you will start your toy application. You can use your own and pull 
runseb/host
name
, which is a simple application that returns the container ID. Start two of them at
first:
$ docker run -d -p 5001:5000 runseb/hostname
$ docker run -d -p 5002:5000 runseb/hostname

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   235   236   237   238   239   240   241   242   ...   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