nginx ã Kubernetes ã¯ã©ã¹ã¿ãŒã«ãããã€ããããšããŸããããç§ã¯ããããã¿ãŒããã«ã§ã€ãã®ãããªã³ãã³ããã¿ã€ãããã§ãããã
kubectl create deployment --image=nginx --replicas=3
ãããŠãšã³ã¿ãŒããŒãæŒããŸããæ°ç§åŸã3ã€ã® nginx ãããããã¹ãŠã®ã¯ãŒã«ãŒããŒãã«å±éãããŠããã®ããããã§ããããéæ³ã®ããã«åäœããçŽ æŽãããã§ãïŒããããå®éã®ãšããäœãèµ·ãã£ãŠããã®ã§ããããã
Kubernetes ã®çŽ æŽããããšããã®1ã€ã¯ãã€ã³ãã©ã¹ãã©ã¯ãã£å šäœãžã®ã¯ãŒã¯ããŒãã®å±éãããŠãŒã¶ãŒãã¬ã³ããªãŒãª API ãä»ããŠåŠçããããšã§ããè€éãã¯ã·ã³ãã«ãªæœè±¡åã«ãã£ãŠé ãããŠããŸãããããããããæäŸãã䟡å€ãååã«ç解ããããã«ã¯ããã®å éšãç解ããããšãæçšã§ãããã®ã¬ã€ãã§ã¯ã¯ã©ã€ã¢ã³ããã kubelet ãžã®ãªã¯ãšã¹ãã®ã©ã€ããµã€ã¯ã«å šäœãéããŠããªããç解ãžãšå°ããŸãããããŠäœãèµ·ãã£ãŠããã®ãã説æããã®ã«å¿ èŠãªãšããã§ãœãŒã¹ã³ãŒããåç §ããŸãã
ããææžã¯éæäœæäžã§ããæ¹åãæžãæããå¯èœãªéšåãèŠã€ãããããã²ã³ã³ããªãã¥ãŒã·ã§ã³ããŠãã ããïŒ
ããå§ããŸããããã¿ãŒããã«ã§ãšã³ã¿ãŒããŒãæŒããŸãããäœãèµ·ãããŸããïŒ
kubectl ãæåã«è¡ãã®ã¯ã¯ã©ã€ã¢ã³ããµã€ãã®ããªããŒã·ã§ã³ã§ããããã«ãããå¿ ã倱æãããªã¯ãšã¹ãïŒãµããŒããããŠããªããªãœãŒã¹ã®äœæãäžæ£ãªåœ¢åŒã®ã€ã¡ãŒãžåã䜿çšããããšãªã©ïŒã¯æ©ã倱æããkube-apiserver ã«éä¿¡ãããŸãããããã«ãããäžèŠãªè² è·ãæžå°ãããã·ã¹ãã ããã©ãŒãã³ã¹ãåäžããŸãã
ããªããŒã·ã§ã³åŸãkubectl 㯠kube-apiserver ã«éä¿¡ãã HTTP ãªã¯ãšã¹ãã®çµã¿ç«ãŠãéå§ããŸããKubernetes ã·ã¹ãã å ã®ç¶æ ã«ã¢ã¯ã»ã¹ãããç¶æ ãå€æŽããããšããè©Šã¿ã¯ãã¹ãŠ API ãµãŒããŒãä»ããŠè¡ãããAPI ãµãŒããŒã¯ etcd ãšéä¿¡ããŸããkubectl ã¯ã©ã€ã¢ã³ããåãã§ããHTTP ãªã¯ãšã¹ããæ§ç¯ããããã«ãkubectl ã¯ãžã§ãã¬ãŒã¿ãŒãšåŒã°ãããã®ã䜿çšããŸããããã¯ã·ãªã¢ã«åãåŠçããæœè±¡ã§ãã
kubectl run
ã®å¯Ÿè±¡ã«ã¯ Deployment ãªãœãŒã¹ã ãã§ãªãè€æ°ã®ãªãœãŒã¹ã¿ã€ããæå®ã§ããã®ã¯ããããããªããããããŸããããããæ©èœãããããã«ããžã§ãã¬ãŒã¿ãŒåã --generator
ãã©ã°ã䜿ã£ãŠæ瀺çã«æå®ãããŠããªããã°ãkubectl ã¯ãªãœãŒã¹ã¿ã€ããæšæž¬ããŸãã
ããšãã°ã --restart-policy = Always
ããªãœãŒã¹ã¯ Deployment ãªãœãŒã¹ãšã¿ãªããã --restart-policy = Never
ãæã€ãªãœãŒã¹ã¯ Pod ãªãœãŒã¹ãšã¿ãªãããŸããkubectl ã¯ã³ãã³ããèšé²ããïŒããŒã«ã¢ãŠããç£æ»çšïŒãªã©ä»ã®ã¢ã¯ã·ã§ã³ãèµ·åããå¿
èŠããããã©ããããã®ã³ãã³ããåãªããã©ã€ã©ã³ã§ãããã©ããïŒ --dry-run
ãã©ã°ãæå®ãããïŒãå€æããŸãã
Deployment ãªãœãŒã¹ãäœæãããããšãèªèãããåŸãæäŸããããã©ã¡ãŒã¿ããã©ã³ã¿ã€ã ãªããžã§ã¯ããçæããããã« DeploymentAppsV1
ãžã§ãã¬ãŒã¿ãŒã䜿ããŸãããã©ã³ã¿ã€ã ãªããžã§ã¯ããã¯ãªãœãŒã¹ã®ç·ç§°ã§ãã
å
ã«é²ãåã«ææãã䟡å€ãããã®ã¯ãKubernetes ã¯ãAPIã°ã«ãŒããã«åé¡ããã versioned API ã䜿çšããŠãããšããããšã§ããAPIã°ã«ãŒãã¯ã䌌ããªãœãŒã¹ãåé¡ããŠãç°¡åã«æšæž¬ã§ããããã«ããããšãç®çãšããŠããŸããããã¯ãŸããåäžã®ã¢ããªã·ãã¯APIã«å¯Ÿããããè¯ã代æ¿æ段ãæäŸããŸããDeployment ãªãœãŒã¹ã®APIã°ã«ãŒã㯠apps
ãšããååã§ããã®ææ°ããŒãžã§ã³ã¯ v1
ã§ããDeployment ãªãœãŒã¹ã®ãããã§ã¹ãã®äžéšã« apiVersion: apps/v1
ãšæžãå¿
èŠãããã®ã¯ãã®ããã§ãã
ãšã«ãã... kubectl ã¯ã©ã³ã¿ã€ã ãªããžã§ã¯ããçæããåŸãé©åãªAPIã°ã«ãŒããšããã«å¯ŸããããŒãžã§ã³ãèŠã€ãå§ãããªãœãŒã¹ã«å¯Ÿããæ§ã
ãªRESTã»ãã³ãã£ã¯ã¹ãç¥ã£ãŠããããŒãžã§ã³ç®¡çãããã¯ã©ã€ã¢ã³ããçµã¿ç«ãŠãŸãããã®æ¢çŽ¢ã¹ããŒãžã¯ããŒãžã§ã³ããŽã·ãšãŒã·ã§ã³ãšåŒã°ãããã¹ãŠã®å©çšå¯èœãªAPIã°ã«ãŒããååŸããããã«ãªã¢ãŒãAPIäžã® /apis
ãã¹ã kubectl ãã¹ãã£ã³ããããšãå«ã¿ãŸããkube-apiserver ã¯ãã®ãã¹ã§ã¹ããŒãææžïŒ OpenAPI ãã©ãŒãããïŒãå
¬éããŠããã®ã§ãã¯ã©ã€ã¢ã³ãããã£ã¹ã«ããªãŒãå®è¡ããã®ã¯ç°¡åã§ãã
ããã©ãŒãã³ã¹ãåäžããããããkubectl 㯠OpenAPI ã¹ããŒãã ã/.kube/cache/discovery
ãã£ã¬ã¯ããªã«ããã£ãã·ã¥ããŸãããã® API ã®ãã£ã¹ã«ããªãŒãå®éã«èŠããå Žåããã®ãã£ã¬ã¯ããªãåé€ãã -v
ãã©ã°ãæ倧ã«ããŠã³ãã³ããå®è¡ããŠã¿ãŠãã ããããããã® API ããŒãžã§ã³ãèŠã€ããããšããŠãããã¹ãŠã® HTTP ãªã¯ãšã¹ãã衚瀺ãããŸãããããããããŸãïŒ
æåŸã®ã¹ãããã¯ãå®éã« HTTP ãªã¯ãšã¹ããéä¿¡ããããšã§ãããªã¯ãšã¹ããè¡ããæåã¬ã¹ãã³ã¹ãè¿ã£ãŠããããkubectl ã¯åžæãããåºåãã©ãŒãããã«åºã¥ããŠæåã¡ãã»ãŒãžã衚瀺ããŸãã
åã®ã¹ãããã§èšåããªãã£ãããšã®1ã€ã¯ã¯ã©ã€ã¢ã³ãèªèšŒã§ãïŒãã㯠HTTP ãªã¯ãšã¹ããéä¿¡ãããåã«åŠçãããŸãïŒã®ã§ããããèŠãŠã¿ãŸãããã
ãªã¯ãšã¹ããæ£åžžã«éä¿¡ããããã«ãkubectl ã¯èªèšŒã§ããå¿
èŠããããŸãããŠãŒã¶èªèšŒæ
å ±ã¯ã»ãšãã©ã®å Žåãã£ã¹ã¯äžã® kubeconfig
ãã¡ã€ã«ã«ä¿åãããŠããŸããããã®ãã¡ã€ã«ã¯å¥ã®å Žæã«ä¿åããããšãã§ããŸãããããèŠã€ããããã«ãkubectl ã¯ä»¥äžãè¡ããŸãã
--kubeconfig
ãã©ã°ãæå®ãããŠããå Žåã¯ããã䜿ããŸãã$KUBECONFIG
ç°å¢å€æ°ãå®çŸ©ãããŠããå Žåã¯ããã䜿ããŸãã- ãã®ä»ã¯
~/.kube
ã®ãããªæšå¥šãããããŒã ãã£ã¬ã¯ããªãæ¢ããèŠã€ãã£ãæåã®ãã¡ã€ã«ã䜿ããŸãã
ãã¡ã€ã«ã解æããåŸã䜿çšããçŸåšã®ã³ã³ããã¹ããæãçŸåšã®ã¯ã©ã¹ã¿ãçŸåšã®ãŠãŒã¶ãŒã«çŽä»ããããŠããèªèšŒæ
å ±ã決å®ããŸãããŠãŒã¶ãŒããã©ã°åºæã®å€ïŒ --username
ãªã©ïŒãæå®ããå Žåãããããåªå
ãããkubeconfig ã§æå®ãããå€ãäžæžãããŸãããã®æ
å ±ãåŸããããškubectl ã¯ã¯ã©ã€ã¢ã³ãã®èšå®ãè¿œå ããHTTP ãªã¯ãšã¹ããé©åã«è£
食ã§ããããã«ãªããŸãã
- x509蚌ææžã¯
tls.TLSConfig
ã䜿ã£ãŠéä¿¡ãããŸããããã«ã¯ã«ãŒã CA ãå«ãŸããŸãïŒ - ãã¢ã©ããŒã¯ã³ã¯ãAuthorizationãHTTP ããããŒã§éä¿¡ãããŸã
- ãŠãŒã¶ãŒåãšãã¹ã¯ãŒã㯠HTTP ããŒã·ãã¯èªèšŒãä»ããŠéä¿¡ãããŸã
- OpenID èªèšŒããã»ã¹ã¯äºåã«ãŠãŒã¶ãŒã«ãã£ãŠæåã§åŠçããããã¢ã©ããŒã¯ã³ã®ããã«éä¿¡ãããããŒã¯ã³ãçæããŸã
ãªã¯ãšã¹ãã¯éä¿¡ãããŸãããäžæ³ïŒæ¬¡ã¯äœã§ããããïŒãã㧠kube-apiserver ãç»å ŽããŸãããã§ã«è¿°ã¹ãããã«ãkube-apiserver ã¯ãã¯ã©ã€ã¢ã³ããšã·ã¹ãã ã³ã³ããŒãã³ããã¯ã©ã¹ã¿ã®ç¶æ ãæ°žç¶åããŠååŸããããã«äœ¿çšããäž»èŠãªã€ã³ã¿ãã§ãŒã¹ã§ãããã®æ©èœãå®è¡ããã«ã¯èŠæ±è ã®æ¬äººæ å ±ã確èªã§ããå¿ èŠããããŸãããã®ããã»ã¹ã¯èªèšŒãšåŒã°ããŸãã
apiserver ã¯ã©ã®ããã«ãªã¯ãšã¹ããèªèšŒããã®ã§ããããïŒãµãŒããŒãæåã«èµ·åãããšãããŠãŒã¶ãŒãæäŸãããã¹ãŠã® CLI ãã©ã°ã調ã¹ãé©åãªãªãŒã»ã³ãã£ã±ãŒã¿ãŒã®ãªã¹ããçµã¿ç«ãŠãŸããäŸãèŠãŠã¿ãŸãããã --client-ca-file
ãæž¡ãããå Žåãããã¯x509ãªãŒã»ã³ãã£ã±ãŒã¿ãŒãè¿œå ããŸãã --token-auth-file
ãæž¡ãããå ŽåãããŒã¯ã³ãªãŒã»ã³ãã£ã±ãŒã¿ãŒããªã¹ãã«è¿œå ããŸãããªã¯ãšã¹ããåãåããã³ã«ãæåãããŸã§ãªãŒã»ã³ãã£ã±ãŒã¿ãŒãã§ãŒã³ãééããŸãã
- x509ãã³ãã©ãŒã¯ãHTTP ãªã¯ãšã¹ãã CA ã«ãŒã蚌ææžã«ãã£ãŠçœ²åããã TLS ããŒã§ãšã³ã³ãŒããããŠããããšã確èªããŸã
- ãã¢ã©ãŒããŒã¯ã³ãã³ãã©ãŒ)ã¯ãïŒHTTP Authorization ãããã§æå®ãããïŒããŒã¯ã³ã
--token-auth-file
ã§æå®ããããã£ã¹ã¯äžã®ãã¡ã€ã«ã«ååšããããšã確èªããŸã - basicauth ãã³ãã©ãŒã¯ãHTTP ãªã¯ãšã¹ãã®åºæ¬èªèšŒè³æ Œæ å ±ãèªèº«ã®ããŒã«ã«ç¶æ ãšäžèŽããããšãåæ§ã«ä¿èšŒããŸã
ãã¹ãŠã®ãªãŒã»ã³ãã£ã±ãŒã¿ãŒã倱æãããšããªã¯ãšã¹ãã¯å€±æããéçŽãšã©ãŒãè¿ãããŸããèªèšŒãæåãããšã Authorization
ãããããªã¯ãšã¹ãããåé€ããããŠãŒã¶æ
å ±ããã®ã³ã³ããã¹ãã«è¿œå ãããŸããããã«ãããåŸç¶ã®ã¹ãããïŒèªå¯ãèªå¯ã³ã³ãããŒã©ãŒãªã©ïŒã§ä»¥åã«ç¢ºç«ããããŠãŒã¶ãŒã® ID ã«ã¢ã¯ã»ã¹ã§ããããã«ãªããŸãã
ããŠããªã¯ãšã¹ãã¯éä¿¡ãããŸããããã㊠kube-apiserver ã«èªèšŒãããŸãããäžå®å¿ã§ããããããŸã çµãã£ãŠããŸãããç§ãã¡ã¯èªèšŒãããŸããããããã¢ã¯ã·ã§ã³ãå®è¡ããããã®æš©éã¯ããã®ã§ããããïŒçµå±ãã¢ã€ãã³ãã£ãã£ãšèš±å¯ã¯åããã®ã§ã¯ãããŸãããåŠçãç¶ããããã«ã¯ãkube-apiserver ã«èªå¯ãããå¿ èŠããããŸãã
kube-apiserver ãèªå¯ãåŠçããæ¹æ³ã¯èªèšŒãšéåžžã«äŒŒãŠããŸãããã©ã°å
¥åã«åºã¥ãããã¹ãŠã®ãªã¯ãšã¹ãã«å¯ŸããŠå®è¡ãããäžé£ã®ãªãŒãœã©ã€ã¶ãŒãéããŸãããã¹ãŠã®ãªãŒãœã©ã€ã¶ãŒããªã¯ãšã¹ããæåŠããå Žåããªã¯ãšã¹ã㯠Forbidden
ã¬ã¹ãã³ã¹ãšãªãããã以äžå
ã«é²ãããšã¯ãããŸãããåäžã®ãªãŒãœã©ã€ã¶ãŒãèªå¯ãããšãªã¯ãšã¹ããç¶è¡ãããŸãã
v1.8ã«å«ãŸããŠãããªãŒãœã©ã€ã¶ãŒã®äŸã¯æ¬¡ã®ãšããã§ãã
- webhook ã¯ã¯ã©ã¹ã¿å€ã® HTTPïŒSïŒ ãµãŒãã¹ãšããåãããŸã
- ABAC ã¯éçãã¡ã€ã«ã§å®çŸ©ãããããªã·ãŒã匷å¶ããŸã
- RBAC ã¯ç®¡çè ã«ãã£ãŠ k8s ãªãœãŒã¹ãšããŠè¿œå ããã RBAC ããŒã«ã匷å¶ããŸã
- NODE ããŒãã¯ã©ã€ã¢ã³ããã€ãŸã kubelet ã¯èªåèªèº«ããã¹ãããŠãããªãœãŒã¹ã«ã®ã¿ã¢ã¯ã»ã¹ã§ããããã«ãªããŸã
å Authorize
ã¡ãœããããã§ãã¯ããŠããããã©ã®ããã«æ©èœããã®ãã確ãããŠãã ããïŒ
ããŠãããã§ãã®æç¹ã§èªèšŒããã kube-apiserver ã«ãã£ãŠèªå¯ãããŸãããããã§ã¯äœãæ®ã£ãŠããã§ããããïŒkube-apiserver ããèŠãã°ãç§ãã¡ãäœè ã§ããããšããããšãä¿¡é Œããç¶ç¶ããããšãèš±å¯ããŸãããKubernetesãšããŠã¯ãã·ã¹ãã ã®ä»ã®éšåã¯äœãèµ·ããã¹ããããããŠèš±ãããã¹ãã§ãªããã«ã€ããŠåŒ·ãæèŠãæã¡ãŸããããã§ã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒãç»å ŽããŸãã
èªå¯ã¯ãŠãŒã¶ãŒãèš±å¯ãåŸãŠãããã©ãããçããããšã«çŠç¹ãåœãŠãŠããŸãããã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒã¯ãªã¯ãšã¹ããã¯ã©ã¹ã¿ã®ããåºãæåŸ ãšã«ãŒã«ã«äžèŽããããšãä¿èšŒããããã«ãªã¯ãšã¹ããã€ã³ã¿ãŒã»ããããŸãããããã¯ããªããžã§ã¯ãã etcd ã«æ°žç¶åãããåã®å¶åŸ¡ã®æåŸã®ç Šã§ããã¢ã¯ã·ã§ã³ãäºæããªãçµæãæªåœ±é¿ãäžããªãããã«ãæ®ãã®ã·ã¹ãã ãã§ãã¯ãã«ãã»ã«åããŸãã
ã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒã®åäœæ¹æ³ã¯ãªãŒã»ã³ãã£ã±ãŒã¿ãŒãšãªãŒãœã©ã€ã¶ãŒã®åäœæ¹æ³ãšäŒŒãŠããŸããã1ã€éãããããŸãããªãŒã»ã³ãã£ã±ãŒã¿ãŒããã³ãªãŒãœã©ã€ã¶ãŒãã§ãŒã³ãšã¯ç°ãªããåäžã®ã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒã倱æãããšããã§ãŒã³å šäœãå£ãããªã¯ãšã¹ãã¯å€±æããŸãã
ã¢ãããã·ã§ã³ã³ã³ãããŒã©ã®èšèšã«é¢ããŠæ¬åœã«ã¯ãŒã«ãªã®ã¯ãæ¡åŒµæ§ã®ä¿é²ã«çŠç¹ãåœãŠãŠããããšã§ããåã³ã³ãããŒã©ãŒã¯ãã©ã°ã€ã³ãšã㊠plugin/pkg/admission/directory
ã«ä¿åãããå°ããªã€ã³ã¿ãŒãã§ãŒã¹ãæºããããã«äœãããŠããŸããããããã kubernetes ã® main ãã€ããªã«ã³ã³ãã€ã«ãããŸãã
ã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒã¯éåžžããªãœãŒã¹ç®¡çãã»ãã¥ãªãã£ãããã©ã«ãèšå®ãåç §æŽåæ§ã«åé¡ãããŸãããªãœãŒã¹ç®¡çãè¡ãã¢ãããã·ã§ã³ã³ã³ãããŒã©ãŒã®äŸãããã€ã瀺ããŸãã
InitialResources
ã¯éå»ã®äœ¿çšç¶æ³ã«åºã¥ããŠã³ã³ããã®ãªãœãŒã¹ã«ããã©ã«ãã®ãªãœãŒã¹å¶éãèšå®ããŸãLimitRanger
ã¯ã³ã³ããã®ãªã¯ãšã¹ããšå¶éã®ããã©ã«ããèšå®ããããç¹å®ã®ãªãœãŒã¹ã«äžéã匷å¶ããŸãïŒã¡ã¢ãªã¯2GB以äžã§ããã©ã«ãã¯512MBïŒResourceQuota
ã¯åå空éå ã®ããã€ãã®ãªããžã§ã¯ãïŒpodãrcãservice ããŒããã©ã³ãµãŒïŒãç·æ¶è²»ãªãœãŒã¹ïŒcpuãã¡ã¢ãªããã£ã¹ã¯ïŒãèšç®ããŠæåŠããŸãã
ãããŸã§ã§ãKubernetes ã¯ãªã¯ãšã¹ããå®å šã«åå³ããå ã«é²ãããšãèš±å¯ããŸããã次ã®ã¹ãããã§ãkube-apiserver 㯠HTTP ãªã¯ãšã¹ãããã·ãªã¢ã©ã€ãºãããããããã©ã³ã¿ã€ã ãªããžã§ã¯ããæ§ç¯ãïŒkubectl ã®ãžã§ãã¬ãŒã¿ãŒã®éããã»ã¹ã®ãããªãã®ã§ãïŒãããããããŒã¿ã¹ãã¢ã«æ°žç¶åããŸããå°ãå解ããŠã¿ãŸãããã
kube-apiserver ã¯ãªã¯ãšã¹ããåãããšããã©ã®ããã«ããŠäœããã¹ãããç¥ãã®ã§ããããïŒãªã¯ãšã¹ããåŠçãããåã«ã¯ããªãè€éãªäžé£ã®ã¹ãããããããŸãããã€ããªãæåã«å®è¡ãããšãããå§ããŸãããã
kube-apiserver
ãã€ããªãå®è¡ããããšããµãŒããŒãã§ãŒã³ãäœæããŸããããã«ãããapiserver éçŽãå¯èœã«ãªããŸããããã¯åºæ¬çã«è€æ°ã® apiserver ããµããŒãããæ¹æ³ã§ãïŒããã«ã€ããŠå¿é ããå¿ èŠã¯ãããŸããïŒã- ãããèµ·ãããšãããã©ã«ãã®å®è£ ãšããŠæ©èœããæ±çšç㪠apiserver ãäœæãããŸãã
- çæããã OpenAPI ã¹ããŒãã apiserver ã®èšå®ãåã蟌ã¿ãŸãã
- kube-apiserver ã¯ãã¹ããŒãã§æå®ãããŠãããã¹ãŠã® API ã°ã«ãŒããå埩åŠçããããããã«å¯ŸããŠæ±çšçãªæœè±¡ã¹ãã¬ãŒãžãšããŠæ©èœããã¹ãã¬ãŒãžãããã€ããŒãèšå®ããŸãããããkube-apiserver ããªãœãŒã¹ã®ç¶æ ã«ã¢ã¯ã»ã¹ãããå€æŽããããã察象ã§ãã
- ãã¹ãŠã®APIã°ã«ãŒãã«å¯ŸããŠåã°ã«ãŒãããŒãžã§ã³ã«ã€ããŠãç¹°ãè¿ããHTTP ã«ãŒãããšã«REST ãããã³ã°ãã€ã³ã¹ããŒã«ããŸããããã«ãã kube-apiserver ã¯ãªã¯ãšã¹ãããããã³ã°ããäžèŽãããã®ãèŠã€ãã£ããæ£ããããžãã¯ã«å§ä»»ããããšãã§ããããã«ãªããŸãã
- ç¹å®ã®ãŠãŒã¹ã±ãŒã¹ã§ã¯ãPOST ãã³ãã©ãŒãç»é²ããããããé çªã« create resource ãã³ãã©ãŒã«å§è²ãããŸãã
ãã®æç¹ã§ãkube-apiserver ã¯ã©ã®ã«ãŒããååšããããå®å šã«èªèããŠããããªã¯ãšã¹ããäžèŽããå Žåã«ã©ã®ãã³ãã©ãŒãšã¹ãã¬ãŒãžãããã€ããŒãåŒã³åºããã®å éšãããã³ã°ãæã£ãŠããŸãããªããšè³¢ãã®ã§ãããããããã§ã¯ãHTTP ãªã¯ãšã¹ããæµã蟌ãã ãšããŸãããã
- ãã³ãã©ãŒãã§ãŒã³ããªã¯ãšã¹ããèšå®ãã¿ãŒã³ïŒã€ãŸããç»é²ããã«ãŒãïŒã«äžèŽãããããšãã§ããå Žåããã®ã«ãŒãã«ç»é²ãããŠããå°çšãã³ãã©ã«ãã£ã¹ããããããŸãããã以å€ã¯ãã¹ããŒã¹ã®ãã³ãã©ãŒã«ãã©ãŒã«ããã¯ããŸãïŒããã¯
/apis
ãåŒã³åºãããšãã«èµ·ããããšã§ãïŒããã®ãã¹ã«ãã³ãã©ãç»é²ãããŠããªãå Žåã¯ãnot found ãã³ãã©ãŒãåŒã³åºããã404ãè¿ãããŸãã - 幞ããªããšã«ãç§ãã¡ã«ã¯
createHandler
ãšããç»é²ãããã«ãŒãããããŸããããã¯äœãããããã®ãã®ãªã®ã§ããããïŒããã¯æåã«HTTPãªã¯ãšã¹ãããã³ãŒãããæäŸããã JSON ãããŒãžã§ã³ç®¡çããã API ãªãœãŒã¹ã®æåŸ ã«æ²¿ãããšãä¿èšŒãããããªåºæ¬çãªããªããŒã·ã§ã³ãå®è¡ããã§ãããã - ç£æ»ãšæçµã¢ãããã·ã§ã³ãå®è¡ãããŸãã
- ã¹ãã¬ãŒãžãããã€ãã«å§è²ããããšã§ãªãœãŒã¹ã etcd ã«ä¿åãããŸããéåžžãetcd ããŒã¯
<åå空é>/<åå>
ã®åœ¢åŒã«ãªããŸãããèšå®å¯èœã§ãã - ããããäœæãšã©ãŒããã£ãããããæåŸã«ãã¹ãã¬ãŒãžãããã€ããŒã¯ãªããžã§ã¯ããå®éã«äœæãããããšã確èªããããã«
get
åŒã³åºããå®è¡ããŸããè¿œå ã®ãã¡ã€ãã©ã€ãºãå¿ èŠãªå Žåã¯ãpost-create ãã³ãã©ãŒãšãã³ã¬ãŒã¿ãåŒã³åºããŸãã - HTTP ã¬ã¹ãã³ã¹ãäœæãããŠè¿éãããŸãã
ããããã®ã¹ãããããããŸãïŒç§ãã¡ãå®éã«ã©ãã ãã®ä»äºãããŠããã®ããç解ããŠããã®ã§ããŠãµã®ã®ç©Žã®ãã³ã®è³ããã©ãã®ã¯ãšãŠãçŽ æŽãããããšã§ããèŠçŽãããšãDeployment ãªãœãŒã¹ã¯ etcd ã«ãããŸãããããããããšå£ãã ãã§ã¯ããŸã èŠãããšã¯ã§ããŸããâŠ
ãªããžã§ã¯ããããŒã¿ã¹ãã¢ã«æ°žç¶åãããåŸãäžé£ã®ã€ãã·ã£ã©ã€ã¶ãŒãå®è¡ããããŸã§ãã®ãªããžã§ã¯ã㯠apiserver ã«å®å šã«å¯èŠç¶æ ã«ãªãããã§ã¯ãªããã¹ã±ãžã¥ãŒã«ãããããšããããŸãããã€ãã·ã£ã©ã€ã¶ãŒã¯ããªãœãŒã¹ã¿ã€ãã«é¢é£ä»ãããããªãœãŒã¹ãå€éšã«å ¬éãããåã«ãã®ãªãœãŒã¹ã«å¯ŸããŠããžãã¯ãå®è¡ããã³ã³ãããŒã©ã§ãããªãœãŒã¹ã¿ã€ãã«ã€ãã·ã£ã©ã€ã¶ãŒãç»é²ãããŠããªãå Žåããã®åæåæé ã¯ã¹ãããããããªãœãŒã¹ã¯ããã«å¯èŠç¶æ ã«ãªããŸãã
å€ãã®çŽ æŽãããããã°æçš¿ã§ææãããŠããããã«ãããã䜿ããšäžè¬çãªããŒãã¹ãã©ããæäœãå®è¡ã§ããã®ã§åŒ·åãªæ©èœã§ããäŸãã°ã
- ããŒã80ãå ¬éãããããŸãã¯ç¹å®ã®ã¢ãããŒã·ã§ã³ãåãããããã·ãµã€ãã«ãŒã³ã³ããã Pod ã«ã€ã³ãžã§ã¯ã·ã§ã³ãã
- ãã¹ã蚌ææžä»ãã®ããªã¥ãŒã ãç¹å®ã®ããŒã ã¹ããŒã¹å ã®ãã¹ãŠã® Pod ã«ã€ã³ãžã§ã¯ã·ã§ã³ãã
- Secret ã20æåæªæºã®å ŽåïŒãã¹ã¯ãŒããªã©ïŒãäœæãããªã
initializerConfiguration
ãªããžã§ã¯ãã䜿ããšãç¹å®ã®ãªãœãŒã¹ã¿ã€ãã«å¯ŸããŠã©ã®ã€ãã·ã£ã©ã€ã¶ãŒãå®è¡ãããã宣èšã§ããŸããPod ãäœæããããã³ã«ã«ã¹ã¿ã ã€ãã·ã£ã©ã€ã¶ãŒãå®è¡ããå¿
èŠããããšãšãã¯æ¬¡ã®ããã«èšè¿°ããŸãã
apiVersion: admissionregistration.k8s.io/v1alpha1
kind: InitializerConfiguration
metadata:
name: custom-pod-initializer
initializers:
- name: podimage.example.com
rules:
- apiGroups:
- ""
apiVersions:
- v1
resources:
- pods
ãã®èšå®ãäœæããããšããã¹ãŠã®Podã® metadata.initializers.pending
ãã£ãŒã«ãã« custom-pod-initializer
ãè¿œå ãããŸããã€ãã·ã£ã©ã€ã¶ãŒã³ã³ãããŒã©ãŒã¯ãã§ã«ãããã€ãããŠãããæ°ãã Pod ãå®æçã«ã¹ãã£ã³ããŸããã€ãã·ã£ã©ã€ã¶ã Pod ã® pending ãã£ãŒã«ãã«ååãæã€ãã®ãæ€åºãããšããã®ããžãã¯ãå®è¡ããŸããåŠçãå®äºãããšããã³ãã£ã³ã°ãªã¹ãããååãåé€ãããŸããååããªã¹ãã®å
é ã«ããã€ãã·ã£ã©ã€ã¶ãŒã ãããªãœãŒã¹ãæäœã§ããŸãããã¹ãŠã®ã€ãã·ã£ã©ã€ã¶ãçµäºã㊠pending
ãã£ãŒã«ãã空ã«ãªããšããªããžã§ã¯ãã¯åæåããããšã¿ãªãããŸãã
éãããªãã¯æœåšçãªåé¡ã«æ°ã¥ãããããããŸããããããã®ãªãœãŒã¹ã kube-apiserver ã«ãã£ãŠå¯èŠåãããŠããªãå Žåãã©ã®ããã«ããŠãŠãŒã¶ãŒã©ã³ãã³ã³ãããŒã©ãŒããªãœãŒã¹ãåŠçããããšãã§ããã®ã§ããããïŒãã®åé¡ãåé¿ããããã«ãkube-apiserver ã¯ãåæåãããŠããªããã®ãå«ãããã¹ãŠã®ãªããžã§ã¯ããè¿ã ?includeUninitialized
ã¯ãšãªãã©ã¡ãŒã¿ãå
¬éããŠããŸãã
ãã®æ®µéã§ãç§ãã¡ã® Deployment ã¬ã³ãŒã㯠etcd ã«ååšããåæåããžãã¯ã¯ãã¹ãŠå®äºããŠããŸãã次ã®ã¹ãããã§ã¯ãKubernetes ãäŸåãããªãœãŒã¹ããããžãŒãèšå®ããŸãã èããŠã¿ããšãDeployment ã¯å®éã«ã¯åã« ReplicaSet ã®éãŸãã§ãããReplicaSet 㯠Pod ã®éãŸãã§ããã§ã¯ãKubernetes ã¯1ã€ã® HTTP ãªã¯ãšã¹ããããã®éå±€ãã©ã®ããã«äœæããã®ã§ããããïŒããããKubernetes ã®ãã«ãã€ã³ã³ã³ãããŒã©ãŒãåŒãç¶ããšããã§ãã
Kubernetes ã¯ã·ã¹ãã å
šäœã§ãã³ã³ãããŒã©ãŒãã匷åã«å©çšããŠããŸããã³ã³ãããŒã©ãŒã¯ãKubernetes ã·ã¹ãã ã®çŸåšã®ç¶æ
ãç®çã®ç¶æ
ã«èª¿æŽããããã®éåæã¹ã¯ãªããã§ãã
ããããã®ã³ã³ãããŒã©ãŒã¯å°ããªè²¬åãæã¡ã kube-controller-manager
ã³ã³ããŒãã³ãã«ãã£ãŠäžŠè¡ããŠå®è¡ãããŸããæåã«åŒãç¶ããã®ã§ãã Deployment ã³ã³ãããŒã©ãŒã玹ä»ããŸãã
Deployment ã¬ã³ãŒãã etcd ã«ä¿åããåæåãããåŸããã㯠kube-apiserver ãéããŠå¯èŠåãããŸãããã®æ°ãããªãœãŒã¹ãå©çšå¯èœã«ãªããšãDeployment ã¬ã³ãŒããå€æŽããããã©ãããç£èŠãã圹å²ãæ〠Deployment ã³ã³ãããŒã©ãŒã«ãã£ãŠæ€åºãããŸããç§ãã¡ã®å Žåãã³ã³ãããŒã©ãŒã¯ã€ã³ãã©ãŒããŒãä»ã㊠create ã€ãã³ãçšã®ç¹å®ã®ã³ãŒã«ããã¯ãç»é²ããŸãïŒãããäœã§ãããã«ã€ããŠã®è©³çŽ°ã¯äžèšãåç §ããŠãã ããïŒã
ãã®ãã³ãã©ãŒã¯ãDeployment ãæåã«äœ¿çšå¯èœã«ãªã£ããšãã«å®è¡ããããªããžã§ã¯ããå éšã¯ãŒã«ãŒãã¥ãŒã«è¿œå ããããšã«ãã£ãŠéå§ãããŸãããªããžã§ã¯ãã®åŠçã«åãæãããŸã§ã«ãã³ã³ãããŒã©ã¯ Deployment ã調ã¹ãŠããã«é¢é£ä»ãããã ReplicaSet ãŸã㯠Pod ã¬ã³ãŒãããªãããšãèªèããŸããã©ãã«ã»ã¬ã¯ã¿ã䜿ã£ãŠ kube-apiserver ã«åãåãããããšã«ãã£ãŠå®çŸãããŸããèå³æ·±ãã®ã¯ããã®åæããã»ã¹ã¯ç¶æ ã«äŸåããªããšããããšã§ããæ¢åã®ã¬ã³ãŒããšåãæ¹æ³ã§æ°ããã¬ã³ãŒãã調æŽããŸãã
äœãååšããªãããšãèªèããåŸãç¶æ ã®è§£æ±ºãéå§ããããã«ã¹ã±ãŒãªã³ã°ããã»ã¹ãéå§ããŸããReplicaSet ãªãœãŒã¹ãããŒã«ã¢ãŠãïŒäœæïŒããããã«ã©ãã«ã»ã¬ã¯ã¿ãå²ãåœãŠããªããžã§ã³çªå·1ãäžããããšã§å®çŸããŸããReplicaSet ã® PodSpec ã¯ãDeployment ã®ãããã§ã¹ããšãã®ä»ã®é¢é£ã¡ã¿ããŒã¿ããã³ããŒãããŸããå Žåã«ãã£ãŠã¯ãDeployment ã¬ã³ãŒãããã®åŸã«æŽæ°ããå¿ èŠããããŸãïŒããšãã°ããããã©ã€ã³ãèšå®ãããŠããå ŽåïŒã
次ã«ã¹ããŒã¿ã¹ãæŽæ°ãããDeployment ãæåŸ ãããå®äºç¶æ ã«äžèŽããã®ãåŸ ã€ã®ãšåã調æŽã«ãŒãã«æ»ããŸããDeployment ã³ã³ãããŒã©ãŒã¯ ReplicaSet ã®äœæã«ã€ããŠã®ã¿é¢å¿ããã€ã®ã§ããã®èª¿æŽã¹ããŒãžã¯æ¬¡ã®ã³ã³ãããŒã©ãŒã§ãã ReplicaSet ã³ã³ãããŒã©ã«ãã£ãŠç¶ç¶ããå¿ èŠããããŸãã
åã®ã¹ãããã§ã¯ãDeployment ã³ã³ãããŒã©ãŒã¯ãDeployment ã®æåã® ReplicaSet ãäœæããŸãããããŸã Pod ã¯ãããŸããããã㧠ReplicaSet ã³ã³ãããŒã©ãŒã®åºçªã§ãïŒãã®ã³ã³ãããŒã©ãŒã®ä»äºã¯ãReplicaSet ãšãã®äŸåãªãœãŒã¹ïŒ Pod ïŒã®ã©ã€ããµã€ã¯ã«ãç£èŠããããšã§ããä»ã®ã»ãšãã©ã®ã³ã³ãããŒã©ãŒãšåæ§ã«ãç¹å®ã®ã€ãã³ãã§ãã³ãã©ãèµ·åããããšã«ãã£ãŠå®çŸãããŸãã
é¢å¿ã®ããã€ãã³ãã¯äœæã§ããReplicaSet ãäœæããããšïŒ Deployment ã³ã³ãããŒã©ãŒã®åäœã®çµæïŒãRS ã³ã³ãããŒã©ãŒã¯æ°ãã ReplicaSet ã®ç¶æ ã調ã¹ãæ¢åã®ãã®ãšå¿ èŠãªãã®ãšã®éã«å·®åãããããšãèªèããŸãããã®åŸãReplicaSet ã«å±ãã Pod ã®æ°ãå¢ãããŠãã®ç¶æ ã調æŽããããšããŸããReplicaSet ã®ããŒã¹ãã«ãŠã³ãïŒèŠªã® Deployment ããç¶æ¿ãããã®ïŒãåžžã«äžèŽããããã«ãæ éã«äœæãããŸãã
Kubernetes ã¯ãªãŒããŒãªãã¡ã¬ã³ã¹ïŒåãªãœãŒã¹å ã®ã芪㮠ID ãåç §ãããã£ãŒã«ãïŒãéããŠãªããžã§ã¯ãã®éå±€æ§é ã匷å¶ããŸããããã¯ãã³ã³ãããŒã©ãŒã«ãã£ãŠç®¡çãããŠãããªãœãŒã¹ãåé€ããããšåãªãœãŒã¹ãã¬ããŒãžã³ã¬ã¯ã·ã§ã³ãããããšïŒã«ã¹ã±ãŒãåé€ïŒããä¿èšŒããã ãã§ãªãã芪ãªãœãŒã¹ãåãšæŠããªãããã®å¹æçãªæ¹æ³ãæäŸããŸãïŒ2人ã®æœåšçãªèŠªãåãåãå ±æããã®ãæ³åããŠãã ããïŒïŒã
Owner Reference èšèšã®ãã1ã€ã®å°ããªå©ç¹ã¯ã¹ããŒããã«ã§ããããšã§ããã³ã³ãããŒã©ãŒãåèµ·åããããšããŠãããªãœãŒã¹ããããžãŒã¯ã³ã³ãããŒã©ãŒããç¬ç«ããŠãããããããŠã³ã¿ã€ã ã¯ã·ã¹ãã å šäœã«åœ±é¿ãäžããŸãããåé¢ã«éäžãããšãã³ã³ãããŒã©ãŒèªäœã®èšèšã«ã圱é¿ãäžããŸããã³ã³ãããŒã©ãŒã¯ãæ瀺çã«ææããŠããªããªãœãŒã¹ãæäœããã¹ãã§ã¯ãããŸããã代ããã«ãã³ã³ãããŒã©ãŒã¯ãã®æææš©ã¢ãµãŒã·ã§ã³ãéå¹²æžãéå ±æã«ãããŠéžæçã§ããã¹ãã§ãã
ãšã«ããããªãŒããŒãªãã¡ã¬ã³ã¹ã«æ»ããŸãããïŒã·ã¹ãã ã«ãå€ç«ããããªãœãŒã¹ãããå ŽåããããŸããã€ãã®ãããªå Žåã§ãã
- 芪ãåé€ãããããåãåé€ãããŠããªããšã
- ã¬ããŒãžã³ã¬ã¯ã·ã§ã³ããªã·ãŒããã®åé€ãçŠããŠãããšã
ãã®ç¶æ³ã«ãããŠãã³ã³ãããŒã©ãŒã¯æ°ãã芪ã«å€ç«ããåãéžã¶ããä¿èšŒããŸããè€æ°ã®èŠªãåãéžã¶ããšãäºããŸãããæåããã®ã¯1人ã ãã§ãïŒä»ã®èŠªã¯ããªããŒã·ã§ã³ãšã©ãŒãåãåããŸãïŒã
ãæ°ã¥ããããããŸããããRBAC ãªãŒãœã©ã€ã¶ãŒãDeployment ã³ã³ãããŒã©ãŒã®ãããªã³ã³ãããŒã©ãŒãæ©èœããã«ã¯ãã¯ã©ã¹ã¿ãŒã®ç¶æ ãååŸããå¿ èŠããããŸããRBAC ãªãŒãœã©ã€ã¶ãŒã®äŸã«æ»ããšããªã¯ãšã¹ãããããšãã«ããªãŒã»ã³ãã£ã±ãŒã¿ãŒã¯åŸã§äœ¿çšããããã«ãŠãŒã¶ãŒç¶æ ã®åæè¡šçŸãä¿åããŸããRBAC ãªãŒãœã©ã€ã¶ãŒã¯ãããã䜿çšã㊠etcd å ã®ãŠãŒã¶ãŒã«é¢é£ä»ããããŠãããã¹ãŠã®ããŒã«ãšããŒã«ãã€ã³ãã£ã³ã°ãååŸããŸããã³ã³ãããŒã©ãŒã¯ã©ã®ããã«ããŠãã®ãããªãªãœãŒã¹ã«ã¢ã¯ã»ã¹ããŠå€æŽããã®ã§ããããïŒããã¯äžè¬çãªäœ¿çšäŸã§ãããKubernetes ã§ã¯ã€ã³ãã©ãŒããŒã䜿ã£ãŠè§£æ±ºãããŠããŸãã
ã€ã³ãã©ãŒããŒãšã¯ãã³ã³ãããŒã©ãŒãã¹ãã¬ãŒãžã€ãã³ãããµãã¹ã¯ã©ã€ãããŠãé¢å¿ã®ãããªãœãŒã¹ãç°¡åã«ãªã¹ãã§ããããã«ãããã¿ãŒã³ã§ããæ±ããããæœè±¡åãæäŸããããšãšã¯å¥ã«ãããã¯ãã£ãã·ã³ã°ã®ãããªå€ãã®ä»çµã¿ã®é¢åãèŠãŸãïŒãã£ãã·ã³ã°ã¯ãäžèŠãª kube-apiserver æ¥ç¶ãæžããããµãŒããŒãšã³ã³ãããŒã©ãŒã®éè€ããã·ãªã¢ã«åã³ã¹ããæžããã®ã§éèŠã§ãïŒããã®èšèšã䜿çšããããšã§ãåšå²ã«è¿·æããããã«ãã³ã³ãããŒã©ãŒãã¹ã¬ããã»ãŒããªæ¹æ³ã§ãããšãã§ããããã«ãªããŸãã
ã€ã³ãã©ãŒããŒãã³ã³ãããŒã©ãŒã«é¢ããŠã©ã®ããã«æ©èœãããã«ã€ããŠã®è©³çŽ°ã¯ããã®ããã°æçš¿ããã§ãã¯ããŠãã ããã
ãã¹ãŠã®ã³ã³ãããŒã©ãå®è¡ããããšãDeploymentãReplicaSetãããã³3ã€ã® Pod ã etcd ã«æ ŒçŽãããkube-apiserver ãéããŠäœ¿çšå¯èœã«ãªããŸããããããªãããç§ãã¡ã® Pod ã¯ãŸã Node ã«ã¹ã±ãžã¥ãŒã«ãããŠããªãã®ã§ã Pending
ç¶æ
ã®ãŸãŸã§ããããã解決ããæåŸã®ã³ã³ãããŒã©ã¯ã¹ã±ãžã¥ãŒã©ãŒã§ãã
ã¹ã±ãžã¥ãŒã©ãŒã¯ã³ã³ãããŒã«ãã¬ãŒã³ã®ã¹ã¿ã³ãã¢ãã³ã³ã³ããŒãã³ããšããŠå®è¡ãããä»ã®ã³ã³ãããŒã©ãŒãšåãããã«åäœããŸããã€ãŸãã€ãã³ããåŸ
æ©ããŠç¶æ
ã®èª¿æŽãè©Šã¿ãŸãããã®å ŽåãPodSpec ã«ç©ºã® NodeName
ãã£ãŒã«ããæ〠Pod ããã£ã«ã¿ãªã³ã°ãããã® Pod ãååšã§ããé©å㪠Node ãèŠã€ããããšããŸãã
é©åãªããããèŠã€ããããã«ãç¹å®ã®ã¹ã±ãžã¥ãŒãªã³ã°ã¢ã«ãŽãªãºã ã䜿çšãããŸããããã©ã«ãã®ã¹ã±ãžã¥ãŒãªã³ã°ã¢ã«ãŽãªãºã ã®ããã¿ã¯æ¬¡ã®ãšããã§ãã
-
ã¹ã±ãžã¥ãŒã©ãèµ·åãããšãäžé£ã®ããã©ã«ãè¿°èªãç»é²ãããŸãããããã®è¿°èªã¯ãè©äŸ¡æã« Pod ããã¹ãããé©æ§ã«åºã¥ã㊠Node ããã£ã«ã¿ãªã³ã°ããå¹æçãªæ©èœã§ããããšãã°ãPodSpec ãæ瀺çã« CPU ãŸã㯠RAM ãªãœãŒã¹ãèŠæ±ããNode ããã£ãã·ãã£äžè¶³ã®ããã«ãããã®èŠæ±ãæºããããšãã§ããªãå ŽåãPod ã®éžæã¯è§£é€ãããŸãïŒãªãœãŒã¹ãã£ãã·ãã£ã¯çŸåšå®è¡äžã®ã³ã³ãã ããã£ãã·ãã£åèšãããããªãœãŒã¹èŠæ±ã®åèšããåŒãããã®ã§ãïŒã
-
é©åãªããŒããéžæããããšããããã®é©åæ§ãã©ã³ã¯ä»ãããããã«ãæ®ãã® Node ã«å¯ŸããŠäžé£ã®åªå é äœé¢æ°ãå®è¡ãããŸããããšãã°ãã¯ãŒã¯ããŒããã·ã¹ãã å šäœã«åæ£ãããã«ã¯ãä»ããããªãœãŒã¹èŠæ±ãå°ãªãããŒããåªå ããŸãïŒããã¯ãå®è¡äžã®ã¯ãŒã¯ããŒããå°ãªãããšã瀺ãããã§ãïŒããããã®æ©èœãå®è¡ãããšãåããŒãã«æ°å€ã©ã³ã¯ãå²ãåœãŠãããŸãããããŠæé«ã©ã³ã¯ã®ããŒããã¹ã±ãžã¥ãŒãªã³ã°ã®ããã«éžæãããŸãã
ã¢ã«ãŽãªãºã ãããŒããèŠã€ãããšãã¹ã±ãžã¥ãŒã©ãŒã¯ Name ãš UID ã Pod ãšäžèŽããObjectReference ãã£ãŒã«ããéžæããã Node ã®ååãå«ã Binding ãªããžã§ã¯ããäœæããŸãããã®åŸããã㯠POST ãªã¯ãšã¹ããä»ã㊠apiserver ã«éä¿¡ãããŸãã
kube-apiserverã ãã® Binding ãªããžã§ã¯ããåãåããšãã¬ãžã¹ããªã¯ãªããžã§ã¯ãããã·ãªã¢ã©ã€ãºããPod ãªããžã§ã¯ãã®ä»¥äžã®ãã£ãŒã«ããæŽæ°ããŸããObjectReference 㧠NodeName ãèšå®ããé¢é£ããã¢ãããŒã·ã§ã³ãè¿œå ããPodScheduled
ã¹ããŒã¿ã¹æ¡ä»¶ã True
ã«èšå®ããŸãã
ã¹ã±ãžã¥ãŒã©ãŒã Podã Node ã«ã¹ã±ãžã¥ãŒãªã³ã°ãããšããã®ããŒãäžã® kubelet ãåŒãç¶ããå®è¡ããŠãããã€ã¡ã³ããéå§ã§ããŸããé¢çœãã§ããïŒ
è¿œèš: ã¹ã±ãžã¥ãŒã©ãŒã®ã«ã¹ã¿ãã€ãº: é¢çœãã®ã¯è¿°èªãšåªå
é äœé¢æ°ã®äž¡æ¹ãæ¡åŒµå¯èœã§ã --policy-config-file
ãã©ã°ã䜿ã£ãŠå®çŸ©ã§ããããšã§ããããã¯ããçšåºŠã®æè»æ§ããããããŸãã管çè
ã¯ãã¹ã¿ã³ãã¢ãã³ Deployment ã§ã«ã¹ã¿ã ã¹ã±ãžã¥ãŒã©ãŒïŒã«ã¹ã¿ã åŠçããžãã¯ãæã€ã³ã³ãããŒã©ãŒïŒãå®è¡ããããšãã§ããŸããPodSpec ã« schedulerName
ãå«ãŸããŠããå ŽåãKubernetes ã¯ãã® pod ã®ã¹ã±ãžã¥ãŒãªã³ã°ããã®ååã§ç»é²ãããŠããã¹ã±ãžã¥ãŒã©ãŒã«åŒãç¶ããŸãã
ããŠãã¡ã€ã³ã³ã³ãããŒã©ã®ã«ãŒãã¯çµäºããŸããããŸãšããŠèŠãŸããããHTTP ãªã¯ãšã¹ããèªèšŒãèªå¯ãã¢ãããã·ã§ã³ã³ã³ãããŒã«ã®åã¹ããããééããŸãããDeploymentãReplicaSetã3ã€ã®PodãªãœãŒã¹ã¯ etcd ã«æ°žç¶åãããŸãããäžé£ã®ã€ãã·ã£ã©ã€ã¶ãŒãå®è¡ãããŸããããããŠæåŸã«ãå Pod ã¯é©åãªããŒãã«ã¹ã±ãžã¥ãŒã«ãããŸãããããããããŸã§ã®ãšãããç§ãã¡ãæšçããŠããç¶æ ã¯çŽç²ã« etcd ã«ååšããŸãã以éã®ã¹ãããã«ã¯ãã¯ãŒã«ãŒããŒãéã«ç¶æ ãåé ããããšãå«ãŸããŸããããã¯ãKubernetesã® ãããªåæ£ã·ã¹ãã ã®æ¬è³ªãªã®ã§ãïŒãã㯠kubelet ãšåŒã°ããã³ã³ããŒãã³ããéããŠè¡ãããŸãããããå§ããŸãããïŒ
kubelet ã¯ãKubernetes ã¯ã©ã¹ã¿å ã®ããŒãæ¯ã«å®è¡ããããšãŒãžã§ã³ãã§ãç¹ã« Pod ã®ã©ã€ããµã€ã¯ã«ã®ç®¡çãæ åœããŸããããã¯ããPodãïŒããã¯å®éã«ã¯åãªãKubernetes ã®æŠå¿µã§ãïŒã®æœè±¡åãšãã®æ§æèŠçŽ ã§ããã³ã³ãããšã®éã®ãã¹ãŠã®ç¿»èš³ããžãã¯ãåŠçããããšãæå³ããŸãããŸããããªã¥ãŒã ã®ããŠã³ããã³ã³ããã®ãã°èšé²ãã¬ããŒãžã³ã¬ã¯ã·ã§ã³ããã®ä»å€ãã®éèŠãªããšã«é¢é£ãããã¹ãŠã®é¢é£ããžãã¯ãåŠçããŸãã
kubelet ã«ã€ããŠèããã®ã«äŸ¿å©ãªæ¹æ³ã¯ããã¯ãã³ã³ãããŒã©ãŒã®ãããªãã®ãšããŠèããããšã§ãã20ç§ããšïŒããã¯èšå®å¯èœã§ãïŒã« kube-apiserver ãã Pod ãã¯ãšãªãã NodeName
ã kubelet ãå®è¡ãããŠããããŒãã®ååãšäžèŽãããã®ããã£ã«ã¿ãªã³ã°ããŸãããªã¹ããæã£ãŠãããšãèªèº«ã®å
éšãã£ãã·ã¥ãšæ¯èŒããããšã«ãã£ãŠæ°ããªè¿œå ãæ€åºããäœããã®ççŸãååšããã°ç¶æ
ãåæããå§ããŸãããã®åæããã»ã¹ãã©ã®ãããªãã®ããèŠãŠã¿ãŸãããã
- pod ãäœæãããŠããå ŽåïŒç§ãã¡ã®ãã®ã§ãïŒïŒãpod ã®ã¬ã€ãã³ã·ãŒã远跡ããããã« Prometheus ã§äœ¿çšãããããã€ãã®ã¹ã¿ãŒãã¢ããã¡ããªãã¯ã¹ãç»é²ããŸãã
- 次ã«ãPod ã®çŸåšã® Phase ã®ç¶æ
ãè¡šã PodStatus ãªããžã§ã¯ããçæããŸããPod ã® Phase ã¯ãpod ããã®ã©ã€ããµã€ã¯ã«ã®ã©ãã«ããã®ãã®æŠèŠã§ããäŸãšããŠã¯ã
Pending
ãRunning
ãSucceeded
ãFailed
ãUnknown
ãªã©ããããŸãããã®ç¶æ ãçæããã®ã¯éåžžã«è€éãªã®ã§ãæ£ç¢ºã«äœãèµ·ããã®ããèŠãŠã¿ãŸãããã- æåã«ãäžé£ã®
PodSyncHandlers
ãé çªã«å®è¡ãããŸããåãã³ãã©ã¯ãPod ããŸã ããŒãã«ååšãã¹ããã©ããã確èªããŸããPod ãããããã«å±ããŠããªããšå€æããå ŽåãPod ã®ãã§ãŒãºã¯PodFailed
ã«å€ãããæçµçã« Node ããåé€ãããŸãããã®äŸãšããŠã¯ãactiveDeadlineSeconds
ãè¶ ããåŸã« Pod ãåé€ããããšããããŸãïŒ Jobs äžã«äœ¿çšãããŸãïŒã - 次ã«ãPod ã® Phase 㯠init ãšå®éã®ã³ã³ããã®ã¹ããŒã¿ã¹ã«ãã£ãŠæ±ºãŸããŸããã³ã³ããã¯ãŸã èµ·åãããŠããªãã®ã§ãã³ã³ããã¯åŸ
æ©äžãšããŠåé¡ãããŸããåŸ
æ©äžã®ã³ã³ãããæ〠Pod ã«ã¯ã
Pending
ã® Phase ã«ãªããŸãã - æåŸã«ãPod Condition ã¯ãã®ã³ã³ããã®ç¶æ
ã«ãã£ãŠæ±ºå®ãããŸããã³ã³ããã¯ã³ã³ããã©ã³ã¿ã€ã ã«ãã£ãŠãŸã äœæãããŠããªãã®ã§ã
PodReady
æ¡ä»¶ãFalse ã«èšå®ããŸãã
- æåã«ãäžé£ã®
- PodStatus ãçæãããåŸãPod ã®ã¹ããŒã¿ã¹ãããŒãžã£ãŒã«éä¿¡ãããŸãããã㯠apiserver ãä»ã㊠etcd ã¬ã³ãŒããéåæçã«æŽæ°ããããšãæ ããŸãã
- 次ã«ãpod ã«æ£ããã»ãã¥ãªãã£æš©éãããããšãä¿èšŒããããã«äžé£ã®ã¢ãããã·ã§ã³ãã³ãã©ãŒãå®è¡ãããŸããããã㯠AppArmor ãããã¡ã€ã«ãš
NO_NEW_PRIVS
ã匷å¶ããããšãå«ã¿ãŸãããã®æ®µéã§æåŠããã Pod ã¯ç¡æéã«Pending
ã®ç¶æ ã®ãŸãŸã«ãªããŸãã cgroups-per-qos
ã©ã³ã¿ã€ã ãã©ã°ãæå®ãããŠããå Žåãkubelet ã¯pod çšã® cgroup ãäœæãããªãœãŒã¹ãã©ã¡ãŒã¿ãé©çšããŸããããã¯ãpod ã®ãµãŒãã¹åè³ªïŒ QoS ïŒåŠçãåäžãããããã§ãã- Pod çšã®ããŒã¿ãã£ã¬ã¯ããªãäœæãããŸãããããã«ã¯ pod ãã£ã¬ã¯ããªïŒéåžžã¯
/var/run/kubelet/pods/<podID>
ïŒããã®ããªã¥ãŒã ãã£ã¬ã¯ããªïŒ<podDir>/volumes
ïŒããã³ãã®ãã©ã°ã€ã³ãã£ã¬ã¯ããªïŒ<podDir>/plugins
ïŒãå«ãŸããŸãã - ããªã¥ãŒã ãããŒãžã£ã¯
Spec.Volumes
ã§å®çŸ©ãããé¢é£ããªã¥ãŒã ãããã°ãããã¢ã¿ããããŠåŸ ã¡ãŸããããŠã³ããããŠããããªã¥ãŒã ã®çš®é¡ã«ãã£ãŠã¯ãããã€ãã®ãããã§ã¯ããé·ãæéåŸ ã€å¿ èŠããããŸãïŒã¯ã©ãŠãã NFS ããªã¥ãŒã ãªã©ïŒã Spec.ImagePullSecrets
ã§å®çŸ©ãããŠãããã¹ãŠã®ã·ãŒã¯ã¬ããã¯ãåŸã§ã³ã³ããã«ã€ã³ãžã§ã¯ã·ã§ã³ã§ããããã«ãapiserver ããååŸãããŸãã- ãã®åŸãã³ã³ããã©ã³ã¿ã€ã ã¯ã³ã³ãããå®è¡ããŸãïŒè©³çŽ°ã¯åŸè¿°ïŒã
ããã§ã»ãšãã©ã®ã»ããã¢ãããå®äºããã³ã³ãããèµ·åããæºåãæŽããŸããããã®èµ·åãè¡ããœãããŠã§ã¢ã¯ã³ã³ããã©ã³ã¿ã€ã ãšåŒã°ããŸãïŒ docker
ã rkt
ããã®äŸã§ãïŒã
ããæ¡åŒµæ§ãé«ããããã«ãv1.5.0以éã® kubelet ã§ã¯ãå ·äœçãªã³ã³ããã©ã³ã¿ã€ã ãšãããšãããããã« CRIïŒ Container Runtime Interface ïŒãšåŒã°ããæŠå¿µã䜿çšããŠããŸãããäžèšã§èšãã°ãCRI 㯠kubelet ãšç¹å®ã®ã©ã³ã¿ã€ã å®è£ ã®éã®æœè±¡åãæäŸããŸããéä¿¡ã¯ãããã³ã«ãããã¡ïŒããéãJSONã®ãããªãã®ïŒãšgRPC APIïŒ Kubernetes ãªãã¬ãŒã·ã§ã³ãå®è¡ããã®ã«æé©ãªã¿ã€ãã® API ïŒãä»ããŠè¡ãããŸããkubelet ãšã©ã³ã¿ã€ã ã®éã§å®çŸ©æžã¿ã®å¥çŽã䜿çšããããšã«ãã£ãŠãã³ã³ããã®ç·šææ¹æ³ã«é¢ããå®éã®å®è£ ã®è©³çŽ°ã¯ã»ãšãã©ç¡é¢ä¿ã«ãªããããããã¯éåžžã«çŽ æŽãããã¢ã€ãã¢ã§ããéèŠãªã®ã¯å¥çŽã ãã§ããããã«ãããã³ã¢ Kubernetes ã³ãŒããå€æŽããå¿ èŠããªããããæå°éã®ãªãŒããŒãããã§æ°ããã©ã³ã¿ã€ã ãè¿œå ã§ããŸãïŒ
ã ãã¶æšªéã«ãããŠããŸã£ãã®ã§ã³ã³ããã®ãããã€ã«æ»ããŸãããâŠãPod ãæåã«èµ·åããããšãkubelet 㯠RunPodSandbox
ãªã¢ãŒãããã·ãŒãžã£ã³ãã³ãïŒ RPC ïŒãåŒã³åºããŸããããµã³ãããã¯ã¹ããšã¯ãCRIçšèªã§ã¯äžé£ã®ã³ã³ãããè¡šãããæ³åã®éãKubernetesã§èšã Pod ã§ãããã®çšèªã¯æå³çã«ææ§ã«ãªã£ãŠãããããå®éã«ã³ã³ããã䜿çšããªãä»ã®ã©ã³ã¿ã€ã ã«å¯ŸããŠãããã®æå³ã倱ãããšã¯ãããŸããïŒãµã³ãããã¯ã¹ã VM ã®å Žåããããã€ããŒãã€ã¶ããŒã¹ã®ã©ã³ã¿ã€ã ãæ³åããŠãã ããïŒã
ä»å㯠Docker ã䜿çšããŠããŸãããã®ã©ã³ã¿ã€ã ã§ã¯ããµã³ãããã¯ã¹ã®äœæã«ã¯ãäžæåæ¢ãã³ã³ããã®äœæãå«ãŸããŸããäžæåæ¢ã³ã³ããã¯ãã¯ãŒã¯ããŒãã³ã³ããã䜿çšããããšã«ãªãå€ãã® pod ã¬ãã«ã®ãªãœãŒã¹ããã¹ããããããpod å ã®ä»ã®ãã¹ãŠã®ã³ã³ããã®èŠªã®ããã«æ©èœããŸãããããã®ããªãœãŒã¹ããšã¯ Linux ããŒã ã¹ããŒã¹ïŒIPCãnetworkãPIDïŒã§ããLinux ã§ã³ã³ãããã©ã®ããã«æ©èœããã®ãã«æ £ããŠããªãå Žåã¯ãç°¡åã«èª¬æããŸããããLinux ã«ãŒãã«ã«ã¯ããŒã ã¹ããŒã¹ã®æŠå¿µãããããã¹ã OS ã¯å°çšã®ãªãœãŒã¹ã»ããïŒ CPU ãã¡ã¢ãªãªã©ïŒãåãåºããããã䜿çšããŠããäžçã§å¯äžã®ãã®ã§ãããã®ããã«ããã»ã¹ã«æäŸã§ããŸããCgroup ã¯ãLinux ããªãœãŒã¹å²ãåœãŠã管çããæ¹æ³ã§ãããããããã§ãéèŠã§ãïŒãªãœãŒã¹äœ¿çšéãç£èŠããèŠå®ã®ãããªãã®ã§ãïŒãDocker ã¯ããããã®ã«ãŒãã«æ©èœã®äž¡æ¹ã䜿çšããŠããªãœãŒã¹ãä¿èšŒããåé¢ã匷åãããããã»ã¹ããã¹ãããŸãã詳现ã«ã€ããŠã¯ãb0rkã®çŽ æŽãããæçš¿ãã³ã³ãããšã¯äœãïŒãããã§ãã¯ããŠãã ããã
ãäžæåæ¢ãã³ã³ããã¯ããããã®åå空éããã¹ãŠãã¹ãããåã³ã³ãããããããå
±æã§ããããã«ããæ¹æ³ãæäŸããŸããåããããã¯ãŒã¯åå空éã®äžéšã§ãããããåã pod å
ã®ã³ã³ããã localhost
ã䜿çšããŠäºãã«åç
§ã§ããã®ã1ã€ã®å©ç¹ã§ããäžæåæ¢ã³ã³ããã®2ã€ãã®åœ¹å²ã¯ãPID åå空éãã©ã®ããã«æ©èœãããã«é¢é£ããŠããŸãããã®çš®ã®åå空éã§ã¯ãããã»ã¹ãéå±€ããªãŒã圢æããäžçªäžã®ãinitãããã»ã¹ããããããã»ã¹ã®ãåãåãããæ
åœããŸãããããã©ã®ããã«æ©èœãããã«ã€ããŠã®è©³çŽ°ã¯ããã®çŽ æŽãããããã°èšäºããã§ãã¯ããŠãã ããã
ç§ãã¡ã® Pod ã¯ä»ãåºæ¬çãªæ§é ãã€ãŸã Pod ééä¿¡ãå¯èœã«ããããã«ãã¹ãŠã®åå空éããã¹ãããäžæåæ¢ã³ã³ããæã£ãŠããŸãããããããããã¯ãŒãã³ã°ã¯ã©ã®ããã«æ©èœããã©ã®ããã«èšå®ãããã®ã§ããããïŒ
kubelet ã pod çšã®ãããã¯ãŒã¯ãèšå®ãããšãã¿ã¹ã¯ããCNIããã©ã°ã€ã³ã«å§è²ããŸããCNI 㯠Container Network Interface ã®ç¥ã§ãContainer Runtime Interfaceãš åãããã«åäœããŸããäžèšã§èšãã°ãCNI ã¯ããŸããŸãªãããã¯ãŒã¯ãããã€ããããŸããŸãªãããã¯ãŒã¯å®è£
ãã³ã³ããã«äœ¿çšã§ããããã«ããããã®æœè±¡åã§ãããã©ã°ã€ã³ãç»é²ãããkubelet 㯠JSON ããŒã¿ïŒèšå®ãã¡ã€ã«ã¯ /etc/cni/net.d
ã«ãããŸãïŒã stdin ãä»ããŠé¢é£ãã CNI ãã€ããªïŒ/opt/cni/bin
ã«ããïŒã«ã¹ããªãŒãã³ã°ããããšã«ãã£ãŠããããšãããšãããŸãããã㯠JSON èšå®ã®äŸã§ãã
{
"cniVersion": "0.3.1",
"name": "bridge",
"type": "bridge",
"bridge": "cnio0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"ranges": [
[{"subnet": "${POD_CIDR}"}]
],
"routes": [{"dst": "0.0.0.0/0"}]
}
}
ãŸãã CNI_ARGS
ç°å¢å€æ°ãéããŠãã®ååãåå空éã®ãã㪠pod ã®ããã®è¿œå ã®ã¡ã¿ããŒã¿ãæå®ããŸãã
次ã«èµ·ããããšã¯ CNI ãã©ã°ã€ã³ã«äŸåããŠããŸãããããã§ã¯ bridge
CNI ãã©ã°ã€ã³ãèŠãŠã¿ãŸãããã
- ãã©ã°ã€ã³ã¯æåã«ã«ãŒããããã¯ãŒã¯åå空éã«ããŒã«ã« Linux ããªããžãèšå®ããŠãã®ãã¹ãäžã®ãã¹ãŠã®ã³ã³ããã«ãµãŒãã¹ãæäŸããŸãã
- 次ã«ãäžæåæ¢ã³ã³ããã®ãããã¯ãŒã¯ããŒã ã¹ããŒã¹ã«ã€ã³ã¿ãŒãã§ã€ã¹ïŒ veth ãã¢ã®äžç«¯ïŒãæ¿å ¥ããããäžæ¹ã®ç«¯ãããªããžã«æ¥ç¶ããŸããVethãã¢å€§ããªãã¥ãŒãã®ãããªãã®ãšèããã®ãããã§ããããäžæ¹ãã³ã³ããã«æ¥ç¶ãããããäžæ¹ãã«ãŒããããã¯ãŒã¯ã®ããŒã ã¹ããŒã¹ã«ããããã±ããããã®éãééã§ããããã«ããã®ã§ãã
- 次ã«ãäžæåæ¢ã³ã³ããã®ã€ã³ã¿ãŒãã§ã€ã¹ã« IP ãå²ãåœãŠãã«ãŒããèšå®ããŸããããã«ãããPod ã«ç¬èªã® IP ã¢ãã¬ã¹ãå²ãåœãŠãããŸããIP å²ãåœãŠã¯ãJSON èšå®ã«æå®ãããŠãã IPAM ãããã€ããŒã«å§è²ãããŸãã
- IPAM ãã©ã°ã€ã³ã¯ãã¡ã€ã³ãããã¯ãŒã¯ãã©ã°ã€ã³ãšäŒŒãŠããŸãããã€ããªãä»ããŠåŒã³åºãããæšæºåãããã€ã³ã¿ãŒãã§ãŒã¹ãæã¡ãŸãããããããã³ã³ããã®ã€ã³ã¿ãŒãã§ãŒã¹ã® IP /ãµãããããã²ãŒããŠã§ã€ãšã«ãŒããšå
±ã«æ±ºå®ãããã®æ
å ±ãã¡ã€ã³ãã©ã°ã€ã³ã«è¿ãå¿
èŠããããŸããæãäžè¬ç㪠IPAM ãã©ã°ã€ã³ã¯
host-local
ãšåŒã°ããäºåã«å®çŸ©ãããã¢ãã¬ã¹ç¯å²ã®ã»ãããã IP ã¢ãã¬ã¹ãå²ãåœãŠãŸããç¶æ ããã¹ããã¡ã€ã«ã·ã¹ãã ã®ããŒã«ã«ã«ä¿åãããããåäžãã¹ãäžã® IP ã¢ãã¬ã¹ã®äžææ§ãä¿èšŒãããŸãã
- IPAM ãã©ã°ã€ã³ã¯ãã¡ã€ã³ãããã¯ãŒã¯ãã©ã°ã€ã³ãšäŒŒãŠããŸãããã€ããªãä»ããŠåŒã³åºãããæšæºåãããã€ã³ã¿ãŒãã§ãŒã¹ãæã¡ãŸãããããããã³ã³ããã®ã€ã³ã¿ãŒãã§ãŒã¹ã® IP /ãµãããããã²ãŒããŠã§ã€ãšã«ãŒããšå
±ã«æ±ºå®ãããã®æ
å ±ãã¡ã€ã³ãã©ã°ã€ã³ã«è¿ãå¿
èŠããããŸããæãäžè¬ç㪠IPAM ãã©ã°ã€ã³ã¯
- DNS ã®å Žåãkubelet 㯠CNI ãã©ã°ã€ã³ã«å
éš DNS ãµãŒããŒã® IP ã¢ãã¬ã¹ãæå®ããŸããããã«ãããã³ã³ããã®
resolv.conf
ãã¡ã€ã«ãé©åã«èšå®ãããŸãã
ããã»ã¹ãå®äºãããšããã©ã°ã€ã³ã¯ JSON ããŒã¿ã kubelet ã«è¿ããŠæäœã®çµæã瀺ããŸãã
ãããŸã§ãã³ã³ããããã¹ãã«æ¥ç¶ããæ¹æ³ã«ã€ããŠèª¬æããŸãããããã¹ãéã®éä¿¡ã¯ã©ã®ããã«è¡ãããã®ã§ããããïŒããã¯ç°ãªããã·ã³äžã®2ã€ã®Podãéä¿¡ãããå Žåã«ãå¿ ãèµ·ãããŸãã
ããã¯éåžžããªãŒããŒã¬ã€ãããã¯ãŒãã³ã°ãšåŒã°ããæŠå¿µã䜿çšããŠå®çŸãããŸããããã¯ãè€æ°ã®ãã¹ãéã§åçã«ã«ãŒããåæãããæ¹æ³ã§ãã人æ°ã®ãªãŒããŒã¬ã€ãããã¯ãŒã¯ãããã€ãã®1ã€ã Flannel ã§ããã€ã³ã¹ããŒã«æã®äžå¿çãªåœ¹å²ã¯ãã¯ã©ã¹ã¿å ã®è€æ°ã®ããŒãéã«ã¬ã€ã€3 IPv4ãããã¯ãŒã¯ãæäŸããããšã§ããFlannel ã¯ã³ã³ãããã©ã®ããã«ãã¹ãã«ãããã¯ãŒã¯æ¥ç¶ããããïŒããã¯CNIãèŠããŠããä»äºã§ãïŒãå¶åŸ¡ããã®ã§ã¯ãªãããã©ãã£ãã¯ããã¹ããéãã§ã©ã®ããã«è»¢éãããããå¶åŸ¡ããŸãããããè¡ãã«ã¯ããã¹ãã®ãµãããããéžæã㊠etcd ã«ç»é²ããŸãã次ã«ãã¯ã©ã¹ã¿ã«ãŒãã®ããŒã«ã«è¡šçŸãç¶æããçºä¿¡ãã±ããã UDP ããŒã¿ã°ã©ã ã«ã«ãã»ã«åããŠãæ£ãããã¹ãã«å°éã§ããããã«ããŸãã詳现ã«ã€ããŠã¯ãCoreOS ã®ããã¥ã¡ã³ãããã§ãã¯ããŠãã ããã
ãããã¯ãŒãã³ã°ã®ãã¹ãŠã®é¢åãªããšã¯å®äºããŸãããäœãæ®ã£ãŠããã§ããããïŒã¯ãŒã¯ããŒãã³ã³ãããå®éã«èµ·åããå¿ èŠããããŸãã
ãµã³ãããã¯ã¹ã®åæåãå®äºããŠã¢ã¯ãã£ãã«ãªããšãkubelet ã¯ããã«å¯Ÿããã³ã³ããã®äœæãéå§ã§ããŸããæåã« PodSpec ã§å®çŸ©ãããŠãã init ã³ã³ãããèµ·åãã次ã«ã¡ã€ã³ã³ã³ããèªäœãèµ·åããŸãã次ã®ãããªæé ã§ãã
- ã³ã³ããã€ã¡ãŒãžããã«ããŸããPodSpec ã§å®çŸ©ãããŠãã Secret ã¯ãã¹ãŠãã©ã€ããŒãã¬ãžã¹ããªã«äœ¿çšãããŸãã
- CRI ãä»ããŠã³ã³ãããäœæããŸããããã¯ã芪㮠PodSpec ãã
ContainerConfig
æ§é äœïŒã³ãã³ããç»åãã©ãã«ãããŠã³ããããã€ã¹ãç°å¢å€æ°ãªã©ãå®çŸ©ãããŠããïŒãçæããããããããã³ã«ãããã¡çµç±ã§ CRI ãã©ã°ã€ã³ã«éä¿¡ããããšã«ãã£ãŠè¡ãããŸããDocker ã®å Žåã¯ããã€ããŒãããã·ãªã¢ã©ã€ãºããŠãDaemon API ã«éä¿¡ããããã®ç¬èªã®èšå®æ§é äœãçæããŸãããã®éçšã§ãã³ã³ããã«ããã€ãã®ã¡ã¿ããŒã¿ã©ãã«ïŒã³ã³ããã¿ã€ãããã°ãã¹ããµã³ãããã¯ã¹ ID ãªã©ïŒãé©çšãããŸãã - ã³ã³ããã CPU ãããŒãžã£ã«ç»é²ããŸããããã¯1.8ã®æ°ããã¢ã«ãã¡æ©èœã§ããã
UpdateContainerResources
CRI ã¡ãœããã䜿ã£ãŠããŒã«ã«ããŒãäžã® CPU ã®ã»ããã«ã³ã³ãããå²ãåœãŠãŸãã - ã³ã³ãããéå§ãããŸãã
- èµ·ååŸã®ã³ã³ããã©ã€ããµã€ã¯ã«ããã¯ãç»é²ãããŠããå Žåã¯å®è¡ãããŸããããã¯ã¯
Exec
ïŒã³ã³ããå ã®ç¹å®ã®ã³ãã³ããå®è¡ããïŒãHTTP
ïŒã³ã³ãããšã³ããã€ã³ãã«å¯ŸããŠHTTPãªã¯ãšã¹ããå®è¡ããïŒã®ã©ã¡ããã§ããPostStartããã¯ã®å®è¡ã«æéããããããããããã³ã°ã¢ãããããã倱æãããããå Žåãã³ã³ããã¯æ±ºããŠrunning
ç¶æ ã«ã¯ãªããŸããã
å®äºã§ãã
以äžã®åŸã«ã3ã€ã®ã³ã³ãããã1ã€ãŸãã¯è€æ°ã®ã¯ãŒã«ãŒããŒãã§å®è¡ãããŠããã¯ãã§ãããã¹ãŠã®ãããã¯ãŒãã³ã°ãããªã¥ãŒã ãã·ãŒã¯ã¬ããã¯ãkubelet ã«ãã£ãŠè¿œå ãããCRI ãã©ã°ã€ã³ãä»ããŠã³ã³ããã«ãªããŸããã