CoreOSãšã¯äœã§ããïŒ
CoreOSã¯ãç°¡åãã€æè»ã«ã¹ã±ãŒã©ãã«ãªã¯ã©ã¹ã¿ãŒãæ§ç¯ããããã®LinuxããŒã¹ã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ãã CoreOSã¯æå°éã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ã§ãã ã€ã³ã¹ããŒã«ISOã€ã¡ãŒãžã®ããªã¥ãŒã ã¯ããã136MBã§ãããã€ã³ã¹ããŒã«ããã³èµ·ååŸã®æçµãã·ã³ã®ã¡ã¢ãªã«ã¯ãããã114MBããå¿ èŠãããŸããã CoreOSã¯ChromeOSã«åºã¥ããŠãããChromeOS ã¯Gentooã«åºã¥ããŠããŸãã
å®éãCoreOSã¯æ¡ä»¶ä»ãã§æ¬¡ã®éšåã«åå²ã§ããŸãã
- Systemd-ã¯ã©ã¹ã¿ãŒãã·ã³äžã®ããŒã«ã«ãµãŒãã¹ã管çããŸã
- Docker-ãµãŒãã¹ã®åé¢ãæäŸããŸãããååãšããŠãã®äœ¿çšã¯å¿ èŠãããŸãã
- Etcd-ã¯ã©ã¹ã¿ãŒæ§æã®åæ£ä¿å
- ããªãŒã -åæ£ãµãŒãã¹å¶åŸ¡ãæäŸããŸãïŒsystemdã®ãã¢ããªã³ãïŒ
CoreOSã¯ãå¿ èŠãªã¯ã©ã¹ã¿ãŒãã·ã³ã§systemdãµãŒãã¹ãå®è¡ãããã®ã¹ããŒã¿ã¹ãç£èŠããæ§æãä¿åã§ããŸãã
ã·ã¹ãã å
CoreOSã¯éåžžã®systemdã䜿çšããŸããããã¯çŸåšãå€ãã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã«å«ãŸããŠããŸãã ããã¯ãLinuxãµãŒãã¹çšã®ããŒã«ã«ç®¡çã·ã¹ãã ã§ãã
Docker
Dockerã«ã€ããŠHabréã§äœåºŠãæžããŠããŸã ã ã€ãŸããDockerã¯ãã¹ãLinuxãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ã«ãŒãã«ãååŸããæå®ãããã¡ã€ã«ã·ã¹ãã ã®ã€ã¡ãŒãžãããŠã³ãããä»®æ³åç°å¢ã«ãããã®ããã«ãã®ã€ã¡ãŒãžå ã§äœæ¥ã§ããããã«ããŸãã
Dockerã¯ä»®æ³åã䜿çšããªãããšã«æ³šæããŠãã ããã ããã»ã¹ãåé¢ããã«ã¯ã cgroupãšåå空éã䜿çšããŸã ãããã«ãããKVMãªã©ã®ããŒã«ãããããããªãæ·±å»ãªãªãŒããŒããããåãé€ãããšãã§ããŸãã ãã¡ãããDockerã¯MacãšWindowsã®äž¡æ¹ã§äœ¿çšã§ããŸããããã®å Žåããã¹ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã¯VirtualBoxãŸãã¯ãã®ä»ã®ä»®æ³åã·ã¹ãã å ã§åäœããå¿ èŠããããŸããDockerãåäœããã«ã¯Linuxã«ãŒãã«ãå¿ èŠã§ãïŒ Boot2Docker
Etcd
Etcdã¯ãCoreOSã¯ã©ã¹ã¿ãŒå ã®åãã·ã³ã§å®è¡ãããåæ£Key-ValueãªããžããªãŒã§ãããã¯ã©ã¹ã¿ãŒå šäœã®ã»ãŒãã¹ãŠã®ããŒã¿ãžã®å ±æã¢ã¯ã»ã¹ãæäŸããŸãã ãµãŒãã¹èšå®ããããã®çŸåšã®ã¹ããŒã¿ã¹ãã¯ã©ã¹ã¿ãŒèªäœã®æ§æãªã©ã¯etcdå ã«ä¿åãããŸã Etcdã䜿çšãããšãããŒã¿ãéå±€çã«ä¿åïŒããªãŒã®ãããªã¹ãã¬ãŒãžïŒãããŒãŸãã¯ãã£ã¬ã¯ããªå šäœãžã®å€æŽããµãã¹ã¯ã©ã€ããããŒããã³ããŒãã£ã¬ã¯ããªã®TTLå€ãèšå®ïŒå®éã«ã¯ãæéåããïŒãããŒãã¢ãããã¯ã«å€æŽãŸãã¯åé€ãèŠåæ£ããæ¹æ³ã§ä¿åïŒäžæã®ãã¥ãŒãå®è£ ã§ããŸãïŒ ïŒ ã¯ã©ã¹ã¿ãŒã¹ã±ãŒã«ã§å®è¡ãããŠãããµãŒãã¹ã®æ§æã¯etcdã«æ ŒçŽãããŠããããããªããžããªå ã®å¯Ÿå¿ããããŒãžã®å€æŽã«ãµã€ã³ã¢ããããã ãã§ãç¹å®ã®ãµãŒãã¹ã®éå§ãšåæ¢ã«ã€ããŠç¥ãããšãã§ããŸãã
Etcdã¯REST HTTPã€ã³ã¿ãŒãã§ãŒã¹ããµããŒãããŠãããããcurlã§ååã«åäœããŸãã CoreOSã®ã³ãã³ãã©ã€ã³ããã etcdctlãŠãŒãã£ãªãã£ã䜿çšããŠå¶åŸ¡ãããŸãã
èŠé
ããªãŒãã¯ãããŒã«ã«ã³ã³ãã¥ãŒã¿ããã¯ã©ã¹ã¿ã¬ãã«ã«ãµãŒãã¹ç®¡çã転éããsystemdã®ã¢ããªã³ã§ãã Fleetã¯ãsystemdãŠãããïŒetcdå ïŒã®åœ¢åŒã§ãµãŒãã¹ã®æ§æãä¿åããããŒã«ã«ãã·ã³ã«èªåçã«é ä¿¡ããã¯ã©ã¹ã¿ãŒãã·ã³äžã®ãµãŒãã¹ãéå§ãåèµ·åïŒå¿ èŠãªå ŽåïŒãåæ¢ããŸãã ããªãŒãã¯ãç¹å®ã®ã¯ã©ã¹ã¿ãŒãã·ã³ã®ã¯ãŒã¯ããŒãã«åºã¥ããŠãµãŒãã¹ã®èµ·åãèšç»ã§ããŸãã ç¹å®ã®ãµãŒãã¹ã¯ç¹å®ã®ãã·ã³ãªã©ã§ã®ã¿å®è¡ããå¿ èŠããããšåœŒã¯èšãããšãã§ããŸãã
CoreOSã¯ç°¡åã§ã
CoreOSã¯ã©ã¹ã¿ãŒã§helloãµãŒãã¹ãéå§ããã«ã¯ã次ãå®è¡ããã ãã§ãã
1. SSHãä»ããŠä»»æã®ã¯ã©ã¹ã¿ãŒãµãŒããŒã«ãã°ã€ã³ããŸãïŒãã¹ãŠåçã§ãïŒã
2.ãµãŒãã¹ã®èª¬æãå«ãããã¹ããã¡ã€ã«ãäœæããŸãã ããšãã°ãhello.serviceïŒ
[Unit] Description=My Service After=docker.service [Service] TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill hello ExecStartPre=-/usr/bin/docker rm hello ExecStartPre=/usr/bin/docker pull busybox ExecStart=/usr/bin/docker run --name hello busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done" ExecStop=/usr/bin/docker stop hello
3.次ã®ã³ãã³ããå®è¡ããŸãã
fleetctl submit hello.service fleetctl load hello.service fleetctl start hello.service
4.以äžã§ãïŒ æåŸã®ã³ãã³ãfleetãåãåã£ãã®ã§ããã®ä»¶ã«ã€ããŠäœãæ瀺ããªãã£ããããè² è·ã®æãå°ãªãã¯ã©ã¹ã¿ãŒãã·ã³ãç¹å®ãããŠããããã¡ã€ã«ãååŸããéžæãããã·ã³ã«è»¢éããsystemdããµãŒãã¹ãæ ŒçŽããŠããå Žæã«é 眮ããŠãsystemdã«èµ·åãäŸé ŒããŸãã ãããŠãèµ·ååŸãã¹ããŒã¿ã¹ãç£èŠããŸãã ãµãŒãã¹ãå®è¡ãããŠãããã·ã³ãäºæããã¯ã©ãã·ã¥ããå ŽåãããªãŒãã¯å¥ã®ãã·ã³ã§ãµãŒãã¹ãåèµ·åããŸãã
ãã®äŸããã詳现ã«æ€èšããŠãã ããã
ãµãŒãã¹æ§æãã¡ã€ã«ïŒ
[Unit] # Description=My Service # docker.service After=docker.service [Service] # # , docker TimeoutStartSec=0 # . # , . ExecStartPre=-/usr/bin/docker kill hello ExecStartPre=-/usr/bin/docker rm hello # docker # fleet , ExecStartPre=/usr/bin/docker pull busybox # . Bash. ExecStart=/usr/bin/docker run --name hello busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done" # ExecStop=/usr/bin/docker stop hello
å®è¡ããã³ãã³ãïŒ
# fleetctl submit hello.service # , systemd fleetctl load hello.service # fleetctl start hello.service
ãµãŒãã¹ã®ã¹ããŒã¿ã¹ã衚瀺ããã«ã¯ã fleetctl list-unit-filesã³ãã³ãïŒãã¹ãŠã®ãµãŒãã¹ã®ç°¡åãªèŠçŽïŒãŸãã¯fleetctl status hello.serviceïŒãµãŒãã¹ã«é¢ãã詳现æ å ±ïŒã䜿çšããŸãã
CoreOSãã€ã³ã¹ããŒã«ãã
CoreOSã¯ããŸããŸãªæ¹æ³ã§ã€ã³ã¹ããŒã«ã§ããŸã ã ãã ããå®éšããããšã«ããå Žåã¯ãVagrantããã€ã³ã¹ããŒã«ããããšããå§ãããŸãã
1. Git ã VirtualBox ã Vagrantã®ææ°ããŒãžã§ã³ãã€ã³ã¹ããŒã«ããŸãã
1aã ãŸãã¯ãäžéšã®git cloneãã©ã«ããŒã§github.com/coreos/coreos-vagrant.git && cd coreos-vagrant
1bã ãŸãã¯ãGitãããŠã³ããŒãããããªãå Žåã¯ã ãããã©ããã§è§£åããŸãã
2.ãã©ã«ããŒã«ç§»åãã user-data.sampleãã¡ã€ã«ã®ååãuser-dataã«å€æŽãã config.rb.sampleãconfig.rbã«å€æŽããŸãã discovery.etcd.io/newã«ç§»åãã衚瀺ããã URLããããã¡ã«ã³ããŒããuser-dataå ã®ãã£ã¹ã«ããªæ瀺ã®è¡ã®ã³ã¡ã³ãã解é€ããŠãããã§URLã眮ãæããŸãã
3.ãã©ã«ãã«ç§»åãã ãããŸã§æµ®æµªè ãè¡ããŸã
4.ããŒã¹ã€ã¡ãŒãžãããŠã³ããŒããããã®ãåŸ ã¡ãŸãã
5. vagrant sshãå®è¡ããŸãã
ããªãã¯äžã«ããŸã:)
CoreOSã®å¶éã匱ç¹ãé©ã
CoreOSã¯ãæäŸãããŠãããã®ä»¥å€ã¯æäŸããŠããŸãã:)èšãæãããšãããã®ãŸãŸãã§ã¯ã説æãããã®ä»¥å€ã¯äœãç¥ããŸããã ãŸããCoreOSã«åºã¥ããŠã¯ã©ã¹ã¿ãŒãæ§ç¯ããå Žåãå°ãªããšã次ã®åé¡ãçºçããŸãã
ããã±ãŒãžãããŒãžã£ãŒãšã¢ããããŒã
CoreOSã«ã¯ããã±ãŒãžãããŒãžã£ãŒããããŸããã ãŸããè¿œå ã®ãœãããŠã§ã¢ãã¢ã»ã³ãã«ãŸãã¯ã€ã³ã¹ããŒã«ããããã®ã·ã¹ãã ïŒwgetããã³curl :)ãé€ãïŒã å¥ã®æ¹æ³ãšããŠã çµ±åãããDockerããŒã«ããã¯ã¹ã³ã³ãããŒã䜿çšããããšããå§ãããŸãã æå¹ã«ããã«ã¯ãã³ãã³ãã©ã€ã³ãã/ usr / bin / toolboxãå®è¡ããã ãã§ã ã ç¹æš©ã³ã³ããã¯ãyumãžã®ã¢ã¯ã»ã¹ãããFedoraã§å§ãŸããŸãã
CoreOSã®æŽæ°ã¯ãã¢ã¯ãã£ã/ããã·ãããŒãã£ã·ã§ã³ã·ã¹ãã ã䜿çšããŠOSå šäœã«å¯ŸããŠå®è¡ãããŸãã å®éãCoreOSã«ã¯2ã€ã®ã·ã¹ãã ããŒãã£ã·ã§ã³ããããŸãã åžžã«ã¢ã¯ãã£ããªã®ã¯ãã®ãã¡ã®1ã€ã ãã§ãã OSå šäœã®æŽæ°ã¯2çªç®ã«ã€ã³ã¹ããŒã«ããããã®åŸåèµ·åãå®è¡ãããã¢ã¯ãã£ãããŒãã£ã·ã§ã³ãå€æŽãããŸãã ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã¯ãå®å šã«ã®ã¿æŽæ°ãããŸãã ãããã£ãŠã以åã®ããŒãžã§ã³ã®OSã«ç°¡åã«ããŒã«ããã¯ã§ããŸãã ç§ã®ããã«;ïŒããã§ã«CoreOSã®ããã±ãŒãžãããŒãžã£ãŒãããã«äœ¿çšãããå Žåã¯ã éçºè åãããã¥ã¡ã³ãããèªã¿ãã ããã
ãµãŒãã¹çºèŠ
CoreOSã®ãããªãã¯ãã¯ãã¯ã©ã¹ã¿ãŒãã·ã³éã§ãµãŒãã¹ãç°¡åã«è»¢éããããèªäœã§ãµãŒãã¹ãåæ¢ããã³éå§ããããšã§ãã 倧ãŸãã«èšã£ãŠãããã¯ããã·ã³Xã§æåã«èµ·åãããWebãµãŒããŒããå éšãããã¯ãŒã¯ã§å®å šã«ç°ãªãIPã¢ãã¬ã¹ãæã€ãã·ã³Yã«5åã§ç°¡åã«å°éã§ããããšãæå³ããŸãã ãã¡ãããFleetã®ç¹å¥ãªæ瀺ã®å©ããåããŠãç¹å®ã®ãã·ã³ã«ãµãŒãã¹ãç°¡åã«ãæäŸãã§ããŸããã...ã§ã¯ããªãCoreOSãå¿ èŠãªã®ã§ããïŒ :)ããã«ããããµãŒãã¹ã®IPã¢ãã¬ã¹ã解決ããåé¡ãçºçããŸãã åºæ¬çã«ãetcdãç §äŒãããµãŒãã¹ãçŸåšå®è¡ãããŠãããã·ã³ãèŠã€ããã®ã¯ç°¡åã§ãã ãã ããããã¯èªåçã«ã¯è¡ãããŸããã ãµãŒãã¹ãã£ã¹ã«ããªãŒã¯éåžžã«æ·±å»ãªåé¡ã§ããã ããã解決ããããã«èšå€§ãªéã®ãœãããŠã§ã¢ãæäŸãããŠããŸãã ã SkyDNSã¯ç§ã«ãšã£ãŠæãé åçã§ãã ãµã€ãããã¯ãŠãããã䜿çšããŠSkyDNSã䜿çšã§ããŸãã
ã³ã³ããã®æ°žç¶æ§ãšããŒã¿èªäœ
ãæ°ã¥ãã®ãšãããCoreOSã¯å®éã«ã¯å¥ã®ãã·ã³ã«ç°¡åã«è»¢éããŠå®è¡ã§ããã¹ããŒãã¬ã¹Dockerã³ã³ãããäžå¿ã«æ§ç¯ãããŠããŸãã å®éãnginxãphp-fpmãªã©ã®ã³ã³ãããŒåã¯éåžžã«ç°¡åã§ãã ãããã®æ§æãã¡ã€ã«ã¯ãã³ã³ãããŒãšããŠé åžããããšãã§ããŸãã ã¢ããªã±ãŒã·ã§ã³ã®ãœãŒã¹ã³ãŒãã§ãããããŒã¿ããªã¥ãŒã ïŒããã¯ããŒã¿ã®ã¿ãå«ãdockerã³ã³ãããŒïŒã®åœ¢ã§é åžã§ããããŸããŸãªãµãŒãã¹ã«æ¥ç¶ã§ããŸãã ããŒã¿ããŒã¹ã§äœããããã§ããïŒ
ããã€ãã®æ¹æ³ããããŸãã ãŸããFlockerãªã©ã®ãµãŒãã¹ãããŒã¿ã䜿çšãããµãŒãã¹ãæã€ã³ã³ãããŒã®åŸã«ããŒã¿ã³ã³ãããŒã移è¡ããŸãã 次ã«ãDBMSã«äŒŒããµãŒãã¹ãã¯ã©ã¹ã¿ãŒã¢ãŒãã§èµ·åããŸãã NoSQLãœãªã¥ãŒã·ã§ã³ã¯ãããéåžžã«ããŸãè¡ãããšãã§ãããªã¬ãŒã·ã§ãã«ãœãªã¥ãŒã·ã§ã³ã¯èããæªãã§ãããããã¯ãŸã å¯èœã§ãã 第äžã«ãã¯ã©ã¹ã¿ãŒå ã§GlusterFSãCephãªã©ã®åæ£ãã¡ã€ã«ã·ã¹ãã ãäžããããšãã§ããŸãã ãã ãããã®ãããªãœãªã¥ãŒã·ã§ã³ã¯ããã©ãŒãã³ã¹ã®èŠ³ç¹ããè©äŸ¡ããå¿ èŠããããŸãã ããã§ãããã®åé¡ã«ã€ããŠè°è«ããŸãã ã
ãããã«
CoreOSã¯çŸåšããããã®èšèãæããã«ççºçãªæé·ãçµéšããŠããŸãã Dockerãšåæ§ãäžè¬çã«ã CoreOSã®ããŸããŸãªãããžã§ã¯ãã®æ°ã¯æ¯æ¥å¢å ããŠããŸã ã ãã®ãããç¹å®ã®åé¡ã解決ããããã«äœãã足ããªãå Žåãææ¥ã¯ãã®æ©äŒããã§ã«çŸãããããããŸããã
CoreOSãããžã§ã¯ãã®äžç°ãšããŠã代æ¿ã®ã³ã³ããåãšãã±ããã®æšæºãéçºãããŠããŸãã ããã...ä»ã®ãšãããã©ãããDockerã䜿çšããã»ããè¯ãããã§ãã ããã«ãCoreOSã¯å°æ¥DockerãæŸæ£ããäºå®ã¯ãããŸããã
äœãèªãïŒ
ãã¡ããã ããã¥ã¡ã³ããèªãããšãã§ããŸã ã ãã ãã CoreOSã«é¢ããDigital Oceanã·ãªãŒãºã®èšäºã¯äœãããæ°ã«å ¥ã£ãŠããŸãã å®éã®ãšããããã®èšäºã¯ãã®æ ¹æ ã«åºã¥ããŠæžãããŠããããã®åœ±é¿äžã«ãããŸã:)