Docker Cookbook


Starting a CoreOS Cluster via Vagrant to Run Containers on Multiple Hosts | 175



Download 6,31 Mb.
Pdf ko'rish
bet144/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   140   141   142   143   144   145   146   147   ...   260
Bog'liq
Docker Cookbook

6.3 Starting a CoreOS Cluster via Vagrant to Run Containers on Multiple Hosts | 175


In the 
config.rb
file, uncomment the beginning of the script and set your number of
instances so that it looks like this:
if
File
.
exists?
(
'user-data'
)
&&
ARGV
[
0
].
eql?
(
'up'
)
require
'open-uri'
require
'yaml'
token
=
open
(
'https://discovery.etcd.io/new'
)
.
read
data
=
YAML
.
load
(
IO
.
readlines
(
'user-data'
)
[
1
.
.
-
1
].
join
)
data
[
'coreos'
][
'etcd'
][
'discovery'
]
=
token
yaml
=
YAML
.
dump
(
data
)
File
.
open
(
'user-data'
,
'w'
)
{
|
file
|
file
.
write
(
"#cloud-config\n\n
#{
yaml
}
"
)
}
end
.
.
.
$num_instances
=
4
If you have followed 
Recipe 6.1
 and 
Recipe 6.2
, destroy any existing
CoreOS instances before booting your cluster with 
vagrant
destroy
.
With your number of instances set to four, make sure you have copied the original
user-data.sample
to a 
user-data
file and then simply 
vagrant up
and wait for the pro‐
visioning to finish. You can then 
ssh
to one of the nodes and use a new tool, 
fleet
, to
list the machines that have joined the cluster:
$ cp user-data.sample user-data
$ vagrant up
$ vagrant status
Current machine states:
core-01 running (virtualbox)
core-02 running (virtualbox)
core-03 running (virtualbox)
core-04 running (virtualbox)
$ vagrant ssh core-01
CoreOS (stable)
core@core-01 ~ $ fleetctl list-machines
MACHINE IP METADATA
01efec94... 172.17.8.102 -
3602cd04... 172.17.8.104 -
cd3de202... 172.17.8.103 -
e4c0e706... 172.17.8.101 -
176 | Chapter 6: Optimized Operating System Distributions for Docker


Discussion
The 
etcd
discovery service provided by CoreOS is used to boostrap the cluster (i.e.,
defining a leader). In the 
user-data
file, you can now see a line that defines the 
discov
ery
key and contains a token (your token will be different than the one listed here):
discovery: https://discovery.etcd.io/61297b379e5024f33b57bd7e7225d7d7
If you 
curl
this URL (
curl -s https://discovery.etcd.io/
61297b379e5024f33b57bd7e7225d7d7 | python -m json.tool
), you will see the IPs
of the nodes in your cluster. Anyone who obtains access to your token could obtain a
list of your cluster nodes and try to add one of his nodes in your cluster, so handle
with care:
{
"createdIndex"_:_279743993_,_"dir"_:_true'>"action"
:
"get"
,
"node"
:
{
"createdIndex"
:
279743993
,
"dir"
:
true
,
"key"
:
"/_etcd/registry/61297b379e5024f33b57bd7e7225d7d7"
,
"modifiedIndex"
:
279743993
,
"nodes"
:
[
{
"createdIndex"
:
279744808
,

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   140   141   142   143   144   145   146   147   ...   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