ãã®è³æã¯ã RootConf 2017ã§ã®ç§ã®ã¬ããŒãã«åºã¥ããŠãããã°@ Conference of Oleg BuninïŒOntikoïŒå°çšã«äœæãããŸãã ã
ã©ã®ããã«ãã¹ãŠãå§ãŸããŸãããïŒ
ããã¯ãã¹ãŠãç§ã1ã€ã®äŒç€Ÿã§åãå§ããããã§æ°ãæåãããšããäºå®ããå§ãŸããŸãã...ãããŠçªç¶ãå€ãã®èŠå ãäžèŽããŸããã
- ãã®äŒç€Ÿã¯ããªã倧ããªãªã³ã©ã€ã³ã¹ãã¢ã§ããã åœæã圌女ã¯ããŸããŸãªè©äŸ¡ã§åœå
ã®ããã15ã®ãªã³ã©ã€ã³ã¹ãã¢ã«ã©ã³ã¯ãããŠããŸããã
- ãã®äŒç€Ÿã«ã¯25人ã®éçºè
ã®ã°ã«ãŒããããŠããã¹ãŠã瀟å
ã§èŠãããå庫管çãç©æµããWebéå£ããã¹ãŠã®ãã¹ã±ãããªã©ããã¹ãŠãæŽå²çã«å
éšã«æžã蟌ãŸããŠããŸããã
- ãããã¯ã·ã§ã³å
šäœãæäœããã³ãŒãããããã€ããéçºè
ãæžããŠã圌ãgit pullãå®è¡ããå¥ã®ããŒãã«ããã泚ããAnsibleãæã£ãŠãã管çè
ã1人ããŸããã
ãããŠçªç¶ã14幎ç®ã®çµãããèµ·ãããŸããã 14幎ç®ã®çµããã«äœãèµ·ãã£ãã®ã誰ããç¥ã£ãŠããŸããAmazonã¯éåžžã«é«äŸ¡ã«ãªããŸããã ããã§ã¯ãããŸããã 圌ã¯éåžžã«é«äŸ¡ã«ãªããåæã«ãå¯äžã®ç®¡çè ãèŸããŸããã
ãããŠãç§ãã¡ã¯-25人ãAmazonãAnsibleïŒæçµçã«ã¯å®å šã«æžãããŠããŸãããïŒã巚倧ãªãªã³ã©ã€ã³ã¹ãã¢-æ¯æ¥äœçŸäžã«ãŒãã«ã®å£²ãäžã-ããªãã¯è»¢åããããšããç ŽãããšããåŸæããããšãã§ããŸããã
äžè¬çã«ãç¶æ³ã¯å³ã®ããã§ã
äœããå€ããå¿ èŠãããããšã«æ°ã¥ããŸããã ãããŠãäžè¬çã«ã¯ãã§ã«æ°ã«ããªãç¶æ³ãªã®ã§ãç§ãã¡ã¯ãã¹ãŠãå€ããããšã«ããŸããïŒã¬ã¬ã·ãŒãšãã¹ãŠã®ãã®ãæåŠããŸãã
ç§ãã¡ã¯äœããããã£ãã®ã§ããïŒ
ãŸãããã¹ãŠãåžžã«å€§ããªã¢ããªã¹ã§èŠãããŠããŸãã.1ã€ã®å€§ããªããŒã ã§ã¢ããªã¹ãåå¥ã®ãµãŒãã¹ïŒãã€ã¯ããµãŒãã¹ã§ã¯ãªãããµãŒãã¹ã®ã¿ïŒã«åå²ããŠã補åããŒã ã25人ã«ç¹åããããšèããŠããŸããã
ãããåæã«ãå šå¡ãäºãã«å¹²æžããªãããã«ãããã£ãã®ã§ãã devOpsã欲ããã£ãã®ã¯ã管çè ãç§ãã¡ãå»ããç§ãã¡ã¯è³¢ã人ã ã£ãããã§ãããã³ãŒããšããŠã®ã€ã³ãã©ã¹ãã©ã¯ãã£ããªã©ã®æ¬ãèªã¿ãŸããã
ããã«ããã¹ãŠãèªååãããŠããå Žåã¯ããã¹ãŠãããç°¡åã«ãããéãããã¹ãŠãæ£åžžã«æ©èœããã©ããªãã®ãããç°¡åã«ãªããŸãã
ãã¡ããã1人ã®ç®¡çè ãããŠã圌ãèŸãããããæ°ãã管çè ãåé€ãããŸã§æ¡çšããªãããšã«ããŸããã
玹ä»çãªãã®ã¯æ¬¡ã®ãšããã§ãã
ã©ããžè¡ãã®ïŒ
ãã¡ãããDockerã§ã¯ã第äžã«ãåªããææ ããããŠç¬¬äºã«ãç§ãèšã£ãããã«ããŒãããã¯ãŒã«ã«ãã¹ãŠãããããã£ã-ããããã§ã¹ã¿ã€ãªãã·ã¥ãªè¥è ãDockerãèªå€§åºåãªã©ããã¹ãŠã®ããšããããã£ãããã§ãã
2017幎ã®èå³æ·±ã質åïŒ
- Dockerã«ã€ããŠãŸã£ããèããããšããªã人ã¯ããŸããïŒ
- ãããŠãå°ãªããšãããŒã«ã«ãã·ã³ã§Dockerã䜿çšããã®ã¯èª°ã§ããïŒ
- ãããŠãå°ãªããšãããã€ãã®åãã«è¶³ããªããµãŒãã¹ã®ããã«ãDockerãå®çšŒåç°å¢ã§ç«ã¡äžããã®ã¯èª°ã§ããïŒ
- ãããŠãå®å
šã«æ¬çªã§Dockerã«äœãã§ããã®ã¯ãDockerã³ã³ãããŒã ãã§ãä»ã«äœããããŸãããïŒ
ãããã§ãã·ã§ãã«ãã§ã¹ãã£ãã«ãRussian Internet Technologies RIT ++ 2017ãã§ã¯ãDockerã«ã€ããŠèããããšããªã人ãçæã§æ°ããã®ã«ååã§ããããã¬ã³ãã¯ããžãã£ãã§ãããç§ãã¡ã¯ééã£ãŠããŸããã§ããã
ããã¯2014幎ã®çµããã§ãããDockerã¯å€ç¬ãªã¯ãžã©ã®ãããªãã®ã ã£ãããšãæãåºããŸãã
äºå®ã¯ãDocker-ã³ã³ãããDSLãDocker-ãã¡ã€ã«ãªã©ã®åªããæŠå¿µå®èšŒã·ã¹ãã ã§ããã 圌ã«ã¯1ã€ã®åé¡ããããŸãããä»äºã®åé¡ã1å°ã®ãã·ã³ã§è§£æ±ºãã以äžã®ããšã¯ãŸã£ããããŸããã§ããã
1å°ã®ãã·ã³ã§ã¯ãå éšã¡ãã·ã¥ã¯åé¡ãããŸããã è€æ°ã®è»-ãŸã£ããäœããããŸããã§ããã ããæ£ç¢ºã«ã¯ãç°ãªãã¢ããªã³ããããŸãã-Dockerã®ã©ãããŒã¯ããã·ã³éã®ãããã¯ãŒã¯ãäœæããã³ã³ãããŒãçžäºã«æããŸããã
ãããã1å°ã®ãã·ã³ã«ã¯åãŸããŸããã§ããã ç§ãã¡ã¯ããŸããŸãªãªãã·ã§ã³ãæ€èšãå§ããããã§éãã§ãå¥ã®ãªãã·ã§ã³ã§ã3çªç®ã5çªç®ã10çªç®ã§è©ŠããŸããã ãããŠãDockerã泚ææ·±ãèŠãŠãå éšãããã¯ãŒã¯ãè¡ããšãã³ã³ãããŒãæã¡äžãããã¹ãŠã®ãããã¯ãŒã¯ã€ã³ã¿ãŒãã§ãŒã¹ã1ã€ã®ããªããžã«éããŠãããããåãããŒã«ã«ãããã¯ãŒã¯äžã«ããããšã«æ°ä»ããŸããã
ããããDockerã®ãŠãŒã¶ãŒããã¬ã³ãã£ã§ããã¹ãŠãæ§æã§ããŸãã ãããã£ãŠããã®ãããªã¯ãŒã«ãªãããã¯ããããŸãïŒDockerã¯ã䜿çšããŠããããªããž-éåžžã®Docker 0ã§ã¯ãªããããçš®ã®å¥åã®ããªããž-ãç¥ãããšãã§ããã©ã®ãµããããããIPã¢ãã¬ã¹ãã³ã³ããã«çºè¡ããããæå®ã§ããŸãã
ç§trickã¯ãããªããžãååŸãããããå éšã€ã³ã¿ãŒãã§ãŒã¹ãç©çãã·ã³ã«æ¥ç¶ããããã«ã³ã³ããããã³ã°ããããšãããããã¹ãŠã®ã³ã³ãããèªåçã«LANãèªèããããšã§ãã ãããŠãããªããLANå šäœãæã£ãŠããåã倧ããªãããã¯ãŒã¯ããã©ã®ãµãããããšãµãããããäœæããããèšããšãã³ã³ãããæã¡äžãããšãLANããIPããããããŒã«ã«ãããã¯ãŒã¯äžã®ä»ã®ãã·ã³ã®ã³ã³ããã衚瀺ãããŸãã
ãã¹ãŠã®ã³ã³ããã®å éšãããã¯ãŒã¯ãæŽçãããã®ãããªå®äŸ¡ãªæ¹æ³ã
ãã§ã«ç§ãã¡ã¯ã¢ããŸã³ãå»ã£ãŠãããšèšã£ãã®ã§ãç§ãã¡ã¯ç§ãã¡ã®åœã§éåžžã«æåãªãã¹ãã£ã³ã°æ¥è ã«è¡ãã圌ããã¬ã³ã¿ã«ãããããŒããŠã§ã¢ã®æãåããŸãã-10-15å°ã®ãµãŒããŒããã¹ãŠLANã«ããããŠããã§ãã IPã¯ãã·ã³äžã®ãã³ãã«ãäºæ³éãã«é 眮ããåãã·ã³ã«ãµãããããå²ãåœãŠãŸããã
ç§ãã¡ã¯äœãããŸãããïŒ
- ã³ã³ããã欲ããã£ã-å
¥æããã
- è»ããããŸã-ã³ã³ãããæã¡äžããŸãã
- ãã¹ãŠã®ã³ã³ããã¯äºãã«èŠããŸãã
ãã®ãããªå€§ããªå¹žããªããŒã«ã«ãšãªã¢ãããã¯ãŒã¯ã
ããã¯ã¯ãŒã«ã§ããããªãã¯ãã§ã«äœããããããšãã§ããŸã-ã³ã³ããã«ã¢ããªã±ãŒã·ã§ã³ãè©°ããŠãæã¡äžããŠããäºãã«è¡ããAPIãRPCãREST-äœã§ãïŒ
質åã¯æ¬¡ã®ããã«ãªããŸã-誰ãã©ãã§äžæããããã©ã®ããã«å€æããŸããïŒ ããã«ãã³ã³ãããäžäžãããæ¯åç°ãªãIPãããå Žåãäºæž¬å¯èœãªãã®ã¯ãããŸããã
ãããŠãç§ãã¡ã¯é äºããšã£ãã ããã¯ããã€ãŠVagrantãäœã£ã人ãã¡ãäœã£ããœãããŠã§ã¢ã§ãããã€ã³ãã©ã¹ãã©ã¯ãã£å°çšã®ããããçš®é¡ã®ããŒã«ãäœæããã®ã«éåžžã«ãã£ãããšäŒã¿ãŸããã ããã¯ããã¹ãŠã®æ å ±ã®åæ£ãªããžããªã§ãã ãã€ã³ãã¯ãè€æ°ã®ã€ã³ã¹ã¿ã³ã¹ãååŸããããããçžäºã«èšå®ãããããããã¹ãŠåãæ å ±ãå éšã«ä¿åããããšã§ããã€ãŸããåæ£ã¹ãã¬ãŒãžã§ãã
ããã«å ããŠã圌ãã¯çµ¶å¯Ÿã«çŽ æŽãããããšãããŸããã ããã«æ å ±ã転éããæ¹æ³ã«ã€ããŠã¯å°ããªåæãããããã®Consulã¯DNSçµç±ã§å¿çã§ããŸãã ã€ãŸããæ¯èŒçèšãã°ããµãŒãã¹ãç»é²ããŠããããã®DNSã«ã¢ã¯ã»ã¹ã§ãããã·ã³ããããã®ãããªååã®ãµãŒãã¹ãèŠæ±ãããšãIPãæäŸãããŸã-ããã ãã§ãã
ããã¯ãã¹ãŠãæµè¡èªãµãŒãã¹ãã£ã¹ã«ããªãšåŒã°ããŸãã ç§ã®æèŠã§ã¯ã0.6ãããåã®éåžžã«å€ãããŒãžã§ã³ããConsulã䜿çšãå§ããŸããã
æçµçã«äœã«ãªããŸããïŒ
- ãã¹ããããŸãã
- ã³ã³ããããããŸãã
- ã³ã³ããã¯äºãã«äŒããŸãã
- ã³ã³ãããæäœããããã®ããŒã«ããããŸãã
Dockerã§ã¯ãã³ã³ããå ã§éä¿¡ãããDNSãåå¥ã«ç»é²ã§ããŸãããããç»é²ããåéã®ãã·ã³ã§ãµãŒããŒã¢ãŒãã§Consulãèµ·åããŸãã
ã€ãŸããåãã¹ãã«ã¯ããã®Consulã®ã¯ã©ã¹ã¿ãŒããµã€ãã«ãããŸããåãã¹ã-1ã€ã®ããŒããæ å ±ããã£ã¹ããªãã¥ãŒã¿ãŒããã©ãŒã«ããã¬ã©ã³ã-äžè¬ã«ãããã¯ã¯ãŒã«ã§ãïŒ
è¯ããœãããŠã§ã¢ã䜿çšããŠãã ããïŒ
ããããé äºã¯ç»é²ã ãã§ã¯ãããŸããã åãã¹ããã·ã³äžã®åå¥ã®ConsulãµãŒããŒ-ããã§ã¯ããã¹ãŠã®çš®é¡ã®æ å ±ãçžäºã«äº€æããŸãã
ãããŠãåé¡ãçºçããŸã-ç§ãã¡ã¯ã³ã³ãããäžããŠããŸããïŒ åœŒãã©ãã«ããã®ããç¥ãæ¹æ³ã¯ïŒ ã©ãã«ãã©ã®ãããªãµãŒãã¹ãååšããããªã©ã ã€ãŸããå®è¡äžã®ã¯ã©ã€ã¢ã³ãã§ãäœããã®æ¹æ³ã§Consulã«ã¢ã¯ã»ã¹ããå¿ èŠããããŸããAPIãŸãã¯åãConsulã䜿çšããŸãããã¢ãŒãã¯å°ãç°ãªããŸãã
ãããŠãããã§æåã®å®ææŠäºããããŸããã ç§ãã¡ã¯ãå ã®ãšãã£ãççŽãªè ã®æŠäºãšåŒã³ãŸããã
ããŠãããã¯ããã»ã©æ·±å»ã§ã¯ãããŸããããããŠã2014-15幎ãDockerããããèªå€§å®£äŒãå§ãŸã£ãã°ããã®ãšããå€ãã®è«äºããããŸããã1ã€ã®ããã»ã¹ãåé¢ããããã«Dockerã§ããïŒ ã¯ããPID 1ããããŸããç°å¢å šäœãäžæãããšããã€ããªãéå§ãããŸãããšã³ããªãã€ã³ããèšè¿°ããDockerãã¡ã€ã«ã«-ããããããŸãã ãŸãã¯ãè€æ°ã®ããã»ã¹ãã³ã³ããã«è©°ã蟌ãããšãã§ããŸãããããã«å¿ããŠãæåã«äœããã®ã¹ãŒããŒãã€ã¶ãŒãªã©ãçºçãããŸãã
ç§ãã¡ã¯éåžžã«é·ãéè°è«ããŸãããããã¯å®éã«ã¯å®ææŠäºã§ããã ãã®çµæã圌ã¯åã£ããç§ã¯ãšã³ãã£ã³ã°ã®äžã€ã§ãããèŠããŠããªãã
äžè¬ã«ãDockerã¯ã·ã¹ãã ã®äžéšã§ãããå¿ ããã1ã€ã®ããã»ã¹ã§ã¯ãªãããšã«åæããŸããã ããã§ãå éšã§ãããçš®ã®ã¹ãŒããŒãã€ã¶ãŒãæããŸããäŸãã°ïŒ
ã€ãŸããæåã«ã¹ãŒããŒãã€ã¶ãŒãã³ã³ãããŒã«ç«ã¡äžãããšãå¿ èŠãªä»ã®ãã¹ãŠã®ããã»ã¹ãéå§ãããŸãã ããã¯ããã®ããŒãã§ã®ã¿äœ¿çšãããã¢ããªã±ãŒã·ã§ã³ã§ããå¯èœæ§ããããŸãã ããšãã°ãCronã®å ŽåããããŸããã€ãŸããã¢ããªã±ãŒã·ã§ã³ã¯ããã«ãããCronã¯è¿ãã§åäœããŸãããããããã»ã¹ã§ãã
ãããã£ãŠãããã«åæããããã³ã³ããå ã®åãå Žæã§ConsulãšãŒãžã§ã³ããå®è¡ã§ããŸãã ããã¯åãConsulã§ãç°ãªãã¢ãŒãã§ã®ã¿èµ·åãããäžè¬çãªã¯ã©ã¹ã¿ãŒã«ã¯åå ãããããã«æ å ±ãé 眮ããŸãã
ã³ã³ãããæã¡äžãããšãããã§ConsulãšãŒãžã§ã³ããèµ·åããŸãã æ§æã¯æ¢ã«ç»é²ãããŠããŸã-äºåã«ã³ã³ãããåéãããã¹ãŠãããã«çž«ãä»ããããŠããŸãã ããã¯äžæããç»é²ããŸã-äžè¬ã«ãéåžžã¯å€æããŸãã
ããããããªããéãå 端ãåã£ãå Žåã®ã¿ã
èšãããšãéåžžã«éèŠãªãã1ã€ã®ç¹ã¯ãConsulã¯ãµãŒãã¹æ€åºã ãã§ã¯ãªããšããããšã§ãã äžè¬ã«ãååãšããŠãService Discoveryèªäœã¯ããªã圹ã«ç«ããªããã®ã§ãããšããã®ã¯-ãããããããŸãããããªãã¯å§ããŠãã³ã³ãããå ¥ããŸããã ã€ãŸããäœããã®unDiscoveryãµãŒãã¹ãå¿ èŠã§ãã
ãããããŸãèœã¡ãã°ãããã¯ç解ã§ããŸãã ãããåå ã§ããããæ åœããäžéšã®ãœãããŠã§ã¢ãã¯ã©ã¹ã¿ãŒã«ä¿¡å·ãéä¿¡ããŸãããç§ã¯ãããããªãïŒãããã®ãã¡ãŒã ãåé€ããDNSå¿çããIPãæ¶ããŸãã
ããããããã§ãªãããšãããã°ãå£ããããççºãããããšã©ãŒãåºããããããšããããŸãã
Consulã«ã¯ãHealth Checksãšããéåžžã«äŸ¿å©ãªããŒã«ããããŸãã ããã¯ããµãŒãã¹ãç»é²ãããšãã«ãã¯ã©ã¹ã¿å šäœã«ãèªåãçããŠããããšã確èªããæ¹æ³ãäŒãããšãã§ãã éåžžã¯ãã¹ãŠãå§ãŸããŸããURLãæå®ããŠããŒãã«ç§»åããããããHTTP 200ãè¿ãããããšã確èªããŸãã
ããããå®éã«ã¯ããããã¯ã©ããªè€éãã§ãäœæã§ããŸãã ããã¯éåžžã«éèŠã§ãããããããç»é²ããŸãããäœããåæ¢ããŠããå ŽåãnginxãŸãã¯ãã®ä»ã®ãµãŒãã¹ãããå Žåã¯ãDNSå¿çã®æ¬¡ã®IPã«ãã€ã§ãåè©Šè¡ã§ããŸããã
ãã¡ãããããã¯ããã§ãã ããããé ããæ©ãããäžéšã®ããã°ã©ããŒVasilyã¯ãåçãã1ã€ã®IPãååŸãããããªãœãããŠã§ã¢ãäœæããããšã«ãªããŸãã ããã¯åœŒã«äžãã£ãŠããã¹ãŠã圌ãšäžç·ã«å£ããŸãããããŠããªãã¯ãããé·ãéãããŠäžå¹žã«èœãšãã§ãããããªããªãããã¯ãã®æ¹æ³ã§ã³ãŒããæžãããšãå¯èœã§ããããšããŽã¡ã·ãªãŒä»¥å€ã®èª°ã«ã決ããŠèµ·ãããªãããã§ãã
ãããã£ãŠãService Discoveryã«çŽæ¥çµã³ä»ããããService unDiscoveryãšHealth Checkã¯éåžžã«éèŠã§ãã
ããã§ãç§ãã¡ã¯äœãåŸãŸãããïŒ
ç©çãã·ã³ãlokalkaãã³ã³ãããäžæãããããã¯ãã¹ãŠäºãã«èŠããŸãã åã³ã³ããå ã§ã¯ãå¿ èŠãªå Žæã«ããããïŒçµå±ããµãŒãã¹ã¯åžžã«ä»ã®äººã«ã³ã³ãããæäŸããããã§ã¯ãªããåã«èµ·åã§ããã ãã§ãïŒãäžè¬çãªãµãŒãã¹æ€åºã«ãµãŒãã¹ãç»é²ãããã«ã¹ãã§ãã¯ãç»é²ãããšãŒãžã§ã³ããèµ·åãããŸãã ãããã¯ãã¹ãŠè¡ãæ¥ããŸã-äžè¬ã«ããã¹ãŠãããŸãããéããã¹ãŠã¯ããŸããããŸãã
ããããããã¯ãã¹ãŠããªãã®ãã«ã«ã«å ã«ã®ã¿ååšããå€ã«åºãæ¹æ³ã®åé¡ããŸã£ãã解決ããŸããã
ãã®å Žåãç§ãã¡ã¯ãªã³ã©ã€ã³ã¹ãã¢ã§ããããªã³ã©ã€ã³ã¹ãã¢ããã³ããšåŒã°ãããµãŒãã¹ããããŸããã ããã¯å ¬éWebãµã€ãã§ãã ããšãã°ãäžéšã®ãµãŒãã¹ã¯ããŒãããŒã«APIãæäŸããããšã«ãªã£ãŠããŸãã äžéšã®ãµãŒãã¹ã¯ããªã³ã©ã€ã³ã¹ãã¢å ã®åã ã®éšéããã³ãŠãããã®ç®¡çè ãåéããå ¬çã«ã¢ã¯ã»ã¹å¯èœãªURLã«å¿çããå¿ èŠããããŸããã
ããã解決ããã«ã¯ïŒ
ããããçš®é¡ã®ãã¡ãã·ã§ããã«ãªã·ã¹ãã ã§ã¯ãããã¯IngressãšåŒã°ããããã«ãªããŸãããå€éšããã¯ã©ã¹ã¿ãŒã«å°éããå Žåãããã§ãã©ã³ã¹ããšããŸãã ç§ãã¡ã¯åçŽã«å§ããŸããïŒç§ãã¡ã¯èšããŸããïŒç§ãã¡ã¯ãã€ãã®ããã«èµ·åããå¥ã®ãµãŒãã¹ãçšæããŸããã80ã§ãããªãã¯ããŒãããªãã¹ã³ããå¿ èŠãããããšã圌ã«äŒããã ãã§ã-DockerããŒã転éãªã©ã
å éšã«ã¯nginxããããnginxãšäžŠè¡ããŠConsul TemplateãšåŒã°ããçŽ æŽããããœãããŠã§ã¢ããããŸãã 圌ã¯ã³ã³ã¹ã«ãäœã£ãã®ãšåã人ãã¡ããã§ãã ãã®ãœãããŠã§ã¢ã«ã¯1ã€ã®ç°¡åãªç®çããããŸããConsulã§æ€çŽ¢ããããã§äœããå€æŽããããšãããŒã«ã«ã§æ°ããæ§æãçæããnginx reloadãªã©ã®ã·ã§ã«ã³ãã³ããå®è¡ã§ããŸãã ãã®ãããåžžã«çŸåšã®nginxæ§æãšãå éšã®ãªã¯ãšã¹ããå€éšã®ç¹å®ã®ãµãŒãã¹ã«ã«ãŒãã£ã³ã°ããããšãã§ããŸãã
ãŸããConsulã§ãµãŒãã¹ãç»é²ããå Žåãä»éãããã¹ãŠã®æ å ±ãã¿ã°ã®åœ¢åŒã§ããã«é 眮ã§ããŸãããããã®ã¿ã°ã¯ãã¹ãŠããã³ãã¬ãŒãããèšå®ãåéãããã®ãã³ãã¬ãŒããšã³ãžã³ã®ã³ã³ããã¹ãã§ã¯ãŸã£ããåãã«ãªããŸãã ãããã£ãŠãããšãã°ãããã«ãããªãã¯ãã¡ã€ã³ãæžãããšãã§ããŸã-ããªãã¯ããããµãŒãã¹ã«ããã·ã¥ããŸã-ããªãã¯èšã-ããã¯ãããªãã¯httpã¿ã°ãå¥ã®ã¿ã°ãæã£ãŠããŸã-IPãªã©ãIPãªã©ãªã©ããããŠãã®åŽããããªãã®èšå®ãçæããŸã
é£æ¬²ã¯é£äºã«äŒŽããã®ã§ããããããã¹ãŠã®ãµãŒãã¹ãèªåçã«æç»ããã ãã§ãªããããšãã°ããã®ãããªãµãŒãã¹ã«äººã ãåå ãããããªããããããã®äººã ã ããèš±å¯ãããå Žåã«äœããã®èªèšŒãæç»ããäžå€®ã®OAuthã§æ¿èªãããŠããŸãããã¢ããªã±ãŒã·ã§ã³ã§å®è£ ãè¡ããããããŸããã
ããšãã°ãGrafanaãèšå®ããŠé衚瀺ã«ããŸããã GrafanaãããŒã«ã«ãããã¯ãŒã¯ããã§ã¯ãªããå€éšããèŠããå ŽåããããŸãããåæã«ç¬èªã®èªèšŒããŸãã¯äœããã®LDAPãçºçãããå¿ èŠããããŸããäžè¬ã«ãhemoãããããããããããã·ããæ¹ãç°¡åã§ãã
ãã®åŸãLet's Encryptãç»å Žããhttps蚌ææžãèªåçã«çºè¡ããå¿ èŠããããŸããããããã«äœãä»ã®ãã®ãè¿œå ãããŸããã
ãã®çµæãå éšã«å·šå€§ãªã¢ããªã±ãŒã·ã§ã³ãäœæããŸããã ãªã³ã¯ã®ãªã¹ãã§ã¯ãæåŸã®è¡ã«ãããŸãã å ¬ã®å Žã§ã®ãã®ã¢ããªã±ãŒã·ã§ã³ã¯ãç§ãã¡ã®å éšã§æ©èœãããã®ã§ã¯ãããŸããããååãšããŠãã©ã®ããã«æ©èœããããç§ã«å°ããããšãã§ããŸãã
å®éãããã¯æ©èœã®10ïŒ ãè¿œå ããããªã倧ããªã¢ããªã±ãŒã·ã§ã³ã§ããããªãœãŒã¹ã®80ïŒ ãæ¶è²»ããŸããã ããã«äœ¿çšã§ããConsulãã³ãã¬ãŒããšæ¯èŒããŠãå®å®æ§ãšä¿¡é Œæ§ãé«ãã質åã®80ïŒ ã解決ã§ããŸãã
ã³ã³ãããèœäžããããççºããããè»ãæ éãããããããã¯ãŒã¯ã1å°ã®ãã·ã³ãè€æ°ã®ãã·ã³ã§æ¶ããããããŒããã©ã€ããæ éããããæªç¥ã®ãŽããçºçãããããããšããããŸãã
ãŸããããã§ã¯ãã³ã³ãããšèŠãªããããã®ã«ã€ããŠè»œãå®ææŠäºããããŸããã
ã³ã³ãã-ä»®æ³ãã·ã³ã«è¿ãã§ããïŒ ãç§ãã¡ã¯ãã§ã«ããããã®ããã»ã¹ãããããã®ãµãŒãã¹ãè©°ã蟌ãã§ããŠãããã§åããŠããããšããããšã¯ç¹ã«especiallyçã§ããã ããã¯ä»®æ³ãã·ã³ã§ãéåžžã«è»œãã§ãïŒ ãã®ããã«æ±ã£ãŠã¿ãŸããããã
ãŸãã¯ãã³ã³ããã¯ãããªããããã§æšãŠãããã§æŸããããã§æšãŠãããã§æŸã£ãæ¶èåã§ã-ç¶æ ã¯å éšã«ä¿åãããŠããããç§ãã¡ã¯äœãæ®ããããããŸããã
éåžžãã³ã³ããã¯æ¶èåãšããŠæ±ãããŸãã å éšã«ç¶æ ã¯ä¿åãããŸããã ãã¡ãããããã¯éçºè ã«ç¹å®ã®å¶éã課ããŸãã ããšãã°ãããŒã«ã«ãã¡ã€ã«ã·ã¹ãã ã«ã¯äœãä¿åã§ããŸããã 決ããŠã ãŠãŒã¶ãŒãåçãã¢ããããŒãããå Žåã¯ãäœããã®å€éšãµãŒãã¹ã«éä¿¡ããå¿ èŠããããŸãã
è¯ãæ¹æ³ã§ã¯ãããã¯ã©ããªå Žåã§ãåžžã«è¡ãããã¹ãã§ãããåçãä¿åããã ãã§ã¯ãããŸããã
ãŸãã¯ãããšãã°ãå®çŸ©äžããã¹ãŠãä¿æããå¿ èŠãããããŒã¿ããŒã¹ã§ãã®å Žåã«äœããã¹ãããå¥ã®è³ªåãçºçããŸã-ããã€ãã®ç¶æ ãä¿åãããããŒã¿ã暪ããã£ãŠããŸããïŒ
ãŸããå°ãæ»ã£ãŠãããã¯ãŒã¯ïŒãã¢ããŒãã¢ã®éåžžã®ãããã¯ãŒã¯ïŒã«ã€ããŠèãããšãéåžžã®DBAã»ããã¢ãããè€è£œãããã¯ã¢ããã®ããã«ããã¹ãããåããã·ã³ãããã¯ã¢ããããŠããã®Dockerã¯ã©ã¹ã¿ãŒã®é£ã«ããŒã¹ãé 眮ã§ããŸãããªã©ãªã©ã ããã«ãå¿ èŠã«å¿ããŠããã¹ãŠã®ã³ã³ãããService Discoveryã«ç»é²ããããšãã§ããŸãã
ãããŠãããªãã¯ç§ãã¡ãšåãåæ¢ãªäººã«ãªãããšãã§ããç§ãã¡ã¯å®å šã«Dockerã«äœãã§ãããšå«ã³ãã³ãããããŸãã ãã®åŸãå°ãäœæ¥ããå¿ èŠããããŸãããäžæº¶æ§ã®åé¡ã¯ãããŸããã
ããšãã°ããã®ã±ãŒã¹ã§ã¯ãMySqlãšRabbitMQãéåžžã«ç©æ¥µçã«äœ¿çšããŸããã ãããšããã®äž¡æ¹ã¯ããã£ã¹ã¯ã«äœããæžãããã®ããŒã¿ãä¿åããããšãæã èŠæ±ããŸãã ã³ã³ãããçªç¶ççºããå Žåã¯ãã³ã³ãããæã¡äžããã¬ããªã±ãŒã·ã§ã³ãæ§æãããªã©ã®å¿ èŠããããŸãã
äžè¬çã«ãæ倧ã®åé¡ã¯ããã®ããã«æ©èœããã³ã³ãããåéããããšã§ã¯ãããŸããã Consulã®ãããªãã¹ãŠã®ãã¡ãã·ã§ã³ã·ã¹ãã ã®å Žåã®ããã«ãã³ã³ãããåãåããæ®ãã®äººãã¡ãã©ãã«ãããã圌ã«äŒããŸãã äžæããç¶æ ãããŒã«ããããŒã¿ãåéããã¯ã©ã¹ã¿ãŒã«åå ããŠåäœãéå§ããŸãã
MySqlã®å Žåãããã¯Galeraã®äžã§è¡ãããŸãã Galeraã¯ããã®ãããªåæãã«ããã¹ã¿ãŒã¬ããªã±ãŒã·ã§ã³ã§ãã ããã¯ããŸããããŸããç§ã¯çå£ã«èšããŸããç§ã¯å€§å¥œãã§ãã
ããŠãµã®ãã®å ŽåãåããŽãã ã³ã³ãããæã¡äžãããšãã«ã¯ã©ã¹ã¿ã«æ¥ç¶ããŠå ¥åããå°ããªã¹ã¯ãªãããèšè¿°ããããšã¯ããã»ã©é£ãããããŸããã
誰ãããããè¡ãããšããå§ãããŸã-éè¡ããªãã§ãã ãããããŒã¿ããŒã¹ãå¥ã ã®ãµãŒããŒã«çœ®ããªãã§ãã ãã-ãã¹ãŠãã³ã³ããã«æŒã蟌ãã§ãã ãããããã¯ã¯ãŒã«ã§ãïŒ
ãã¡ãããïŒã»ãŒïŒç¡æã§åãåã£ããã·çŒãã«ã€ããŠ
ãã®ãã¹ãŠãè©Šãããšã-ã³ã³ãããå ¥ããŠãã¢ããªã±ãŒã·ã§ã³ãæã¡äžãã-æ°ããããŒãžã§ã³ãã©ã®ããã«ããŒã«ããã¯ããŸãããïŒ ãã¡ãããã³ã³ããã§git pullãå®è¡ããŸããã§ããã ç§ãã¡ã¯ãé©åãªäººãšåæ§ã«ããã¹ãŠãæ°ããã³ã³ããã«éããŸããã ã³ãŒãã®æ°ããããŒãžã§ã³ãConsulã®æ°ããæ§æããã®ä»ã®ããã€ãããããŸããã 次ã«ãã¯ã©ã¹ã¿ãŒã«å ¥ã£ãŠèµ·åããŸããã ããæ£ç¢ºã«ã¯ãæåã«å€ããã®ãç«ã¡äžãã次ã«æ°ãããã®ã調éããŠç§»è¡ãæšé²ããŸããã
ããããããŒã±ãã£ã³ã°ããã£ãŠæ¥ãŠããããäžåºŠãããŠã³ã¿ã€ã ãã¢ããããŒããæºåããŠãã ããïŒããšèšããŸãã...
æããã«ãç§ãã¡ã¯ç«ã¡æ¢ãŸã£ãŠèããèšããŸãããããŸããåŸ ã£ãŠãã ãããããã«äœãã§ãããã¹ãŠã®äººã«èªåçã«ç¥ãããService DiscoveryããããŸãã ã©ã€ãããŒããååšãããã©ãããå€æã§ãããã«ã¹ãã§ãã¯ããããŸãã ããã«ãçããŠãã-ããã¯å¿ ãããæ»ãã§ãæ©èœããŠããªãããã§ã¯ãããŸããïŒ äžããããšãã§ããŸããããŸã ä»äºã®æºåãã§ããŠããŸããïŒ
ã³ã³ãããæã¡äžãããåæ¢ãããããæ¹æ³ãç¥ã£ãŠããŠãDockerã®å Žåãããã¯ããªãå®äŸ¡ãªæäœã§ãããã«ãŒ/ã°ãªãŒã³å±éãããŒãªã³ã°æŽæ°ãªã©ã®ãã¹ãŠã®ãã·ã¥ã¿ãã¯ãããã«äœ¿çšã§ããŸãã ããªããããå¿ èŠãããå¯äžã®ããšã¯ãäœãåæ¢ããªãããŒã¿ããŒã¹ãžã®ç§»è¡ãæžãå¿ èŠãããããšããã¹ãŠã®ããã°ã©ãã«çŽåŸãããããšã§ãã
ã€ãŸããããŒãžã§ã³äºææ§ãããŒã¿ããŒã¹ã¹ããŒãã®äžäœäºææ§ãæ°ããããŒãžã§ã³ãäœæããå Žåãå€ãããŒãžã§ã³ã®ã¹ããŒããšæ°ããããŒãžã§ã³ã®ã¹ããŒãã®äž¡æ¹ã§åäœããå€ãããŒãžã§ã³ãæ¶å»ããŠããå€ãããŒãžã§ã³ãã¯ãªãŒã³ã¢ãããããªã©ã§ããå®éãéåžžã«åçŽãªããšã§ãã
ããã°ã©ããŒã説åŸããããã«å¿ èŠãªã®ã¯ãããªããè¯ãã¹ãã£ãã¯ãæã£ãŠããããããã°ã©ããŒãè³¢ããšãã ãã§ãã ãããããã®åŸããã¹ãŠãæ£åžžã«åäœããŸãã
ããšãã°ããªã³ã©ã€ã³ã¹ãã¢ããã³ããšåŒã°ãããã®ãã©ã®ããã«æŽæ°ããããéåžžã«èªãã«æã£ãŠããŸãã ã¯ã©ã¹ã¿ãŒã¯ãæ°ããããŒãžã§ã³ã®ã³ãŒãã§è€æ°ã®ã³ã³ãããŒãå®è¡ããŸããã 圌ãã¯ç«ã¡äžãããæºåãã§ããŠããŸããïŒ3ã€ã®ãã¡2ã€ã®ãã«ã¹ãã§ãã¯ãæ©èœããŸããã 3çªç®ã®ãã®ã¯ãã·ã§ãŒã±ãŒã¹ãå¿ èŠãªããŒã¿ããã©ãã°ããäºåã«ãã£ãã·ã¥ãããã£ãã·ã¥ãå ç±ãããªã©ã®çç±ã§ããŸã æ©èœããŸããã§ããã ãã®åŸããã«ã¹ãã§ãã¯ãç·è²ã«ãªããŸãããããã¯ããã§ã«ã©ã€ããã©ãã£ãã¯ãéä¿¡ã§ããããšãæå³ããŸãã
ããã ãã§ã-ããã§äžæããäžéããŸããã ããã§äœããééã£ãŠããå Žåãããã¯äžéããããã§äžæããŠããŸã-ããã¯éåžžã«ç°¡åã«åäœããŸãã
æãéèŠãªããšã¯ããã®äžã«éæ³ããªãããšã§ã-ããªãã¯ãã¹ãŠã®ããŒã«ãæã£ãŠããŸãã ç§Theã¯ããããè¿ éã«è¡ããããã«ããããšã§ããã æŽæ°ã«é¢ããã»ãšãã©ã®åé¡ã¯ãããã«äœããå®è¡ã§ããªãããšã§ãã ãã®æé ãé«éåããããŒã«ãããã°ããã¹ãŠãããŸãæ©èœããŸãã
2çªç®ã®ãã³ã¯ãããããã¹ãŠã®ç£èŠãè¡ã£ããšãã§ãããã¬ã€ãºãã€ã³ãã©ãã¯ã¹ãGrafanaãããã·ã¥ããŒãã ç§ãã¡ã®ãã©ãã€ã ã§ã¯ãåããŒã ããã®ãµãŒãã¹ã«è²¬ä»»ãè² ã£ãŠããŸãããå®éããã¹ãŠã®ã¢ã€ãã¢ãèªåèªèº«ã®äžã«ãã¹ãŠãå ãã³ã³ãããªã©ããã¢ã€ãã¢ãçãŸããŸããã åããŒã ã¯ç¬èªã®ãµãŒãã¹ãèŠãŠãå¿ èŠãšèããæ¹æ³ã«ããŸãããå¿ èŠãªç°ãªããœãããŠã§ã¢ã§é©åãªæ°ã®ã³ã³ãããäœæããäœããäžå çã«ååŸããŸããã Grafanaãšinfluxã¯ãããããåå¥ã«ã¬ã€ãºããŸã-æããªã®ã§ãäžå åãããŸããã ããããåœæGrafanaã«ã¯æ³šæåèµ·ã¯ãããŸããã§ããã 圌ã¯ä»ã¯ããŸãè¯ããããŸãããããã®åŸã¯ãŸã£ãããããŸããã§ããã
ç§ãã¡ã¯ãããã¹ã¿ãŒã§ããå¿ èŠãããã®ã§ãä»ã®æ¥œåšã欲ãããããŸããã§ããïŒ
ããããinfluxã«ã¯KapacitorãšåŒã°ããåªãããœãããŠã§ã¢ãããã€ããããŸãã ããã¯ãç¬èªã®ã³ã³ããã«å ¥ããããã«ç¬èªã®æ§æãèšè¿°ããå ·äœçã«å¿ èŠãªã¢ã©ãŒããããã«èšè¿°ããããããã¹ãŠã¯ã©ã¹ã¿ã«åŒãåºããŠãããã§æ©èœãããããªãã®ã§ãã
åããŒã ã¯ç¬èªã®ãœãããŠã§ã¢ãäœæããäžè¬çãªService Discoveryã«ç»é²ããå¿ èŠã«å¿ããŠç°å¢ãèªèº«ã§æžã蟌ã¿ãŸãããŸãããã®ã³ã³ãããŒå ã§å¿ èŠã«å¿ããŠã¢ã©ãŒããæžã蟌ã¿ãŸãã äœããå€æŽãããå Žåãã³ã³ããã®æ°ããããŒãžã§ã³ãåéããã¯ã©ã¹ã¿ãŒã«éä¿¡ãããšããã¹ãŠãæ©èœããŸãã
ç§ãã¡ã¯äœãããŸãããïŒ ã¯ãããã§ã«å¿ èŠãªã»ãŒãã¹ãŠã®ãã®ïŒã³ã³ããããããã¯ãŒã¯ãã¢ã€ãã³æ©ããµãŒãã¹æ€åºããã«ã¹ãã§ãã¯-ã³ã³ããå ã®ãã¹ãŠãã³ã³ããå ã®åã³ã³ããã
ã€ãŸããããŒã ãå¿ èŠãšããã®ã¯ãäºåã«å®çŸ©ãããå¥çŽïŒããŸã倧ãããªãïŒã«åŸã£ãŠã³ã³ãããåéããããšã§ãã ãµãŒãã¹ãå éšã°ãªããã«ç»é²ããããã«ã¯ãæ§æãæ£ããèšè¿°ããå¿ èŠããããæŠããŠãä»ã«äœãå¿ èŠãããŸããã äž»ãªããšã¯ããããæ©èœããããšã§ãã
ãã®åŸãåé¡ãçºçããŸã-æ°åå°ã®ãã·ã³ã§ããããã¹ãŠéå§ããæ¹æ³ã¯ïŒ
èŠãã®ã䟿å©ã ãããšãã£ãŠãSwarmã䜿ããŸããã ããã¯ãã³ãã³ããéä¿¡ã§ããAPIã®1ã€ã®ããŒã«ã§ãããäœããã®æ¹æ³ã§ãããã®ã³ã³ãããããã§å解ããŸãã Swarmã®ä»¥éã®ããŒãžã§ã³ã§ã¯ãã¯ã©ã¹ã¿ãŒå ã®ã³ã³ãããŒã®å¿ èŠãªã€ã³ã¹ã¿ã³ã¹æ°ã远跡ã§ããå Žåãåèµ·åæ¡ä»¶ãªã©ã®ããããåŒãç¶ã衚瀺ãããŠããŸããã
äžè¬ã«ãããã§ååã§ãã
ãããã£ãŠãSwarmã¯ãã§ã«ååšããŠãããšããçç±ã ãã§ååŸããŸããã ãã ããå¿ èŠãªå°ããªãµãã»ããçšã«ç¬èªã®ã³ãŒããäœæããå¿ èŠããããŸãããã€ãŸããDockerããŒã¢ã³ãåãã10-15-20ãã·ã³ã§ãããã®ãã·ã³ã«ã³ã³ãããè©°ã蟌ã¿ãé©åãªéã確ä¿ããå¿ èŠããããŸããäžãäžã-äžè¬ã«ããã以äžã¯å¿ èŠãããŸããã
èªç¥çãšåæ°
ç§ãã¡ã¯åœã®ç®¡çè ã§ããããã¹ãŠã®ç®¡çè ã®åèŠããããããåãå®çšŒåã¯ã©ã¹ã¿ãŒã§ã®éçšãã¹ããŒãžã³ã°ããã¹ããè¡ããCIå šäœã¯ããã«äžãã£ããã¹ãŠã®æ°ããããŒããšãšãã«ååšããŸããã
1ã€ã®ã¯ã©ã¹ã¿ãŒãç£èŠããæ¹ã2ã€ã®ã¯ã©ã¹ã¿ãŒãããç°¡åã§ããããããããã¯ãã¹ãŠ1ã€ã®ã¯ã©ã¹ã¿ãŒã«ååšããŸãã åºæ¬çãªéãã¯ãããŸããããµãŒãã¹ãç°ãªãæ¹æ³ã§åŒã³åºãã ãã§ããã¹ãŠæ£åžžã«æ©èœããŸãã ãããè¡ãã«ã¯ã念ã®ããã«å°ãã®éã®äºåãå¿ èŠã§ãã
ããªããèšãããšãã§ããŸã-ããªããèšãã®ãšåããããç°¡åã ã£ããªãïŒ ãããããã¹ãŠãæ¬åœã«ç°¡åã§ãããããã¯ã·ã³ãã«ãªã³ã³ããŒãã³ããã·ã³ãã«ãªããŒã«ã§ãããäœåãªãœãããŠã§ã¢ã¯ã»ãšãã©ãããŸããã
ãªãããã ããªã®ã§ããïŒ
ãªãç·ã¯äœçŸäººå¹ŽãåããŠãããããã¹ãŠããã®ã§ããïŒ
å®éãçãã¯éåžžã«ç°¡åã§ãã ãããã®äººãè€éãªã³ãŒããè€éãªæ§æãè€éãªæŠå¿µãªã©ãéããŠè§£æ±ºããåé¡ã®ã»ãšãã©ã¯ããã®å ŽåãããŒã å ã®åæã¬ãã«ã§è§£æ±ºãããŸãã
ãã¹ãŠã®ããŒã ã®å€§å€æ°ã«ãšã£ãŠãããã§ååã ãšå¿ããä¿¡ããŠããŸãã é«åºŠãªãœãããŠã§ã¢ãKubernetesã«é£ã³èŸŒãå¿ èŠã¯ãããŸããã ãã®ãœãããŠã§ã¢ã¯éåžžã«è€éã§ãçåãçããå Žå-äœã«æéãããããïŒKubernetesãæŽçããããé£æåã®æ©èœãããã£ããããããã«ã¯ãããã«éŽäžã§ãããã³ã°ãéå§ããŸãã ïŒ ãã¶ããæãªããã®æ¹æ³ã§ãgit pushã¯è»ã«å¯ŸããŠæ ãè ã«ãªãã§ãããããªã©ã
ããããç·ãDockerã¯ç¥ããªãããšãæ¥ããŠããŸãã Stopudovoã¯èª°ãã圌ãšåãæ¹æ³ãç¥ã£ãŠããŸãã ããã«å°ããªããŒãã«ãè¿œå ããŠãããã«ã¯ã©ã¹ã¿ãŒã«æŒã蟌ã¿ãŸãã
ã»ãšãã©ã®å ŽåãããŒã å ã§ã®éåžžã«åçŽãªæè¡ç解決çãšéåžžã«åçŽãªåæã§ååã§ãããšç§ã¯å¿ããä¿¡ããŠããŸãã ãããŠããã®çµã¿åããããããããè€éãªæŠå¿µã«å¯ŸåŠããããªãéçºè ã«åçŽãªãµãŒãã¹ãæäŸããã®ã§ããã°ããªãã ãããïŒ
OntikoïŒå人ãçŸæç¹ã§ã¯ãRootConf 2017ããã®ãã¹ãŠã®ã¬ããŒãã®ãããªé²ç»ãžã®ç¡æã¢ã¯ã»ã¹ãå ¬éãããŠããŸãã å€ãã®äŸ¿å©ã§èå³æ·±ããã®ãèŠã€ããŠããã ããã°å¹žãã§ãã
ãŸããç§ãã¡ã®ããã°ã©ã å§å¡äŒã¯ããã§ã«ã¹ããŒã«ãŒããã®ç³è«ãå®å šã«åãå ¥ãå§ããŠããŸãã å€ãã®çµéšãèå³æ·±ãäºäŸãããå Žåã¯ãRootConf 2018ã®è¬æŒè ã«ãªãããšãã§ããŸããã¢ããªã±ãŒã·ã§ã³ã¯ããã«æ®ãããšãã§ããŸã ã