Hyper.sh - Clusterless Docker Hosting
Hyper.sh ã®ç¹å¾´ã¨ã¡ãªãã
å人çã«ã¯ã¯ã©ã¹ã¿ä¸è¦ã§ Docker ã使ããã¨ããã ãã§ããªãã®ã¡ãªããã«ãªãã®ã§ããããã以å¤ã«ãããããã¨ç¹å¾´ã¨ã¡ãªããããã£ãã®ã§å°ãã ãæ¸ãã¦ããã¾ãã
Docker ã¨åãã³ãã³ãä½ç³»ã§å©ç¨ã§ãã
Hyper.sh ãæä¾ãã¦ãã CLI 㯠Docker ã¨ã»ã¼åãã³ãã³ãã使ããããã«ãªã£ã¦ãã¾ããå ·ä½çã«ã¯ docker ã hyper ã«ç½®ãæããã ãã§ä½¿ãå§ãããã¨ãåºæ¥ã¾ãã
# docker ã®å ´å docker pull shibayan/decode-demo:v5 docker run -d -p 80:80 -it shibayan/decode-demo:v5 # hyper ã®å ´å hyper pull shibayan/decode-demo:v5 hyper run -d -p 80:80 -it shibayan/decode-demo:v5
Floating IP ã Service ãªã© Hyper åºæã®æ©è½ã«é¢ãã¦ã¯ã³ãã³ããç¨æããã¦ãã¾ãããä¸è²«æ§ã®ããã³ãã³ããæä¾ããã¦ããã®ã§ä½¿ããããã§ãã
ã¡ãã㨠CLI 㯠Windows çããã¼ã¿ã§ããæä¾ããã¦ããã®ã§ããã¦ã³ãã¼ãããã ãã§ä½¿ãã¾ãã
åã³ã³ããããã¤ãã¼ãã¤ã¶ã§åé¢ããã¦ãã
Hyper-V Container ã®ããã«åã³ã³ããã§é«åº¦ã«åé¢ãããç°å¢ãæä¾ããã¦ãã¾ãããã¤ã¸ã¼ãã¤ãã¼ã®å½±é¿ãæãã¤ã¤å®å®ããç°å¢ãå¾ããã¨ãåºæ¥ããã§ãã
What is Hyper.sh | Hyper.sh User Guide
å ã ããã¤ãã¼ãã¤ã¶ä¸ã§ã³ã³ãããåããã¨ããã½ãªã¥ã¼ã·ã§ã³ãæä¾ãã¦ããã¿ããã§ããããå©ç¨ãã¦ãµã¼ãã¹ãç«ã¡ä¸ããããã§ãã
ç§åä½ã§ã®èª²éã§ã³ã¹ããæé©ååºæ¥ã
ã¯ã©ã¹ã¿ãå¿ è¦ãªãã®ã§ãå®è³ªåºå®è²»ã¿ãããªã¤ã³ã¹ã¿ã³ã¹ã®è²»ç¨ã¯æãã£ã¦ãã¾ããããã®ä»£ããã«ã³ã³ãããèµ·åãã¦ããç§åä½ã§èª²éãè¡ããã¾ãã
CPU ã³ã¢æ°ã¨ã¡ã¢ãªéã®çµã¿åãã㧠S1 ãã L3 ã¾ã§ç¨æããã¦ãã¾ãã
å¿ è¦ãªæã«ã³ã³ãããç«ã¡ä¸ãã¦ãè¦ããªããªã£ããåé¤ã¨ããå ·åã«ãæ°è»½ã«ä½¿ããã¨ãåºæ¥ã¾ãã
ã¡ãªã¿ã«ãããã¯ã¼ã¯ã® In / Out ã¯ç¡æã¨ãªã£ã¦ãã¾ãããããªãã¯ã¯ã©ã¦ãã§ã¯ Out ã®ã¿èª²é対象ã«ãªã£ãããã¾ãããHyper ã§ã¯ç¡æã§ä½¿ãæ¾é¡ã¨ããããã§ãã
æã£åãæ©ã試ã
ãµã¯ãã¨è©¦ãã¦ã¿ããã®ã§ããããããã使ãã Azure CLI 2.0 ã® Docker Image ã使ã£ã¦ã¿ã¾ããhyper ã®è¨å®ãçµãã£ã¦ããã°ãhyper run ãå©ãã°æ°ç§ã§ã³ã³ãããç«ã¡ä¸ããã¾ãã
hyper run -it azuresdk/azure-cli-python
ãã®ã¾ã¾ã¿ã¼ããã«ãèµ·åããã®ã§ãaz ã³ãã³ãã使ã£ã¦æä½ãè¡ãã¾ãã
ä¸ã®ã³ãã³ãã ã¨ã³ã³ãããçµäºããå¾ãæ®éª¸ãæ®ãç¶ãã¦ãã¾ãã®ã§ãã³ã³ããã®èµ·åæã« --rm ãªãã·ã§ã³ãæå®ãã¦ããæ¹ãè¯ãã§ããã
hyper run --rm -it azuresdk/azure-cli-python
ããã§ã³ã³ãããæããå¾ã«èªåã§åé¤ãè¡ããã¾ãã
ã³ã³ãããµã¤ãºãæå®ãã
ããã©ã«ãã§ã¯ S4 ã§ã³ã³ãããèµ·åãã¾ãããèµ·åæã« --size ãªãã·ã§ã³ãä»ããã¨ãµã¤ãºãæå®ãããã¨ãåºæ¥ã¾ãã以ä¸ã®ä¾ã§ã¯ S2 ã§èµ·åããããã«ãªãã¾ãã
hyper run --rm --size=s2 -it azuresdk/azure-cli-python
èµ·åå¾ã«ããã·ã¥ãã¼ãã§ç¢ºèªããã¨ãã¡ãã㨠S2 ã«ãªã£ã¦ãããã¨ãåããã¾ãã
ã¡ãªã¿ã« ASP.NET Core ã¢ããªã±ã¼ã·ã§ã³ã®å ´åã¯ã¡ã¢ãªã 256MB 以ä¸ãªãã¨è¾ããã§ããã
ã¤ã³ã¿ã¼ãããã«å ¬éãã
å¤é¨ããã³ã³ããã«ã¢ã¯ã»ã¹å¯è½ã«ããããã«ã¯ãã³ã³ããã« Floating IP ãå²ãå½ã¦ãå¿ è¦ãããã¾ããæ©ã話ããããªã㯠IP ã¢ãã¬ã¹ã§ã1 IP ããã $1 ã§å©ç¨ã§ãã¾ãã
# æ°ãã nginx ã³ã³ãããç«ã¡ä¸ãã hyper run -d -p 80:80 --restart=always -it nginx # FIP ã 1 ã¤ç¢ºä¿ãã¦ãä½æããã³ã³ããã«å²ãå½ã¦ã hyper fip allocate -y 1 hyper fip attach x.x.x.x CONTAINERID
ã³ã³ãããä½æãã¦ãFloating IP ãå²ãå½ã¦ãã¨ãããã ãã§ã¢ã¯ã»ã¹å¯è½ã«ãªãã¾ããé常ã«ç°¡åã§ãã
Floating IP ã®å²ãå½ã¦ãå¥ã³ã³ããã«å¤æ´ãã㨠Blue-Green Deployment ãç°¡åã«å®ç¾ã§ãããã§ãã
ã³ã³ããã«å²ãå½ã¦ã Floating IP ã Inbound / Outbound 両æ¹ã® IP ã¢ãã¬ã¹ã¨ãã¦ä½¿ãããããã«ãªã£ã¦ããã¿ããã§ããã©ã®ããã 1 IP ã§ã¹ã±ã¼ã«ããã®ãã¯ãããã¾ããããåºæ¬çã«ã¯åé¡ãªãã¨æãã¾ãã
Compose ã使ã
Hyper.sh ã§ã¯ Docker Compose ã¨åããããªæ©è½ãæä¾ããã¦ãã¾ããç°ãªã£ã¦ããé¨åã¨ãã¦ã¯ fip ã¨ããè¨å®ã追å ããã¦ãããããã§ããã以å¤ã¯å ¨ãå¤ãã£ã¦ããªãã§ãã
ä¾ãã° ASP.NET Core ã¢ããªã±ã¼ã·ã§ã³ã¨åæã« Redis ãç«ã¡ä¸ããå ´åã«ã¯ä»¥ä¸ã®ããã«æ¸ãã¾ãã
version: '2' services: web: image: shibayan/decode-demo:v5 fip: x.x.x.x links: - cache:redis depends_on: - cache ports: - "80:80" cache: image: redis:alpine ports: - "6379"
ã³ãã³ãä½ç³»ã Docker ã¨å ¨ãåããªã®ã§ compose up ãå®è¡ããã¨ã³ã³ãããèµ·åãã¾ããä»åã¯ãã㦠-p ã使ã£ã¦ååãæå®ãã¾ããããããã©ã«ãã§ã¯ãã£ã¬ã¯ããªåã«ãªãã®ã§ç¡ãã¦ãè¯ãã§ãã
hyper compose up -d -p aspnetcore_redis
ããã·ã¥ãã¼ãã§ç¢ºèªããã¨ãæå®ãã 2 ã¤ã®ã³ã³ãããå®è¡ããã¦ãããã¨ãåããã¾ãã
Floating IP ã ASP.NET Core ã¢ããªã±ã¼ã·ã§ã³å´ã«ã¡ããã¨å²ãå½ã¦ããã¦ãã¾ããã¹ã±ã¼ãªã³ã°ã hyper ããè¡ããã¨ãåºæ¥ãã®ã便å©ã§ãã
ä½æããã³ã³ãããè½ã¨ãã®ã compose down ãå®è¡ããã ãã§å®äºã§ãã
hyper compose down -p aspnetcore_redis
Docker Compose ã使ã£ã¦ããã°æ°ããè¦ãããã¨ã¯ã»ã¼ããã¾ããã
Service ã使ã
Hyper.sh ã«åºæã®æ©è½ã¨ã㦠Service ã¨ãããã®ãããã¾ããããã¾ã§ hyper run ã hyper compose ã§ã³ã³ãããç«ã¡ä¸ãã¦ãã¾ããããä¸è¬ç㪠Web ã¢ããªã±ã¼ã·ã§ã³ã®å ´å㯠Service ã使ãæ¹ã便å©ã§ãã
Web ã¢ããªã±ã¼ã·ã§ã³ã«ä»ã¯å¿ é ã¨ãããã HTTPS ã¸ã®å¯¾å¿ããLB å´ã§å¯¾å¿ãåºæ¥ãããã§ãããä½ããããã¼ãªã³ã°ã¢ãããã¼ããç°¡åã«è¡ããã¨ããç¹ãéè¦ã§ãã
ã¨ãããããå®éã«æ°ãã Service ãä½æãã¦ãå¤é¨ããã¢ã¯ã»ã¹å¯è½ã«ãã¦ã¿ã¾ãã
# ã¬ããªã«ã 2 ã¤æ㤠Service ãä½æ hyper service create --service-port=80 --label=web --name=aspnetcore --replicas=2 shibayan/decode-demo:v5 # Service ã«å¯¾ã㦠FIP ãå²ãå½ã¦ã hyper service attach-fip --fip x.x.x.x aspnetcore
ä½æãå®äºããã¨ããã·ã¥ãã¼ããã Service ã®ç¶æ ã確èªã§ãã¾ããã¬ããªã«ã 2 ã¤ã¨ Floating IP ãè¨å®æ¸ã¿ãªã®ã¨ãã¹ã±ã¼ãªã³ã°ãå®äºãã¦ãããã¨ãåããã¾ãã
ãã®ç¶æ 㧠Floating IP ã«ã¢ã¯ã»ã¹ããã¨ãã¡ããã¨æå®ããã¤ã¡ã¼ã¸ãç«ã¡ä¸ãã£ã¦ãã¾ãã
ä½æãã¦ããã³ã³ããã«ã¢ã¯ã»ã¹ãå¯è½ã«ãªãã¾ã§ãæ¬å½ã«æ°ç§ããããããªãã®ãåãã§ãã
Docker ãªã®ã§å½ç¶ãªãã ASP.NET Core ã¢ããªã±ã¼ã·ã§ã³ããããªãåä½ãã¾ãããã¼ã¿ããªãã£æ群ã
ã¹ã±ã¼ãªã³ã°ãå®è¡ãã
ã¬ããªã«æ°ã 2 ã¤ã§èµ·åãã¾ããããå¾ãã hyper service scale ãå®è¡ããã¨ã¬ããªã«æ°ãå¤æ´ãããã¨ãåºæ¥ã¾ããä¸ã®ä¾ã§ã¯ aspnetcore ã¨ãã Service ã®ã¬ããªã«ã 4 ã¤ã«å¢ããã¦ãã¾ãã
hyper service scale aspnetcore=4
ã¹ã±ã¼ãªã³ã°ãé常ã«é«éãªã®ã§ãæ°ç§ã§æå®ããã¬ããªã«æ°ã§èµ·åãã¾ãã
å½ç¶ãªããæ¸ããã®ãæ°ç§ã§å®äºãã¾ãããã¦ã³ã¿ã¤ã ã¯çºçãã¾ããã
ã¤ã¡ã¼ã¸ã®ã¢ãããã¼ããå®è¡ãã
Service ã使ã㨠CLI 㧠Docker Image ã®ãã¼ãªã³ã°ã¢ãããã¼ããç°¡åã«è¡ãã¾ããããã¥ã¡ã³ããèªã㨠1 ã³ã³ãããã¤ã¢ãããã¼ããè¡ãããä»æ§ã®ããã§ãã
hyper service rolling-update --image shibayan/decode-demo:v6 aspnetcore
ãã¼ãªã³ã°ã¢ãããã¼ããå®è¡ããã¨ãæ°ç§ã§ Docker Image ã®å ¥ãæ¿ããå®äºãã¾ããããã·ã¥ãã¼ãã®ã¡ãã»ã¼ã¸ã§ããã¼ãªã³ã°ã¢ãããã¼ããå®äºãããã¨ã確èªãããã¨ãåºæ¥ã¾ãã
é¢é£ä»ãã Floating IP ã«ã¢ã¯ã»ã¹ããã¨ãæ°ããã¤ã¡ã¼ã¸ã®ã¢ããªã±ã¼ã·ã§ã³ã表示ããã¾ãã
ã¢ããªã±ã¼ã·ã§ã³ã®éç¨ã«å¿ è¦ãªæ©è½ã¯ Service ã使ãã¨ã大ä½æºããããã¨ãåãã£ã¦ãã¾ãããã¢ãããã¼ããé常ã«æ©ãã®ã§ãªãªã¼ã¹ãå®å¿ãã¦è¡ãããã§ãã
Floating IP ã®ä»ãæ¿ããå¶å¾¡ãããã¨ã§ Blue-Green Deployment ãå¯è½ã ã¨æãã¾ãã
課éä¸ã®æ³¨æç¹
å®è¡ããã³ã³ããã«é¢ãã¦ã¯ç§åä½ã§ã®èª²éã«ãªãã¿ãããªã®ã§ãé常ã«å®ã Docker ã®ãã¹ãã£ã³ã°ãè¡ãã¾ãããFloating IP ã ãã¯ç¢ºä¿ããç¬éã« $1 ãããããã«ãªã£ã¦ã¾ãã
å®éã«é©å½ã« Floating IP ã®ç¢ºä¿ãè¡ã£ã¦ãããããã£ã¡ã㨠1 æåã課éããã¦ã¾ããã
Floating IP ã«é¢ãã¦ãæéåä½ãããã§ã®èª²éã«ãªã£ã¦ãããã¨å¬ããã®ã§ãããé£ããã®ããããã¾ãããã¨ã¯ããããã¼ã«ãã¦ããã°æ¸ã話ãªã®ã§ä¾¿å©ã« Hyper.sh ã使ã£ã¦ãããã¨æãã¾ãã
æããã¹ãã¯ãã¼ã¿ã»ã³ã¿ã¼ãããµã³ã¼ã«ã¹ã«ããåå¨ããªããã¨ã§ãããå©ç¨ãã¦ããã¨æããããã¼ã¿ã»ã³ã¿ã¼èªä½ã¯ä¸çä¸ã«åå¨ãã¦ããã¿ãããªã®ã§ãã¢ã¸ã¢ã¸ã®è¿½å ãæå¾ ãã¦ã¾ãã