5æ31æ¥ããã·ã¢ã®ã€ã³ã¿ãŒããããã¯ãããžãŒãã§ã¹ãã£ãã«ïŒRIT ++ 2016ïŒã®äžç°ãšããŠéå¬ãããRootConf 2016äŒè°ã§ãã¬ããŒããDockerã«ããç¶ç¶çé ä¿¡ã®ãã¹ããã©ã¯ãã£ã¹ãã§ç¶ç¶çå±éããã³å±éã»ã¯ã·ã§ã³ãéããŸããã Dockerããã³ãã®ä»ã®ãªãŒãã³ãœãŒã¹è£œåã䜿çšããŠç¶ç¶çããªããªãŒïŒCDïŒããã»ã¹ãæ§ç¯ããããã®ãã¹ããã©ã¯ãã£ã¹ããŸãšããŠäœç³»åããŸããã ãããã®ãœãªã¥ãŒã·ã§ã³ã¯å®çšŒåç°å¢ã§äœ¿çšãããŠãããããå®éã®çµéšã«é Œãããšãã§ããŸãã
ãããªã¬ããŒãã« 1æéãè²»ããæ©äŒãããå Žåã¯ãå®å šã«èŠãããšããå§ãããŸãã ãã以å€ã®å Žå-以äžã¯ããã¹ã圢åŒã®ã¡ã€ã³ã¹ã¯ã€ãŒãºã§ãã
Dockerã«ããç¶ç¶çããªããªãŒ
ç¶ç¶çããªããªãšã¯ãäžé£ã®ã€ãã³ããæå³ããŸãããã®çµæãGitãªããžããªããã®ã¢ããªã±ãŒã·ã§ã³ã³ãŒããæåã«å®çšŒåç¶æ ã«ãªãããã®åŸã¢ãŒã«ã€ãã«ç§»åããŸãã Gitâãã«ãïŒã¢ã»ã³ããªïŒâãã¹ãïŒãã¹ãïŒâãªãªãŒã¹ïŒãªãªãŒã¹ïŒâæäœïŒåŸç¶ã®ã¡ã³ããã³ã¹ïŒã®ããã«ãªããŸãã
ã¬ããŒãã®ã»ãšãã©ã¯ãã«ãã¹ããŒãžïŒã¢ããªã±ãŒã·ã§ã³ã¢ã»ã³ããªïŒã«åœãŠãããŠããããªãªãŒã¹ãšæäœã®ãããã¯ã¯æŠèŠã§èª¬æãããŠããŸãã ãããã解決ã§ããåé¡ãšãã¿ãŒã³ã«ã€ããŠèª¬æããŸããããããã®ãã¿ãŒã³ã®ç¹å®ã®å®è£ ã¯ç°ãªãå ŽåããããŸãã
ãªãããã§Dockerãå¿ èŠãªã®ã§ããïŒ ãã®ãªãŒãã³ãœãŒã¹ããŒã«ã®ã³ã³ããã¹ãã§ç¶ç¶çããªããªãŒã®å®è·µã«ã€ããŠè©±ãããšã«ãããããšããçç±ã ãã§ã¯ãããŸããã ã¬ããŒãå šäœãã¢ããªã±ãŒã·ã§ã³ã«åœãŠãããŠããŸãããã¢ããªã±ãŒã·ã§ã³ã³ãŒããå±éããäž»ãªãã¿ãŒã³ãæ€èšããéã«ã¯ãå€ãã®çç±ããã§ã«æããã«ãããŠããŸãã
ã¡ã€ã³ããŒã«ã¢ãŠããã¿ãŒã³
ãã®ãããã¢ããªã±ãŒã·ã§ã³ã®æ°ããããŒãžã§ã³ãå±éãããšãã«ãéçšãµãŒããŒã®åãæ¿ãäžã«çºçããããŠã³ã¿ã€ã ã®åé¡ã«å¿ ãééããŸãã å€ãããŒãžã§ã³ã®ã¢ããªã±ãŒã·ã§ã³ããæ°ããããŒãžã§ã³ãžã®ãã©ãã£ãã¯ã¯ããã«åãæ¿ããããšãã§ããŸããããŸããæ°ããããŒãžã§ã³ãæ£åžžã«ããŠã³ããŒããããã ãã§ãªããããŠã©ãŒã ã¢ããããããŠããããšã確èªããå¿ èŠããããŸãã
ãããã£ãŠããã°ããã®éãã¢ããªã±ãŒã·ã§ã³ã®äž¡æ¹ã®ããŒãžã§ã³ïŒå€ããã®ãšæ°ãããã®ïŒãåæã«æ©èœããŸãã ãããã¯ãŒã¯ããã¡ã€ã«ã·ã¹ãã ãIPCãªã©ã å ±æãªãœãŒã¹ã®ç«¶åãèªåçã«çºçããŸãã Dockerã䜿çšãããšãåããã¹ãïŒãµãŒããŒ/ä»®æ³ãã·ã³ïŒå ã§ãªãœãŒã¹ã®åé¢ãä¿èšŒãããå¥ã ã®ã³ã³ãããŒã§ç°ãªãããŒãžã§ã³ã®ã¢ããªã±ãŒã·ã§ã³ãå®è¡ããããšã«ããããã®åé¡ãç°¡åã«è§£æ±ºã§ããŸãã ãã¡ããããŸã£ããåé¢ããã«ããã€ãã®ããªãã¯ãè¡ãããšãã§ããŸãããæ¢è£œã®äŸ¿å©ãªããŒã«ãã€ãŸãéã®çç±ãããå Žåããããç¡èŠããªãã§ãã ããã
ã³ã³ããåã«ã¯ããããã€æã«ä»ã®å€ãã®å©ç¹ããããŸãã ãã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ã¯ã ã€ã³ã¿ãŒããªã¿ãŒã® ç¹å®ã®ããŒãžã§ã³ ïŒãŸãã¯ããŒãžã§ã³ã®ç¯å²ïŒãã¢ãžã¥ãŒã«/æ¡åŒµæ©èœãªã©ã®ååšãããã³ãããã®ããŒãžã§ã³ã«äŸåããŸãã ãŸããããã¯ãå³æå®è¡å¯èœç°å¢ã ãã§ãªãã ã·ã¹ãã ãœãããŠã§ã¢ãšãã®ããŒãžã§ã³ïŒäœ¿çšãããŠããLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ãŸã§ïŒãå«ãç°å¢å šäœã«ãé©çšãããŸãã ã³ã³ããã«ã¯ã¢ããªã±ãŒã·ã§ã³ã³ãŒãã ãã§ãªããå¿ èŠãªããŒãžã§ã³ã®ããªã€ã³ã¹ããŒã«ãããã·ã¹ãã ããã³ã¢ããªã±ãŒã·ã§ã³ãœãããŠã§ã¢ãå«ãŸããŠãããããäŸåé¢ä¿ã®åé¡ãå¿ããããšãã§ããŸãã
ãªã¹ããããèŠå ãèæ ®ããŠãæ°ããããŒãžã§ã³ãå±éããäž»ãªãã¿ãŒã³ãèŠçŽããŸãã
- æåã«ãã¢ããªã±ãŒã·ã§ã³ã®å€ãããŒãžã§ã³ãæåã®ã³ã³ããã§å®è¡ãããŸãã
- 次ã«ãæ°ããããŒãžã§ã³ãå±éããã2çªç®ã®ã³ã³ããã§ããŠã©ãŒã ã¢ããããããŸãã ãã®æ°ããããŒãžã§ã³èªäœããæŽæ°ãããã¢ããªã±ãŒã·ã§ã³ã³ãŒãã ãã§ãªãããã®äŸåé¢ä¿ãããã³ã·ã¹ãã ã³ã³ããŒãã³ãïŒããšãã°ãOpenSSLã®æ°ããããŒãžã§ã³ãŸãã¯ãã£ã¹ããªãã¥ãŒã·ã§ã³å šäœïŒãä¿æã§ããããšã¯æ³šç®ã«å€ããŸãã
- æ°ããããŒãžã§ã³ããªã¯ãšã¹ããåŠçããæºåãå®å šã«æŽã£ããããã©ãã£ãã¯ã¯æåã®ã³ã³ãããã2çªç®ã®ã³ã³ããã«åãæ¿ãããŸãã
- ããã§ãå€ãããŒãžã§ã³ãåæ¢ã§ããŸãã
ç°ãªãããŒãžã§ã³ã®ã¢ããªã±ãŒã·ã§ã³ãå¥ã ã®ã³ã³ããã«ãããã€ãããã®ã¢ãããŒãã§ã¯ããã1ã€ã®å©äŸ¿æ§ãåŸãããŸããå€ãããŒãžã§ã³ã«ãã°ããããŒã«ããã¯ã§ããŸã ïŒçµå±ãå¿ èŠãªã³ã³ããã«ãã©ãã£ãã¯ãåãæ¿ããã ãã§ååã§ãïŒã
æåŸã®æåã®æšå¥šäºé ã¯ããã£ããã³ã§ãããããªãããšã§ãïŒã [Dockerã§ç¶ç¶çããªããªãŒãç·šæããå Žå] Dockerã䜿çšãã [ãããŠãããäžããããšãç解ãã] ãã ããã¯åé¡ã解決ãããéã®åŒŸäžžãã§ã¯ãªããçŽ æŽãããåºç€ãæäŸããããŒã«ã§ããããšãå¿ããªãã§ãã ããã
åçŸæ§
ãåçŸæ§ããšã¯ãã¢ããªã±ãŒã·ã§ã³ã®æäœæã«çºçããäžè¬çãªäžé£ã®åé¡ãæå³ããŸãã ãã®ãããªå Žåã«ã€ããŠè©±ããŠããïŒ
- å質éšéãã¹ããŒãžã³ã°ã«é¢ããŠæ€èšŒããã·ããªãªã¯ãæ¬çªç°å¢ã§æ£ç¢ºã«åçŸããå¿ èŠããããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã¯ããªããžããªã®ããŸããŸãªãã©ãŒããããã±ãŒãžãåä¿¡ã§ãããµãŒããŒäžã§å ¬éãããŸãïŒæéã®çµéãšãšãã«ãã€ã³ã¹ããŒã«ãããã¢ããªã±ãŒã·ã§ã³ã®ããŒãžã§ã³ãšãšãã«æŽæ°ãããŸãïŒã
- ããã¹ãŠãããŒã«ã«ã§æ©èœããŸãïŒãïŒ...ããã³éçºè ã¯æ¬çªç°å¢ã§ã¯èš±å¯ãããŠããŸãããïŒ
- å€ãïŒã¢ãŒã«ã€ããããïŒããŒãžã§ã³ã®äœãããã§ãã¯ããå¿ èŠããããŸãã
- ...
ãããã®äžè¬çãªæ¬è³ªã¯ã䜿çšãããç°å¢ã®å®å šãªã³ã³ãã©ã€ã¢ã³ã¹ïŒããã³äººçèŠå ã®äžåšïŒãå¿ èŠã§ãããšããäºå®ã«èŠçŽãããŸãã åçŸæ§ãä¿èšŒããæ¹æ³ã¯ïŒ Gitã®ã³ãŒãã«åºã¥ããŠDockerã€ã¡ãŒãžãäœæãããããä»»æã®ã¿ã¹ã¯ã«äœ¿çšããŸãïŒãã¹ããã©ãããã©ãŒã ãéçšç°å¢ãããã°ã©ããŒã®ããŒã«ã«ãã·ã³...ã€ã¡ãŒãžã®äœæåŸã«å®è¡ãããã¢ã¯ã·ã§ã³ãæå°éã«æããããšãéèŠã§ãããšã©ãŒãçºçããå¯èœæ§ãå°ãªãã»ã©éèŠã§ãã
ã€ã³ãã©ã¹ãã©ã¯ãã£ã¯ã³ãŒãã§ã
ã€ã³ãã©ã¹ãã©ã¯ãã£ã®èŠä»¶ïŒãµãŒããŒãœãããŠã§ã¢ã®å¯çšæ§ãããŒãžã§ã³ãªã©ïŒãæ£åŒã§ãªãããããã°ã©ãã³ã°ããããŠããªãå Žåãã¢ããªã±ãŒã·ã§ã³ã®æŽæ°ãå±éãããšãæ²æšãªçµæã«çµããå¯èœæ§ããããŸãã ããšãã°ãã¹ããŒãžã³ã°ã§ã¯ããã§ã«PHP 7.0ã«åãæ¿ããŠãããããã«å¿ããŠã³ãŒããæžãçŽããŠããŸããå€ãPHPïŒ5.5ïŒã䜿çšããå®çšŒåç°å¢ã§ã®å€èŠ³ã¯ããã£ãšé©ãã§ãããã ã€ã³ã¿ããªã¿ã®ããŒãžã§ã³ã®å€§ããªå€æŽãå¿ããªããããããŸãããããæªéã¯çŽ°éšã«å®¿ã£ãŠããŸããïŒäŸåé¢ä¿ã®ãã€ããŒãªæŽæ°ã§ããããšãå€æãããããããŸããã
ãã®åé¡ã解決ããã¢ãããŒãã¯IaCïŒInfrastructure as CodeïŒãšããŠç¥ãããŠãããã€ã³ãã©ã¹ãã©ã¯ãã£èŠä»¶ãã¢ããªã±ãŒã·ã§ã³ã³ãŒããšå ±ã«ä¿åããå¿ èŠããããŸãã ããã䜿çšããå Žåãéçºè ãšDevOpsã¹ãã·ã£ãªã¹ãã¯ãã¢ããªã±ãŒã·ã§ã³ã®1ã€ã®Gitãªããžããªãããã®ç°ãªãéšåã§äœæ¥ã§ããŸãã ãã®ã³ãŒããããGitã¯Dockerã€ã¡ãŒãžãäœæããŸããDockerã€ã¡ãŒãžã§ã¯ãã€ã³ãã©ã¹ãã©ã¯ãã£ã®ãã¹ãŠã®è©³çŽ°ãèæ ®ããŠãã¢ããªã±ãŒã·ã§ã³ããããã€ãããŸãã ç°¡åã«èšãã°ãã€ã¡ãŒãžãçµã¿ç«ãŠãããã®ã¹ã¯ãªããïŒã«ãŒã«ïŒã¯ããœãŒã¹ã³ãŒããšåããªããžããªã«é 眮ããäžç·ã«ããŒãžããå¿ èŠããããŸãã
ãã«ãã¬ã€ã€ãŒã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£ã®å ŽåïŒããšãã°ãDockerã³ã³ãããŒå ã§æ¢ã«å®è¡ãããŠããã¢ããªã±ãŒã·ã§ã³ã®åã«ããnginxããããŸãïŒãåã¬ã€ã€ãŒã®Gitã®ã³ãŒãããDockerã€ã¡ãŒãžãäœæããå¿ èŠããããŸãã 次ã«ãæåã®ã€ã¡ãŒãžã«ã¯ã€ã³ã¿ãŒããªã¿ãŒãšä»ã®ãæãè¿ããäŸåé¢ä¿ãæã€ã¢ããªã±ãŒã·ã§ã³ãããã2çªç®ã®ã€ã¡ãŒãžã«ã¯ã¢ããã¹ããªãŒã ã®nginxããããŸãã
Docker Images Gitãªã³ã¯
Gitããã³ã³ãã€ã«ããããã¹ãŠã®Dockerã€ã¡ãŒãžã¯ãäžæãšãªãªãŒã¹ã®2ã€ã®ã«ããŽãªã«åé¡ãããŸãã äžæçãªç»å㯠Gitã®ãã©ã³ãã®ååã§ã¿ã°ä»ãããã次ã®ã³ãããã§äžæžãã§ãããã¬ãã¥ãŒçšã«ã®ã¿å±éã§ããŸãïŒæ¬çªçšã§ã¯ãããŸããïŒã ããã¯ããªãªãŒã¹çãšã®éèŠãªéãã§ããå ·äœçãªã³ããããã©ã®ãããªãã®ã§ãããã¯ããããŸããã
ãã¹ã¿ãŒãã©ã³ãïŒãã¹ã¿ãŒã®çŸåšã®ããŒãžã§ã³ãåžžã«è¡šç€ºããããã«å¥ã®ãã©ãããã©ãŒã ã«èªåçã«ããŒã«ã¢ãŠãã§ããŸãïŒããªãªãŒã¹ãã©ã³ããç¹å®ã®ã€ãããŒã·ã§ã³ã®ãã©ã³ããªã©ãäžæçãªã€ã¡ãŒãžã§åéããããšã¯çã«ããªã£ãŠããŸãã
äžæçãªç»åã®ãã¬ãã¥ãŒããããã¯ã·ã§ã³ã§ã®ç¿»èš³ã®å¿ èŠã«ãªã£ãåŸãéçºè ã¯ç¹å®ã®ã¿ã°ãä»ããŸããã ãªãªãŒã¹ã€ã¡ãŒãžã¯ã¿ã°ã«ãã£ãŠèªåçã«åéããïŒãã®ã¿ã°ã¯Gitã®ã¿ã°ã«å¯Ÿå¿ããŸãïŒãã¹ããŒãžã³ã°ã«ããŒã«ã¢ãŠããããŸãã å質éšéã«ããæåãããã§ãã¯ã®å Žåã圌ã¯çç£ã«è¡ããŸãã
ããã
説æãããŠãããã¹ãŠïŒããŒã«ã¢ãŠããã€ã¡ãŒãžã®ã¢ã»ã³ããªããã®åŸã®ã¡ã³ããã³ã¹ïŒã¯ãBashã¹ã¯ãªããããã³ãã®ä»ã®ãå³èãæ段ã䜿çšããŠåå¥ã«å®è£ ã§ããŸãã ãããããããè¡ããšãããæç¹ã§å®è£ ãéåžžã«è€éã«ãªããåŠçãäžååã«ãªããŸãã ãããç解ããŠãCI / CD- dappãæ§ç¯ããããã®å°çšã®ã¯ãŒã¯ãããŒãŠãŒãã£ãªãã£ãäœæããŸãã ã
ãœãŒã¹ã³ãŒãã¯Rubyã§æžãããŠããã GitHubã§å ¬éãããŠããŸã ã æ®å¿µãªãããçŸæç¹ã§ã®ããã¥ã¡ã³ãã¯ããŒã«ã®æã匱ãç¹ã§ãããçŸåšäœæ¥äžã§ãã ãããŠäœåºŠãäœåºŠãdappã«ã€ããŠæžããŠè©±ããŸãã é¢å¿ã®ããã³ãã¥ããã£å šäœãšãã®æ©èœãå ±æããããšå¿ããé¡ã£ãŠããŸãããä»ã®ãšããã¯åé¡ãéä¿¡ããŠãªã¯ãšã¹ãããã«ããGitHubã§ãããžã§ã¯ãã®éçºããã©ããŒããŠãã ããã
2019幎8æ13æ¥æŽæ°ïŒ dappãããžã§ã¯ãã®ååãwerfã«å€æŽããããã®ã³ãŒããå®å šã«Goã«æžãæããããããã¥ã¡ã³ããå€§å¹ ã«æ¹åãããŸããã
ã¯ãã«ããã¹
ãããã§ãã·ã§ãã«ç°å¢ã§ãã§ã«å€§ããªèªç¥ãåŸãŠãããã1ã€ã®æ¢è£œã®ãªãŒãã³ãœãŒã¹ããŒã«ã¯ãDockerã管çããããã®ã¯ã©ã¹ã¿ãŒã§ããKubernetesã§ãã Dockerã§æ§ç¯ããããããžã§ã¯ãã®éçšã«ããã䜿çšã®ãããã¯ã¯ã¬ããŒãã®ç¯å²ãè¶ ããŠããããããã¬ãŒã³ããŒã·ã§ã³ã¯ããã€ãã®èå³æ·±ãæ©èœã®æŠèŠã«éå®ãããŠããŸãã
Kubernetesã®ããŒã«ã¢ãŠãã§ã¯æ¬¡ãæäŸããŸãã
- æºåç¶æ³ãããŒã-ã¢ããªã±ãŒã·ã§ã³ã®æ°ããããŒãžã§ã³ã®æºåç¶æ³ã確èªããŸãïŒãã©ãã£ãã¯ãåãæ¿ããŸãïŒã
- ããŒãªã³ã°æŽæ°-ã³ã³ããããã®ã¯ã©ã¹ã¿ãŒå ã®ã€ã¡ãŒãžã®é 次æŽæ°ïŒã·ã£ããããŠã³ãæŽæ°ãèµ·åã®æºåããã©ãã£ãã¯åãæ¿ãïŒ;
- åææŽæ°-ç°ãªãã¢ãããŒãã§ã¯ã©ã¹ã¿ãŒå ã®ã€ã¡ãŒãžãæŽæ°ããŸããæåã«ã³ã³ãããŒã®ååã§ã次ã«æ®ãã§ã
- ã«ããªã¢ãªãªãŒã¹-ç°åžžãç£èŠããããã«ãéãããïŒå°æ°ã®ïŒã³ã³ããã§æ°ããã€ã¡ãŒãžãèµ·åããŸãã
ç¶ç¶çããªããªã¯æ°ããããŒãžã§ã³ã®ãªãªãŒã¹ã ãã§ã¯ãªããããKubernetesã«ã¯ã€ã³ãã©ã¹ãã©ã¯ãã£ã®ãã®åŸã®ã¡ã³ããã³ã¹ã®ããã®å€ãã®æ©äŒããããŸãïŒãã¹ãŠã®ã³ã³ããã«ãããçµã¿èŸŒã¿ã®ç£èŠãšãã°èšé²ãèªåã¹ã±ãŒãªã³ã°ãªã©ã
æçµçãªæšå¥šäºé
- Dockerã䜿çšããŸãã
- Dockerã¢ããªã®ç»åããã¹ãŠã®ããŒãºã«åãããŠäœæããŸãã
- ãã€ã³ãã©ã¹ãã©ã¯ãã£ã¯ã³ãŒãã§ãããšããååã«åŸããŸãã
- GitãDockerã«é¢é£ä»ããŸãã
- ããŒã«ã¢ãŠãé åºã調æŽããŸãã
- æ¢è£œã®ãã©ãããã©ãŒã ïŒKubernetesãªã©ïŒã䜿çšããŸãã
ãããªãšã¹ã©ã€ã
ã¹ããŒãã®ãããªïŒçŽ1æéïŒãYouTubeã§å ¬éãããŸãã ïŒã¬ããŒãèªäœã¯5åããå§ãŸããŸãã ãªã³ã¯ã¯ãªã³ã¯äžã®ãã®ç¬éããã§ãïŒ ã
ã¬ããŒãã®ãã¬ãŒã³ããŒã·ã§ã³ïŒ
PS
ããã°ã®ãããã¯ã«é¢ãããã®ä»ã®ã¬ããŒãïŒ
- ã Werfã¯Kubernetesã®CI / CDããŒã«ã§ãïŒã¬ãã¥ãŒããã³ãããªã¬ããŒãïŒ ã ïŒDmitry Stolyarovã2019幎5æ27æ¥ãDevOpsConfïŒ ã
- â ããŒã¿ããŒã¹ãšKubernetes â ïŒDmitry Stolyarov; 2018幎11æ8æ¥HighLoad ++ïŒ ;
- ã KubernetesãšGitLabã§ã®CI / CDã®ãã¹ããã©ã¯ãã£ã¹ ã ïŒDmitry Stolyarov; 2017幎11æ7æ¥HighLoad ++ïŒ ;
- ã å°èŠæš¡ãããžã§ã¯ãã§ã®Kubernetesã§ã®çµéš ã ïŒDmitry Stolyarovã2017幎6æ6æ¥ãRootConfã§ïŒ ã