ã¯ããã«
ä»ããã¸ãã¼ã§ã¯ããããèªåã®ä¸ã§ Docker ã絡ããã¯ã©ã¹ã¿æ§æã«ã¤ãã¦æ°ã«ãªã£ã¦ããã®ã§ CoreOS ããã®é¢é£æè¡ãæ¹ãã¦åå¼·ãã¦ã¿ããã¨æããCoreOS çã®å種æ å ±ã«ã¤ãã¦ã¯åèã«ããã¦é ããè¨äºãã¨ã¦ã詳ããåèã«ãªãã®ã§ããã¡ããé½åº¦ç¢ºèªãã¤ã¤ç解ãæ·±ãã¦ããããã
ä»åã¯ä»¥ä¸ãå¦ã³ããã
- Vagrant 㧠CoreOS ãã¼ããè¤æ°èµ·åãã
- etcd 㨠fleet ãã¶ã¯ã£ã¨è§¦ã
- fleet 㧠Docker ã³ã³ããã¯ã©ã¹ã¿ã管çãã
- èµ·åããã³ã³ããã®ãµã¼ãã¹ã registrator 㧠etcd ã«ç»é²ãã
- etcd ã«ç»é²ãããµã¼ãã¹ã®æ å ±ãå©ç¨ã㦠HAProxy ã®è¨å®ã«åæ ããã
æ§æ
ä»åãææã¨ãã¦å©ç¨ããæ§æã¯ä»¥ä¸ã®éãã
åè
- http://deeeet.com/writing/2014/11/20/fleet/
- http://enakai00.hatenablog.com/entry/20130917/1379374797
- http://www.freedesktop.org/software/systemd/man/systemd.unit.html
- https://sites.google.com/site/kandamotohiro/systemd/man-systemd-unit-no-yi
- https://coreos.com/fleet/docs/latest/unit-files-and-scheduling.html
- https://coreos.com/fleet/docs/latest/launching-containers-fleet.html
- http://knowledge.sakura.ad.jp/tech/2519/
- http://knowledge.sakura.ad.jp/tech/3390/
CoreOS on VirtualBox
vagrant up
git clone ããã
$ git clone https://github.com/coreos/coreos-vagrant.git
3 å°ã® CoreOS ãã¼ããèµ·åãããã®ã§ Vagrantfile ã®ä»¥ä¸ãä¿®æ£ã
$ diff -u Vagrantfile.bk Vagrantfile --- Vagrantfile.bk 2015-08-10 00:14:07.000000000 +0900 +++ Vagrantfile 2015-08-08 18:36:52.000000000 +0900 @@ -9,14 +9,14 @@ CONFIG = File.join(File.dirname(__FILE__), "config.rb") # Defaults for config options defined in CONFIG -$num_instances = 1 +$num_instances = 3 $instance_name_prefix = "core" $update_channel = "alpha" $image_version = "current" $enable_serial_logging = false $share_home = false $vm_gui = false -$vm_memory = 1024 +$vm_memory = 512 $vm_cpus = 1 $shared_folders = {} $forwarded_ports = {}
etcd ã®ã¯ã©ã¹ã¿ãªã³ã°ã«ã¯ discovery.etcd.io ãå©ç¨ãããã®ã§ token ãåå¾ããã
$ curl -s https://discovery.etcd.io/new
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
åºåããã token ã user-data ã«è¿½è¨ããã
$ diff -u user-data.sample user-data --- user-data.sample 2015-08-08 18:33:32.000000000 +0900 +++ user-data 2015-08-08 18:46:53.000000000 +0900 @@ -5,12 +5,14 @@ # generate a new token for each unique cluster from https://discovery.etcd.io/new # WARNING: replace each time you 'vagrant destroy' #discovery: https://discovery.etcd.io/<token> + discovery: https://discovery.etcd.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx addr: $public_ipv4:4001 peer-addr: $public_ipv4:7001 etcd2: #generate a new token for each unique cluster from https://discovery.etcd.io/new #discovery: https://discovery.etcd.io/<token> # multi-region and multi-cloud deployments need to use $public_ipv4 + # discovery: https://discovery.etcd.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx advertise-client-urls: http://$public_ipv4:2379 initial-advertise-peer-urls: http://$private_ipv4:2380 # listen on both the official ports and the legacy ports
vagrant up
ããã
$ vagrant up
èµ·åãããåãã¼ãã«ãã°ã¤ã³ããã
$ vagrant ssh core-01 $ vagrant ssh core-02 $ vagrant ssh core-03
ããããã®ãã¼ãã«ã¦ etcd ã®ã¯ã©ã¹ã¿ãæ§æããã¦ãããã確èªããã
core@core-01 ~ $ etcdctl --version etcdctl version 2.1.1 core@core-01 ~ $ etcdctl cluster-health cluster is healthy member 7aa2819a5e2a4c9cac1e3d4b87760f7f is healthy member bc1eb30f9eb844648110fec1455db88e is healthy member e1103feeae8744c9ab93dc662803ea66 is healthy
fleet ã§ãµã¼ãã¹ã管çãã
fleet ã¯ã©ã¹ã¿æ§æã®ç¢ºèª
fleetctl list-machines
ãå®è¡ãã¦ã¯ã©ã¹ã¿ã®æ§æã確èªããã
core@core-01 ~ $ fleetctl list-machines
MACHINE IP METADATA
7aa2819a... 172.17.8.101 -
bc1eb30f... 172.17.8.103 -
e1103fee... 172.17.8.102 -
unit ãã¡ã¤ã«ã«ã¯ systemd ã®ç¥èãå¿ è¦ã«ãªã...
fleetctl ã§ãµã¼ãã¹ã管çããå ´åã« unit ã¨ããåä½ã§ãµã¼ãã¹ã管çãããã¨ã«ãªããããã® unit è¨å®ãã¡ã¤ã«ã systemd ã® unit è¨å®ãã¡ã¤ã«ã« fleet ç¬èªã® [X-Fleet]
ã¨ããã»ã¯ã·ã§ã³ãå ããå
容ã«ãªãã以ä¸ã¯ Docker ã³ã³ãããå CoreOS ãã¼ãã§èµ·åãããã¨ãåæã¨ãã unit ãã¡ã¤ã«ãå°ã詳細ãªè¨è¿°æ¹æ³ãåãªãã·ã§ã³ã®æå³ã«ã¤ãã¦ã¯ãã¡ãããã¡ãè¨äºã«ã¨ã¦ã詳ããè¨è¼ããã¦ãããæé£ããããã¾ãã
[Unit] Description=kappa-test After=docker.service Requires=docker.service [Service] ExecStartPre=-/usr/bin/docker kill kappa-test-%i ExecStartPre=-/usr/bin/docker rm kappa-test-%i ExecStart=/usr/bin/docker run --name=kappa-test-%i --hostname=kappa-test-%i -p 8000 centos:centos6 /bin/sh -c 'cd /tmp/ ; hostname -s > index.html ; python -m SimpleHTTPServer' ExecStop=/usr/bin/docker stop kappa-test-%i [Install] WantedBy=multi-user.target [X-Fleet] X-Conflicts=kappa-test@*.service
ä¸è¨ä¾ã® %i
ã«ã¤ãã¦ã¯ sysytemd.unit ã® man ãã¼ã¸ã«ããã¨ãã¦ãããåã®ä¸ã® "@" æåã¨ãµãã£ãã¯ã¹ã®éã®æååãåç
§ãããã¨è¨è¼ããã¦ããããã¾ãã¡ããã³ãã¨æ¥ã¦ããªããå®éã«ãµã¼ãã¹ã start ããã¦ã³ã³ãããèµ·åããã¦ã¿ã㨠1 ãã 3 ã®æ°å¤ãã³ã³ããåçã«å±éããã¦ãããã¨ããããµã¼ãã¹èµ·åæã«åãã¼ãã«å²ãå½ã¦ãããçªå·ã %i
ã¨ããå¤æ°ã§åç
§ãããã¨ãåºæ¥ãããã ãï¼â»å¾è¿°ããããå³å¯ã«ã¯ãã¼ãã§ã¯ç¡ãã¤ã³ã¹ã¿ã³ã¹ã«å²ãå½ã¦ããã instance suffix ãåç
§ãããã¨ãåºæ¥ãï¼ã¾ãã[X-Fleet]
ã»ã¯ã·ã§ã³ã® X-Conflicts
ãªãã·ã§ã³ã§ã¯ã¦ãããåãã°ãããããããã¦åãã¦ããããèµ·åããªãããã«è¨å®ãã¦ããã
詳細ã«ã¤ãã¦ã¯ Template unit files ã詳ãã解説ããã¦ããã
ä¸è¨ä¾ã [email protected] ã¨ãããã¡ã¤ã«åã§ä¿åãã¦ããã¦ã以éã®æé ãé²ããã
unit ãã¡ã¤ã«ã®ç»é²ã¨ç¢ºèª
å
ã»ã©ä¿åãã [email protected] ãã¡ã¤ã«ã fleetctl submit
ã³ãã³ããå©ç¨ã㦠fleet ã«ç»é²ããã
fleetctl submit kappa-test\@.service
ç»é²å 容ï¼unit ä¸è¦§ãå 容ï¼ã確èªããå ´åã«ã¯ä»¥ä¸ã®ããã«ç¢ºèªããã
# list-unit-files ã§ç»é²ããã¦ãã unit ãã¡ã¤ã«ä¸è¦§ãç¢ºèª core@core-01 ~ $ fleetctl list-unit-files --full UNIT HASH DSTATE STATE TARGET kappa-test@.service 559024d01378ac913e63c18dfd75f7a58d1f0bf8 inactive inactive - # cat ã§ç»é²ããã¦ãã unit ãã¡ã¤ã«ã®å 容ãç¢ºèª core@core-01 ~ $ fleetctl cat kappa-test@.service [Unit] Description=kappa-test After=docker.service Requires=docker.service [Service] ExecStartPre=-/usr/bin/docker kill kappa-test-%i ExecStartPre=-/usr/bin/docker rm kappa-test-%i ExecStart=/usr/bin/docker run --name=kappa-test-%i --hostname=kappa-test-%i -p 8000 centos:centos6 /bin/sh -c 'cd /tmp/ ; hostname -s > index.html ; python -m SimpleHTTPServer' ExecStop=/usr/bin/docker stop kappa-test-%i [Install] WantedBy=multi-user.target [X-Fleet] X-Conflicts=kappa-test-@*.service
ã¡ãªã¿ã«ãç»é²æ¸ã¿ã®å 容ãæ´æ°ãããå ´åã«ã¯ä»¥ä¸ã®ãããªæé ãå¿ è¦ã«ãªããä¸æ¸ãã¯åºæ¥ãªãã
# ä¸è¦§ç¢ºèª core@core-01 ~ $ fleetctl list-unit-files --full UNIT HASH DSTATE STATE TARGET kappa-test@.service 559024d01378ac913e63c18dfd75f7a58d1f0bf8 inactive inactive - # destroy ã§åé¤ core@core-01 ~ $ fleetctl destroy kappa-test\@.service Destroyed kappa-test@.service # æ¢ã«ãµã¼ãã¹ãèµ·åãã¦ããå ´åã«ã¯ stop ã§ãµã¼ãã¹ãåæ¢ã㦠unload ãã¦ãã destroy ãã # stop $ fleetctl stop kappa-test@{1..3}.service Unit kappa-test@1.service loaded on 7aa2819a.../172.17.8.101 Unit kappa-test@3.service loaded on e1103fee.../172.17.8.102 Unit kappa-test@2.service loaded on bc1eb30f.../172.17.8.103 # unload core@core-01 ~ $ fleetctl unload kappa-test\@{1..3}.service Unit kappa-test@1.service inactive Unit kappa-test@2.service inactive Unit kappa-test@3.service inactive # destroy core@core-01 ~ $ fleetctl destroy kappa-test\@.service Destroyed kappa-test@.service core@core-01 ~ $ fleetctl destroy kappa-test\@{1..3}.service Destroyed kappa-test@1.service Destroyed kappa-test@2.service Destroyed kappa-test@3.service # submit ã§åç»é² core@core-01 ~ $ fleetctl submit kappa-test\@.service
ãµã¼ãã¹ã®èµ·å
ç»é²ãã unit ã®ãµã¼ãã¹ãèµ·åããããµã¼ãã¹ã®èµ·åã«ã¯ fleetctl start
ãå©ç¨ããã
core@core-01 ~ $ fleetctl start kappa-test\@1.service Unit kappa-test@1.service launched on 7aa2819a.../172.17.8.101 core@core-01 ~ $ fleetctl start kappa-test\@2.service Unit kappa-test@2.service launched on bc1eb30f.../172.17.8.103 core@core-01 ~ $ fleetctl start kappa-test\@3.service Unit kappa-test@3.service launched on e1103fee.../172.17.8.102
fleetctl start
ã®å¼æ°ã¨ã㦠kappa-test\@1.service ã kappa-test\@3.service ã渡ãã¦èµ·åãã¦ããããã®å¼æ°ã«ã¤ãã¦ã¯ä»¥ä¸ã®ãããªæå³ãããã
@
ã¯ãã³ãã¬ã¼ãããèµ·åããï¼ãã³ãã¬ã¼ãï¼kappa-test\@.serviceï¼1
ã3
ã¯ãµã¼ãã¹ãèµ·åããã¤ã³ã¹ã¿ã³ã¹ï¼CoreOS ãã¼ãã¨å¿ ãã¤ã³ã¼ã«ã§ã¯ãªãï¼ãèå¥ããçºã®ä»»æã«ã¤ããçªå·ã¨ãªããunit ãã¡ã¤ã«å ãã%i
ã§åç §ãããã¨ãåºæ¥ã
fleetctl list-units
ã§ç¢ºèªããã
core@core-01 ~ $ fleetctl list-units UNIT MACHINE ACTIVE SUB kappa-test@1.service 7aa2819a.../172.17.8.101 active running kappa-test@2.service bc1eb30f.../172.17.8.103 active running kappa-test@3.service e1103fee.../172.17.8.102 active running
fleetctl status
ã§ã確èªããã
core@core-01 ~ $ fleetctl status kappa-test@{1..3}.service â kappa-test@1.service - kappa-test Loaded: loaded (/run/fleet/units/kappa-test@1.service; linked-runtime; vendor preset: disabled) Active: active (running) since Sun 2015-08-09 23:15:50 UTC; 26min ago Process: 19214 ExecStartPre=/usr/bin/docker rm kappa-test-%i (code=exited, status=0/SUCCESS) Process: 19206 ExecStartPre=/usr/bin/docker kill kappa-test-%i (code=exited, status=0/SUCCESS) Main PID: 19220 (docker) CGroup: /system.slice/system-kappa\x2dtest.slice/kappa-test@1.service ââ19220 /usr/bin/docker run --name=kappa-test-1 --hostname=kappa-test-1 -p 8000 centos:centos6 /bin/sh -c cd /tmp/ ; hostname -s > index.html ; python -m SimpleHTTPServer Aug 09 23:15:50 core-01 systemd[1]: Starting kappa-test... Aug 09 23:15:50 core-01 docker[19206]: kappa-test-1 Aug 09 23:15:50 core-01 docker[19214]: kappa-test-1 Aug 09 23:15:50 core-01 systemd[1]: Started kappa-test. â kappa-test@2.service - kappa-test Loaded: loaded (/run/fleet/units/kappa-test@2.service; linked-runtime; vendor preset: disabled) Active: active (running) since Sun 2015-08-09 23:16:00 UTC; 25min ago Process: 20600 ExecStartPre=/usr/bin/docker rm kappa-test-%i (code=exited, status=0/SUCCESS) Process: 20591 ExecStartPre=/usr/bin/docker kill kappa-test-%i (code=exited, status=0/SUCCESS) Main PID: 20609 (docker) CGroup: /system.slice/system-kappa\x2dtest.slice/kappa-test@2.service ââ20609 /usr/bin/docker run --name=kappa-test-2 --hostname=kappa-test-2 -p 8000 centos:centos6 /bin/sh -c cd /tmp/ ; hostname -s > index.html ; python -m SimpleHTTPServer Aug 09 23:16:00 core-03 systemd[1]: Starting kappa-test... Aug 09 23:16:00 core-03 docker[20591]: kappa-test-2 Aug 09 23:16:00 core-03 docker[20600]: kappa-test-2 Aug 09 23:16:00 core-03 systemd[1]: Started kappa-test. â kappa-test@3.service - kappa-test Loaded: loaded (/run/fleet/units/kappa-test@3.service; linked-runtime; vendor preset: disabled) Active: active (running) since Sun 2015-08-09 23:16:10 UTC; 25min ago Process: 21104 ExecStartPre=/usr/bin/docker rm kappa-test-%i (code=exited, status=0/SUCCESS) Process: 21095 ExecStartPre=/usr/bin/docker kill kappa-test-%i (code=exited, status=0/SUCCESS) Main PID: 21110 (docker) CGroup: /system.slice/system-kappa\x2dtest.slice/kappa-test@3.service ââ21110 /usr/bin/docker run --name=kappa-test-3 --hostname=kappa-test-3 -p 8000 centos:centos6 /bin/sh -c cd /tmp/ ; hostname -s > index.html ; python -m SimpleHTTPServer Aug 09 23:16:10 core-02 systemd[1]: Starting kappa-test... Aug 09 23:16:10 core-02 docker[21095]: kappa-test-3 Aug 09 23:16:10 core-02 docker[21104]: kappa-test-3 Aug 09 23:16:10 core-02 systemd[1]: Started kappa-test.
念ã®ããã«ã³ã³ããã«ã¢ã¯ã»ã¹ãã¦ç¢ºèªããã
# ã³ã³ãããç¢ºèª core@core-01 ~ $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e193b197dc14 centos:centos6 "/bin/sh -c 'cd /tmp 28 minutes ago Up 28 minutes 0.0.0.0:32771->8000/tcp kappa-test-1 # ã³ã³ããã§èµ·åãã¦ãã Web ãµã¼ãã¼ã«ã¢ã¯ã»ã¹ core@core-01 ~ $ curl localhost:32771 kappa-test-1
ãµã¼ãã¹ç»é²
ãã£ãããªã®ã§ registrator ã§
registrator ã使ã£ã¦èµ·åãã¦ããã³ã³ããã®ãµã¼ãã¹ã etcd ã«ç»é²ãã¦ã¿ãã
registrator ã®èµ·å
registrator èªä½ã Docker ã³ã³ããã§æä¾ããã¦ããã®ã§ä»¥ä¸ã®ããã«èµ·åããã
core@core-01 ~ $ docker run -d --name registrator -h $HOSTNAME -v /var/run/docker.sock:/tmp/docker.sock progrium/registrator -ip=172.17.8.101 etcd://172.17.8.101:4001/services core@core-02 ~ $ docker run -d --name registrator -h $HOSTNAME -v /var/run/docker.sock:/tmp/docker.sock progrium/registrator -ip=172.17.8.102 etcd://172.17.8.101:4001/services core@core-03 ~ $ docker run -d --name registrator -h $HOSTNAME -v /var/run/docker.sock:/tmp/docker.sock progrium/registrator -ip=172.17.8.103 etcd://172.17.8.101:4001/services
etcd ã®ã¨ã³ããã¤ã³ããæå®ããå ´åã«ã¯ etcd ã® leader ãã¼ãã® IP ãæå®ããå¿ è¦ããã£ããå°ãleader ãã¼ãã®ç¢ºèªã¯ä»¥ä¸ã®ããã«è¡ãã
core@core-01 ~ $ curl http://127.0.0.1:4001/v2/leader http://172.17.8.101:7001
ç»é²ããããµã¼ãã¹ã確èª
# registrator ã«ãã£ã¦ç»é²ããã¦ãããµã¼ãã¹ãç¢ºèª core@core-01 ~ $ curl -s GET http://127.0.0.1:4001/v2/keys/services | jq . { "action": "get", "node": { "key": "/services", "dir": true, "nodes": [ { "key": "/services/centos", "dir": true, "modifiedIndex": 81615, "createdIndex": 81615 }, { "key": "/services/docker-discover-1936", "dir": true, "modifiedIndex": 81796, "createdIndex": 81796 }, { "key": "/services/docker-discover-8000", "dir": true, "modifiedIndex": 81797, "createdIndex": 81797 } ], "modifiedIndex": 81615, "createdIndex": 81615 } } # centos ã¨ãããã¼ã«ç»é²ããã¦ãããããªã®ã§ç¢ºèªãã core@core-01 ~ $ curl -s GET http://127.0.0.1:4001/v2/keys/services/centos | jq . { "action": "get", "node": { "key": "/services/centos", "dir": true, "nodes": [ { "key": "/services/centos/core-02:kappa-test-3:8000", "value": "172.17.8.102:32771", "modifiedIndex": 126869, "createdIndex": 126869 }, { "key": "/services/centos/core-01:kappa-test-1:8000", "value": "172.17.8.101:32771", "modifiedIndex": 126833, "createdIndex": 126833 }, { "key": "/services/centos/core-03:kappa-test-2:8000", "value": "172.17.8.103:32771", "modifiedIndex": 126851, "createdIndex": 126851 } ], "modifiedIndex": 81615, "createdIndex": 81615 } }
docker-discover ã§ãµã¼ãã¹æ¤åº
docker-discover ã¨ã¯
etcd ã«ç»é²ããã¦ãããµã¼ãã¹ã®æ å ±ãå ã«ã㦠HAProxy ã®è¨å®ãèªåã§çæã㦠HAProxy ãåèµ·åãã...ãã¡ãã Docker ã³ã³ãããHAProxy ãå梱ããã¦ããã
ã¡ãã£ã¨ä¿®æ£
ã©ããã docker-discover 㯠docker-register ã¨ãããããã¾ãã³ã³ããã etcd ã«ç»é²ããæ å ±ãå©ç¨ãããã¨ãåæã®ä½ãã«ãªã£ã¦ãããããªã®ã§ registrator ã§ç»é²ããæ å ±ãå©ç¨ãããã¨ããå ´åã«å°ãä¿®æ£ãå¿ è¦ã ã£ãã®ã§ãfork ããã¦é ãã¦ä¿®æ£ãããã®ã以ä¸ã
俺㮠docker-discover èµ·å
core@core-01 ~ $ docker run -d --net host --name docker-discover -e ETCD_HOST=172.17.8.101:4001 -e SERVICE_PORT=8000 -p 8000:8000 -p 1936:1936 -t inokappa/docker-discover core@core-02 ~ $ docker run -d --net host --name docker-discover -e ETCD_HOST=172.17.8.101:4001 -e SERVICE_PORT=8000 -p 8000:8000 -p 1936:1936 -t inokappa/docker-discover core@core-03 ~ $ docker run -d --net host --name docker-discover -e ETCD_HOST=172.17.8.101:4001 -e SERVICE_PORT=8000 -p 8000:8000 -p 1936:1936 -t inokappa/docker-discover
-e SERVICE_PORT=8000
㧠HAProxy ã§å
¬éãããã¼ããæå®ããã
確èª
æ£å¸¸ã
core@core-01 ~ $ curl localhost:8000 kappa-test-1 core@core-01 ~ $ curl localhost:8000 kappa-test-2 core@core-01 ~ $ curl localhost:8000 kappa-test-3
1 ã¤ã³ã¹ã¿ã³ã¹ãåæ¢ï¼ãµã¼ãã¹ãåæ¢ï¼ãã¦ã¿ãã
core@core-01 ~ $ fleetctl stop kappa-test@2.service Unit kappa-test@2.service loaded on bc1eb30f.../172.17.8.103 core@core-01 ~ $ curl localhost:8000 kappa-test-3 core@core-01 ~ $ curl localhost:8000 kappa-test-1 core@core-01 ~ $ curl localhost:8000 kappa-test-3 core@core-01 ~ $ curl localhost:8000 kappa-test-1 core@core-01 ~ $
åæ¢ããã¤ã³ã¹ã¿ã³ã¹ã復帰ã
core@core-01 ~ $ fleetctl start kappa-test@2.service Unit kappa-test@2.service launched on bc1eb30f.../172.17.8.103 core@core-01 ~ $ curl localhost:8000 kappa-test-1 core@core-01 ~ $ curl localhost:8000 kappa-test-2 core@core-01 ~ $ curl localhost:8000 kappa-test-3 core@core-01 ~ $ curl localhost:8000 kappa-test-1 core@core-01 ~ $ curl localhost:8000 kappa-test-2 core@core-01 ~ $ curl localhost:8000 kappa-test-3
ãã®ä»ã¡ã¢
ssh-agent ãå©ç¨ãã
以ä¸ã®ãããªã¨ã©ã¼ãåºã¦ãã¾ããã¨ããããããã㯠fleetctl ã ssh-agent ãå©ç¨ãã¦ä»ã®ã¯ã©ã¹ã¿ãã¼ãã«ã¢ã¯ã»ã¹ãè¡ãçºã
core@core-01 ~ $ fleetctl status kappa-test@2.service Error running remote command: SSH_AUTH_SOCK environment variable is not set. Verify ssh-agent is running. See https://github.com/coreos/fleet/blob/master/Documentation/using-the-client.md for help.
äºåã«ãã¼ãéã§å ¬ééµã®äº¤æãè¡ã£ã¦ããå¿ è¦ãããã以ä¸ã®ããã« ssh-agent ãäºåãèµ·åãã¦ããå¿ è¦ãããã
# ssh-agent ãå®è¡ core@core-01 ~ $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-TyEESXG6GkAI/agent.20079; export SSH_AUTH_SOCK; SSH_AGENT_PID=20080; export SSH_AGENT_PID; echo Agent pid 20080; # åºåãããå 容ãå®è¡ core@core-01 ~ $ SSH_AUTH_SOCK=/tmp/ssh-TyEESXG6GkAI/agent.20079; export SSH_AUTH_SOCK; core@core-01 ~ $ SSH_AGENT_PID=20080; export SSH_AGENT_PID; core@core-01 ~ $ echo Agent pid 20080; Agent pid 20080 # ç§å¯éµãç»é²ãã core@core-01 ~ $ ssh-add ~/.ssh/id_rsa Identity added: /home/core/.ssh/id_rsa (rsa w/o comment)
ssh-agent ã¯åä½é¨ã
discovery.etcd.io ã«ã¢ã¯ã»ã¹ã㦠token ã®åå¾ãèªååï¼vagrant up æã«ï¼
vagrant up
æã« discovery.etcd.io ã«ã¢ã¯ã»ã¹ã㦠token ãåå¾ããã«ã¯ config.rb ã以ä¸ã®ããã«ä¿®æ£ããã
$ diff -u config.rb.sample~ config.rb --- config.rb.sample~ Sat Mar 14 21:49:50 2015 +++ config.rb Mon Aug 10 14:47:12 2015 @@ -3,18 +3,19 @@ # To automatically replace the discovery token on 'vagrant up', uncomment # the lines below: # -#if File.exists?('user-data') && ARGV[0].eql?('up') -# require 'open-uri' -# require 'yaml' -# -# token = open($new_discovery_url).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 +if File.exists?('user-data') && ARGV[0].eql?('up') + require 'open-uri' + require 'yaml' + require 'openssl' + + token = open($new_discovery_url, :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE).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 # #
ã¾ã ã¾ã ...
ã¶ã¯ãã¨
CoreOS ã etcd ã¾ãã¦ã¯ fleet çã¯ã»ã¼åä½é¨ã§ãã³ãã³ã«ã³ãã³ã ã£ãããå®éã«åãããã¨ã§ã¶ã¯ãã¨æ¦è¦ãæ´ãããã¨ãåºæ¥ãã
åå¼·ä¸è¶³
fleet ã® unit ãæ±ãå ´åã« systemd ã®ç¥èãå¿ è¦ã«ãªãã®ã§ã¡ããã¨æãã¦ããããã
ãµã¼ãã¹æ¤åºã«ã¤ãã¦
ä»ã®ãã¼ã«ãããããã ã registrator ã使ãã®ã¯å人çãªéæ¿ãä»åæ¤è¨¼ããç°å¢ã§ã¯ etcd ã®ã¨ã³ããã¤ã³ãæå®ã leader ãã¼ãã® IP ã§ãªãã¨æ£ãããµã¼ãã¹ç»é²ãè¡ãããªãã£ãã®ã¯è¬ã