Cloud Run ã®å¿çæéãæé©åãã 3 ã¤ã®æ¹æ³
Google Cloud Japan Team
â»ãã®æ稿ã¯ç±³å½æé 2020 å¹´ 11 æ 7 æ¥ã«ãGoogle Cloud blog ã«æ稿ããããã®ã®æ訳ã§ãã
ãµã¼ãã¼ã¬ã¹ã®ã³ã³ããåã¯ã大ããªè² æ ã¨ãªãã¤ã³ãã©ã¹ãã©ã¯ãã£ç®¡çãªãã§ã¹ãã¼ãã¬ã¹ ãã¤ã¯ããµã¼ãã¹ããããã¤ããæ¹æ³ããããããã¼ã«æä¾ããä¸çãå¸å·»ãã¾ãããCloud Run ã§ã¯ã¤ã³ãã©ã¹ãã©ã¯ãã£ç®¡çãä¸åä¸è¦ã§ããã¦ã§ããµã¼ãã¼ã¨ã¹ãã¼ãã¬ã¹ ãã¸ãã¯ãæã¤ã³ã³ãã ã¤ã¡ã¼ã¸ã渡ããã¡ã¢ãª / CPU ã¨è¨±å¯ãããåæå®è¡ã®çµã¿åãããæå®ããã ãã§ãã
Cloud Run ã¯ãHTTP ã¨ã³ããã¤ã³ãã®ä½æãã³ã³ããã¸ã®ãªã¯ã¨ã¹ãã®ã«ã¼ãã£ã³ã°ãå¦çãããªã¯ã¨ã¹ãéã«å¿ããã³ã³ããã®ã¹ã±ã¼ã«ã¢ããã¨ã¹ã±ã¼ã«ãã¦ã³ãè¡ãã¾ããã¾ããCloud Run ã¯ã¢ã¤ãã« ã¤ã³ã¹ã¿ã³ã¹ãªã©ãå¿çæéã®ã¬ã¤ãã³ã·ãç縮ããããã®ãã¤ãã£ãæ©è½ãããã¤ãæä¾ãã¦ãã¾ããã以ä¸ã§æ¦èª¬ããå¹æçãªãµã¼ãã¹ãè¨è¿°ãããã¨ã§ãã®å¤ããæ¹åã§ãã¾ãã
ã¢ã¤ãã« ã¤ã³ã¹ã¿ã³ã¹
ãã©ãã£ãã¯éã¯å¤åããããããã©ãã£ãã¯ã®æ¥å¢ã«ããã³ã¼ã«ã ã¹ã¿ã¼ããå¿ è¦ã«ãªãäºæ ãé¿ãããããã Cloud Run ã¯ããã¤ãã®ã¢ã¤ãã« ã¤ã³ã¹ã¿ã³ã¹ãç¶æãã¾ãããã¨ãã°ãã³ã³ãã ã¤ã³ã¹ã¿ã³ã¹ããªã¯ã¨ã¹ãã®å¦çãå®äºããã¨ãå¥ã®ãªã¯ã¨ã¹ããå¦çããå¿ è¦ãçºçããå ´åã«åãã¦ãä¸å®æéã¢ã¤ãã«ç¶æ ã®ã¾ã¾ã«ãªããã¨ãããã¾ãã
ãã ããå¦çãããªã¯ã¨ã¹ãããªããã°ãCloud Run ã¯ãã°ãããã¦ããæªä½¿ç¨ã®ã³ã³ãããçµäºãã¾ããããã¯ã¤ã¾ããã³ã¼ã«ã ã¹ã¿ã¼ããçºçããå¯è½æ§ãããã¨ãããã¨ã§ããã³ã³ãã ã¤ã³ã¹ã¿ã³ã¹ãå¿ è¦ã«å¿ãã¦ã¹ã±ã¼ãªã³ã°ãããå®è¡ç°å¢ã¯å®å ¨ã«åæåããããã¨ã«ãªãã¾ããmin-instance è¨å®ã使ç¨ãã¦ãã¢ã¤ãã« ã¤ã³ã¹ã¿ã³ã¹ãæ°¸ç¶çã«å©ç¨å¯è½ãªç¶æ ã«ä¿ã¤ãã¨ã¯ã§ãã¾ããããµã¼ãã¹ããªã¯ã¨ã¹ããå¦çãã¦ããªãå ´åã§ãè²»ç¨ãçºçãã¾ãã
ã³ã¼ã«ã ã¹ã¿ã¼ãã®å¯è½æ§ãããå ´åã«ãè²»ç¨ã¨å¿çæéã®ã¬ã¤ãã³ã·ã®ä¸¡æ¹ãæå°åããã¨ãã¾ããããã¢ã¤ãã« ã¤ã³ã¹ã¿ã³ã¹ã®æå°æ°ã¯è¨å®ããªãããã©ããã³ã³ããã®èµ·åä¸ããªã¯ã¨ã¹ãã®ãªãã¹ã³ãéå§ããåã«è¿½å ã®è¨ç®ãå¿ è¦ã«ãªã£ãå ´åã¯èªã¿è¾¼ã¿æéã¨ã¬ã¤ãã³ã·ãé·ããªããã¨ãç解ãã¦ãããã¨ã¨ãã¾ãã
Cloud Run ã³ã³ããã®èµ·å
ã³ã³ããã®èµ·åæéã«åããããµã¼ãã¹ã®æé©åã«å½¹ç«ã¤ãã¯ããã¯ãããã¤ãããã¾ããããã§ã®ç®æ¨ã¯ãã³ã³ãã ã¤ã³ã¹ã¿ã³ã¹ã®ãªã¯ã¨ã¹ãå¦çãé ãããã¬ã¤ãã³ã·ãæå°éã«æãããã¨ã§ãããã®ããã«ã¯ãã¾ã Cloud Run ã³ã³ããã®èµ·åã«ã¼ãã£ã³ã®è¦ç´ãããå§ãã¾ãã
大ã¾ãã«ãèµ·åã«ã¼ãã£ã³ã§ã¯æ¬¡ã®å¦çãè¡ããã¾ãã
1.ãµã¼ãã¹ãéå§ãã
âã³ã³ãããèµ·åãã
âentrypoint ã³ãã³ããå®è¡ãã¦ãµã¼ãã¼ãèµ·åãã
2.éãã¦ãããµã¼ãã¹ãã¼ãã確èªãã
ã¹ããã 1a ã«å¿ è¦ãªæéãæå°éã«æããã«ã¯ããµã¼ãã¹ã調æ´ãã¾ããCloud Run ã®å¿çæéã®ãµã¼ãã¹ãæé©åãã 3 ã¤ã®æ¹æ³ãé ã«è¦ã¦ããã¾ãããã
1. ãµã¼ãã¹ãã¹ãªã åãã
ã¾ããCloud Run ã§ã¯ãã³ã³ãã ã¤ã¡ã¼ã¸ã®ãµã¤ãºã¯ãã³ã¼ã«ã ã¹ã¿ã¼ãããªã¯ã¨ã¹ãã®å¦çæéã«ã¯å½±é¿ãã¾ããããã ããã³ã³ãã ã¤ã¡ã¼ã¸ã®ãµã¤ãºã大ããã¨ããã«ãã«ããããã¤ã«ãæéããããã¾ãã
åçè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ã«é¢ãã¦ã¯ãç¹ã«æ³¨æãå¿ è¦ã§ãããã¨ãã°ãNode.js ã Python ã使ç¨ãã¦ããå ´åãããã»ã¹ã®èµ·åæã«ã¢ã¸ã¥ã¼ã«ã®èªã¿è¾¼ã¿ãçºçãããããã³ã¼ã«ã ã¹ã¿ã¼ãæã«ã¬ã¤ãã³ã·ãå¢å ãããã¨ã«ãªãã¾ãã
ã¾ããã¤ã³ãã¼ãæã«åæåã³ã¼ããå®è¡ããä¸é¨ã®ã¢ã¸ã¥ã¼ã«ã«ã注æãå¿ è¦ã§ãã
以ä¸ãå®è¡ãããã¨ã§ããµã¼ãã¹ãã¹ãªã åã§ãã¾ãã
åçè¨èªã使ç¨ãã¦ããå ´åã¯ãä¾åé¢ä¿ã®æ°ã¨ãµã¤ãºãæå°éã«æããã
èµ·åæã«è¨ç®ããã®ã§ã¯ãªããè¨ç®ã延æããããã°ãã¼ãã«å¤æ°ã®åæåã¯èµ·åæã«è¡ããããããã³ã¼ã«ã ã¹ã¿ã¼ãã®æéãé·å¼ãããè¦å ã¨ãªãã¾ãã使ç¨é »åº¦ã®ä½ããªãã¸ã§ã¯ãã®åæåã延æããã°ãããã«ãããæéãå éããããã¨ã§ã³ã¼ã«ã ã¹ã¿ã¼ãã®æéãç縮ã§ãã¾ãã
åæåãç縮ãã¦ãHTTP ãµã¼ãã¼ã®èµ·åæéãæ©ããã
PHP ã® Composer ãªã¼ããã¼ãã¼ã®æé©åãªã©ãã³ã¼ã ãã¼ãã£ã³ã°ã®æé©åã使ç¨ããã
2. å°ããªãã¼ã¹ã¤ã¡ã¼ã¸ã使ç¨ãã
alpineãdistroless ãªã©ã®ãªã¼ã³ãªãã¼ã¹ã¤ã¡ã¼ã¸ã使ç¨ãã¦ãã³ã³ããã®ãµã¤ãºãæå°ã«æãã¾ãããã¨ãã°ãalpine:3.7 ã¤ã¡ã¼ã¸ã¯ãcentos:7 ã¤ã¡ã¼ã¸ããã 71 MB å°ãããªãã¾ãã
空ã®ã¤ã¡ã¼ã¸ã§ãã scratch ã使ç¨ãã¦ç¬èªã®ã©ã³ã¿ã¤ã ç°å¢ãæ§ç¯ãããã¨ãã§ãã¾ããã¢ããªãéçã«ãªã³ã¯ããããã¤ããªã«ãªã£ã¦ããå ´åãscratch ãã¼ã¹ã¤ã¡ã¼ã¸ã使ç¨ããã®ã¯ç°¡åã§ãã
ã¾ããã¤ã¡ã¼ã¸å ã§æ¬å½ã«å¿ è¦ã¨ããããã®ã®ã¿ãã¤ã³ã¹ãã¼ã«ããããã«ãã¾ããå¿ è¦ã®ãªã追å ããã±ã¼ã¸ã¯ã¤ã³ã¹ãã¼ã«ããªãããã«ãã¾ãããã
3. ã°ãã¼ãã«å¤æ°ã使ç¨ãã
Cloud Run ã§ã¯ããªã¯ã¨ã¹ãéã§ãµã¼ãã¹ã®ç¶æ ãç¶æãããã¨ã¯éãã¾ããããã ããCloud Run ã¯ã³ã³ãã ã¤ã³ã¹ã¿ã³ã¹ãåå©ç¨ãã¦ãã©ãã£ãã¯ã®å¦çãç¶ç¶ãã¾ãã
ããã¯ãã°ãã¼ãã«å¤æ°ã宣è¨ã§ããæ°ããèµ·åããã³ã³ããã§ãã®å¤æ°ã®å¤ãåå©ç¨ã§ããã¨ãããã¨ãæå³ãã¾ããã¾ãããªãã¸ã§ã¯ããã¡ã¢ãª ãã£ãã·ã¥ã«ä¿åãããã¨ãã§ãã¾ããããããªã¯ã¨ã¹ãã®ãã¸ãã¯ã§ã¯ãªããã°ãã¼ãã« ã¹ã³ã¼ãã§è¡ãã¨ããã©ãã£ãã¯ãç¶ç¶ä¸ã®å ´åã®ããã©ã¼ãã³ã¹ãåä¸ãã¾ããããã¯ã³ã¼ã«ã ã¹ã¿ã¼ãæéã®ç縮ã«ã¯ãªãã¾ããããã³ã³ããã®åæåãçºçããéã«ã¯ããªãã¸ã§ã¯ãããã£ãã·ã¥ã«ä¿åããã¦ããããããã®å¾ã®ç¶ç¶ãããªã¯ã¨ã¹ãã®ã¬ã¤ãã³ã·ãç縮ã§ãã¾ãã
ãã¨ãã°ããªã¯ã¨ã¹ããã¨ã®ãã¸ãã¯ãã°ãã¼ãã« ã¹ã³ã¼ãã§è¡ãå ´åãã³ã¼ã«ã ã¹ã¿ã¼ãã«ãããæéã¯ã»ã¼åãã«ãªãã¾ããï¼ã¦ã©ã¼ã ãªã¯ã¨ã¹ãã«ã¯ãªããã£ãã·ã¥ä¿åã®ãã¸ãã¯ã追å ããã¨ã³ã¼ã«ã ã¹ã¿ã¼ãæéã¯é·ããªãã¾ãï¼ããã®ã¦ã©ã¼ã ã¤ã³ã¹ã¿ã³ã¹ãå¦çããå¾ç¶ã®ãªã¯ã¨ã¹ãã®ã¬ã¤ãã³ã·ã¯ä½ããªãã¾ãã
ã³ã¼ã«ã ã¹ã¿ã¼ãã«å½¹ç«ã¤æ¹æ³ã®ä¸ã¤ã¨ãã¦ãã°ãã¼ãã«ç¶æ ã Memorystore ãªã©ã®ã¡ã¢ãªå ãã¼ã¿ã¹ãã¢ã«ãªããã¼ããããã¨ãæãããã¾ããããã«ãããã¢ããªã±ã¼ã·ã§ã³ ãã£ãã·ã¥ã¸ã®ããªç§æªæºã®ãã¼ã¿ã¢ã¯ã»ã¹ãå®ç¾ã§ãã¾ãã
ã¾ã¨ã
èè¦ãªã®ã¯ãã³ã³ããã®åæåä¸ã«è¨ç®ãããã¸ãã¯ãæå°éã«æããã§ããã ãæ©ããªã¯ã¨ã¹ãã®å¦çãéå§ã§ããããã«ãããã¹ãªã ãªãµã¼ãã¹ãä½æãããã¨ã§ãããã®ããã°ã§ã¯ Cloud Run ãµã¼ãã¹ãè¨è¨ããããã®ãã¹ã ãã©ã¯ãã£ã¹ãããã¤ããç´¹ä»ãã¾ããããå¹æçãªãµã¼ãã¹ã®è¨è¿°ãããã©ã¼ãã³ã¹ã®æé©åã«é¢ãããã®ä»ã®ãã³ãã«ã¤ãã¦ã¯ãã¡ãã§ç¢ºèªã§ãã¾ãã
Cloud ã³ã³ãã³ãã®è©³ç´°ã«ã¤ãã¦ã¯ãTwitter ã§@swongful ããã©ãã¼ãã¦ãã ããã
-ãããããã¼ ã¢ããã±ã¤ã Stephanie Wong