Kubernetesã§å®éã®ã¡ã¢ãªãè¶ ããã³ã³ããã¢ããªãåããã¨ãã©ããªããï¼
Kubernetesã¯ãã³ã³ããã¢ããªã±ã¼ã·ã§ã³ããããã¤ããããã®ãªã¼ã±ã¹ãã¬ã¼ã·ã§ã³ãã¼ã«ã§ããKuberenetesã¯åæ£ç°å¢ã«ãããã¹ã±ã¼ã©ãã«ãªã³ã³ããå®è¡ç°å¢ãã¤ããããã®ããã¾ãã¾ãªæ©è½ãæä¾ããã¦ãã¾ãã
ãã¨ãã¨ã¯GoogleãéçºããBorgããã¨ã«OSSåãããã®ã§ãããä»æ¥ã§ã¯ãã¤ã¯ãã½ãããï¼ry
Kubernetesãã¤ããã¨ã¹ãã¼ãã¬ã¹ã§ãã¤ã¯ããµã¼ãã¹çãªã¢ããªã±ã¼ã·ã§ã³ã1æ¥ã«ä½åº¦ããããã¤ã§ããã¹ãã¤ã¯ã¢ã¯ã»ã¹ããã¦ãæ°´å¹³ã¹ã±ã¼ã«ã容æãªã®ã§ã大è¦æ¨¡Webã·ã¹ãã ã§ã¹ã±ã¼ã©ãã«ãªåºç¤ãä½ãããã¨ããã®ã¯åºãç¥ããã¦ãã¾ãã
ä¸æ¹ãKubernetesã«ã¯ãResource Requestsãã¨ããæ©è½ããããããã¯Podããããã¤ããæã«å¿ è¦ã¨ãããªã½ã¼ã¹(CPU/ã¡ã¢ãª)ãæå®ã§ãããã®ã§ããããã«ãããKubernetesã¯ã©ã¹ã¿ã®ãªã½ã¼ã¹ã®ä½¿ç¨çãé«ããå¹çããã¢ããªã稼åããããã¨ãã§ããã®ããããããã®ä¸ã¤ã§ãã
Kubernetesã§ã¯ã³ã³ããã使ç¨ããã³ã³ãã¥ã¼ãã£ã³ã°ãªã½ã¼ã¹ãæ示çã«è¦æ±ãããå¶éããããããããã¨ãã§ãã¾ãã
ãªã½ã¼ã¹è¦æ±(Resource Request)
- ã³ã³ããã«å¯¾ãã¦æå®ãããªã½ã¼ã¹ã使ããããã«ä¿è¨¼ããããã¿
- ã¢ããªãåããã®ã«æä½éå¿ è¦ãªãªã½ã¼ã¹ãæå®
ãªã½ã¼ã¹å¶é(Resurce Limits)
- ã³ã³ããã®ãªã½ã¼ã¹ä½¿ç¨éã®ä¸éã決ããããã¿
- ã¢ããªã±ã¼ã·ã§ã³ã使ç¨ããå¯è½æ§ã®ããæ大ãªã½ã¼ã¹ãæå®
ã¨ãããã¨ã§ãããã¾ãã¯ã¡ã¢ãªã®ãªã½ã¼ã¹è¦æ±(Resource Request)ã¤ãã¦ã
- ã³ã³ããã¢ããªã使ãã¡ã¢ãªãæ示çã«è¦æ±ããã¨ã¯ã©ã¹ã¿ä¸ã§ã©ãããåããããã®ãï¼
- ã¡ã¢ãªããããã使ãå¥ã¢ããªãéªéãã¦ããã¨ãããã¡ãã¨ã·ã¹ãã ã¯åä½ããã®ãï¼
ãæ°ã«ãªããç°¡åãªæ¤è¨¼ããã¦ã¿ã¾ããã
åæèªè
- Dockerã®ä½¿ãæ¹ãåãã人
- ã¯ã©ã¦ãããã¼ã¸ã(AKSã¾ãã¯GKE)ã§Kubernetesã¯ã©ã¹ã¿ãæ§ç¯ã§ãã人
- Kubernetesã®åºæ¬ã³ãã³ããç¥ã£ã¦ãã人
å®é¨ç°å¢
Azureã®Kubernetesã®ãã«ããã¼ã¸ããµã¼ãã¹ã§ããAKSã使ãã¾ããå ¬å¼ãµã¤ãããã¨ã«Kubernetesã¯ã©ã¹ã¿ãæ§ç¯ãã¾ããã
クイック スタート:Azure Kubernetes Service クラスターをデプロイする | Microsoft Docs
ããã§ã¯ã次ã®æ§æã®ã¯ã©ã¹ã¿ã§å®é¨ãã¾ãã
MasterãNodeãkubernetes1.9.6ã§æ¤è¨¼ãã¦ãã¾ãã
ã³ã³ããã¢ããªã使ãã¡ã¢ãªãæ示çã«è¦æ±ããã¨ã¯ã©ã¹ã¿ä¸ã§ã©ãããåããããã®ãï¼
Kubernetesãã·ã¹ãã ã§ä½¿ç¨ããã¡ã¢ãªéã確èª
ä»åã®ã¯ã©ã¹ã¿ã¯Azure VMã®ãStandard_D1_v2ããNodeã«ã¤ãã£ã¦ãã¾ããStandard_D1_v2ã¯1å°å½ããç´3.3GBã®ã¡ã¢ãªã使ãã¾ãã
念ã®ããã次ã®ã³ãã³ãã§ç¢ºèªãã¾ãã
$ kubectl describe node Name: aks-nodepool1-12354740-1 Roles: agent Labels: agentpool=nodepool1 ï½ä¸ç¥ï½ Capacity: memory: 3501592Ki Allocatable: memory: 3399192Ki ï½ä¸ç¥ï½ Name: aks-nodepool1-12354740-2 Roles: agent Labels: agentpool=nodepool1 Capacity: memory: 3501592Ki Allocatable: memory: 3399192Ki
Nodeä¸ã§ã¯kube-proxyçãåä½ãã¦ãããããPodã1ã¤ãåä½ããã¦ããªãç¶æ ã§ãã223Mï¼499Mã®ã¡ã¢ãªã使ç¨ãã¦ãã¾ãã
$ kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% aks-nodepool1-12354740-1 28m 2% 223Mi 6% aks-nodepool1-12354740-2 128m 12% 499Mi 15%
ã¢ããªãåããã®ã«å¿ è¦ãªã¡ã¢ãªãè¦æ±ãã¦Podãåãã
ã¾ãã¯ãResource Requestã®åãã確èªãã¾ããã³ã³ããã«å¶éããããã«ã¯[resources:]ï¼[requests:]ã§å¤ãæå®ãã¾ãã 次ã®ä¾(resource-pod.yaml)ã¯ããnginxãã®å ¬å¼ã¤ã¡ã¼ã¸ããã¨ã«åãããã³ã³ããã1ã¤å«ã¾ããPodããã³ãã¬ã¼ãã¨ãã¦å®ç¾©ããããããreplicas: 2ãã¤ã¾ã2ã¤ã®PodãKubernetesã¯ã©ã¹ã¿ä¸ã«ã¹ã±ã¸ã¥ã¼ãªã³ã°ãããå®ç¾©ã«ãªãã¾ãã
ãã®éãã¡ã¢ãªã®ãªã½ã¼ã¹è¦æ±ã¨ãã¦[memory: 1.5Gi]ãæå®ãã¾ããã¤ã¾ãããã¯Kubernetes ã«å¯¾ãã¦ããã®Podã«ããNginxã³ã³ããã¯1.5Giã®ã¡ã¢ãªå¿ è¦ã ããããããï¼ãã宣è¨ãã¦ãã¾ãã
apiVersion: apps/v1 kind: ReplicaSet metadata: name: reqest-exp spec: replicas: 2 selector: matchLabels: app: replicaset-temp template: metadata: labels: app: replicaset-temp spec: containers: - name: pod-sample image: nginx resources: requests: memory: 1.5Gi
ããã次ã®ã³ãã³ããå®è¡ãã¦ã¯ã©ã¹ã¿ä¸ã§ãªã½ã¼ã¹ãä½ãã¾ãã
$ kubectl create -f resource-pod.yaml replicaset.apps "reqest-exp" created
PodãããããNode1ã¨Node2ã§1ã¤ãã¤åãã¦ãã¾ãã
$ kubectl get po -o wide NAME READY STATUS RESTARTS AGE IP NODE reqest-exp-9kztw 1/1 Running 0 55s 10.244.2.153 aks-nodepool1-12354740-2 reqest-exp-b4t8h 1/1 Running 0 55s 10.244.3.184 aks-nodepool1-12354740-1
çµµã§æãã¨ãããªæãã
ãã ãèµ·åãã¦ããNginxã¯ä½ãä»äºããã¦ããªãã®ã§ãå®éã®ã¡ã¢ãªä½¿ç¨éã¯ã»ã¨ãã©å¢ãã¦ãã¾ããã
$ kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% aks-nodepool1-12354740-1 33m 3% 251Mi 7% aks-nodepool1-12354740-2 133m 13% 505Mi 15%
è¦æ±ãããã¡ã¢ãªãå®éã®ã¡ã¢ãªãè¶ ããã¨ã©ããªãã
次ã®ã³ãã³ããå®è¡ãã¦ãPodã®ã¬ããªã«æ°ã2ãã3ã«å¢ããã¾ããã©ããªãããã¿ã¦ã¿ã¾ãã
$ kubectl scale --replicas=3 -f resource-pod.yaml replicaset.apps "reqest-exp" scaled
Node1ã«2ã¤ã®PodãNode2ã«1ã¤ã®Podãåãã¦ãã¾ããã¾ã å®ç¾©ãã¡ã¤ã«ã§è¦æ±ããç·ã¡ã¢ãªéã¯ãå®éã®ã¯ã©ã¹ã¿ã®ã¡ã¢ãªéãè¶ ãã¦ãã¾ããã
$ kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE reqest-exp-9kztw 1/1 Running 0 8m 10.244.2.153 aks-nodepool1-12354740-2 reqest-exp-b4t8h 1/1 Running 0 8m 10.244.3.184 aks-nodepool1-12354740-1 reqest-exp-wzg7t 1/1 Running 0 43s 10.244.3.185 aks-nodepool1-12354740-1
çµµã§æãã¨ãããªæãã§ãã
次ã¯ã¬ããªã«æ°ã3ãã4ã«å¤æ´ãã¾ãã
$ kubectl scale --replicas=4 -f resource-pod.yaml replicaset.apps "reqest-exp" scaled
4ã¤ç®ã®Podã§ãããreqest-exp-fgrpnãã¯ã©ãã®Nodeã§ãèµ·åãããPendingãã«ãªã£ã¦ããã®ãåããã¾ãã
$ kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE reqest-exp-9kztw 1/1 Running 0 13m 10.244.2.153 aks-nodepool1-12354740-2 reqest-exp-b4t8h 1/1 Running 0 13m 10.244.3.184 aks-nodepool1-12354740-1 reqest-exp-fgrpn 0/1 Pending 0 12s <none> <none> reqest-exp-wzg7t 1/1 Running 0 5m 10.244.3.185 aks-nodepool1-12354740-1
ã¾ãã¾ãçµµã§æãã¨ãããªæãã
ãã¤ããã§ãããå®éã®ã¡ã¢ãªä½¿ç¨éã¯ã»ã¨ãã©å¢ãã¦ãã¾ãããã¤ã¾ãå®éã¯ã¢ã¤ãã«ç¶æ ãªã®ã«4ã¤ç®ã®Podã¯ã¹ã±ã¸ã¥ã¼ãªã³ã°ããã¦ããªãã¨ãããã¨ããã£ã¦ãã¾ããããã¯ã4ã¤ç®ã®Podãé ç½®ãããã¨ãã¦ããã¡ã¢ãªã®ç©ºããããã¥ãã§ã¹ãã§å®ç¾©ããã1.5GBãã確å®ã«ç¢ºä¿ã§ããã¹ãã¼ã¹ãNodeä¸ã«ãªããããã®ãããªç¶æ ã«ãªã£ã¦ãã¾ãã
$ kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% aks-nodepool1-12354740-1 30m 3% 259Mi 7% aks-nodepool1-12354740-2 133m 13% 507Mi 15%
ãªãã4ã¤ç®ã®Podã¯ã¹ã±ã¸ã¥ã¼ãªã³ã°ãããªãã£ãã®ã
Kubernetesã®Resource Requestsã¯ãPodã«å¯¾ãã¦æå®ãããªã½ã¼ã¹ã使ããããã«ä¿è¨¼ããä»çµã¿ã§ãã
ãã®å¤ã¯PodãNodeã«ã¹ã±ã¸ã¥ã¼ãªã³ã°ããã¨ãã«ä½¿ããã¾ããResource Requestsãæå®ããã³ã³ãããå«ãPodãä½æããã¨ãKubernetesã®ã¹ã±ã¸ã¥ã¼ã©ã¼ã¯Nodeãé¸æãã¦å®è¡ãã¾ãããã®éãåNodeã«ã¯ãåãªã½ã¼ã¹ã¿ã¤ãã®æ大容éããã£ã¦ãã¦ã¹ã±ã¸ã¥ã¼ã©ã¯ãåãªã½ã¼ã¹ã¿ã¤ãã«å¯¾ãã¦ãã¹ã±ã¸ã¥ã¼ã«ãããã³ã³ããã®ãªã½ã¼ã¹è¦æ±ã®åè¨ããã¼ãã®å®¹éãããå°ãªããã¨ããã§ãã¯ãã¾ãããã¨ãå®éã®ã¡ã¢ãªä½¿ç¨çã¯é常ã«ä½ãã¦ããã¹ã±ã¸ã¥ã¼ã©ã¯ãã§ãã¯ã失æããå ´åã¯Nodeã«Podãé ç½®ãã¾ããã
Managing Compute Resources for Containers - Kubernetes
ãªããã®Resource Requestsã®è¨å®ã¯Podã§ã¯ãªããã³ã³ããã«å¯¾ãã¦è¡ããã¾ããä»åæå®ããã¡ã¢ãªã¯ãã¤ãåä½ã§è¨å®ã§ããEï¼Pï¼Tï¼Gï¼Mï¼Kï¼Eiï¼Piï¼Tiï¼Giï¼Miï¼Kiï¼ã®ããããã使ç¨ãã¦ãã¡ã¢ãªãæ´æ°ã¾ãã¯åºå®å°æ°ç¹æ´æ°ã¨ãã¦æå®ãã¾ãã
ä»åã®ã±ã¼ã¹ã§ã¯ãå®éã®ã¡ã¢ãªããããã空ãã¦ããã«ããããããPodã¯é ç½®ããã¾ããã§ãããNodeã®ã¡ã¢ãªã®æ大容éã¯åãã£ã¦ããã®ã§ããããããåºç¤ã®æ¹å¼è¨è¨æ®µéã§Nodeã«ãã ããã ãã«Podãã¹ã±ã¸ã¥ã¼ãªã³ã°ããããã¨ãé¿ãããã¨ãã§ãã¾ãã
ãã ãããä»åã¯åããµã¤ãºã®Nodeã§æ¤è¨¼ãã¦ããã®ã§ãã¡ãã¨2å°ã§ã¹ã±ã¸ã¥ã¼ãªã³ã°ãããããªæ°ããã¾ããããªã«ãè¦è½ã¨ãã¦ããã®ãããããã¾ãããã¨ããããã§ãã½ã¼ã¹ã³ã¼ãããã¡ãã¨èªã¿ããã¨æãã¾ãã (çç±ããåç¥ã®äººãããã°ãããã¦ãã ãã)
ã追è¨ï¼ã¾ãã¹@ãã¤ã¯ãã½ããããããæãã¦ãããã¾ããï¼ãææéããNode1ã ãheapsterãåãã¦ããã¾ããããã£ããç解ãã¾ããã (以ä¸åæãã)ååã®Memory Requestsã«ã¤ãã¦ã§ãããçæ¹ã®Nodeã ãheapsterãåãã¦ãã¦é対称ãªã®ã§ããã®åã¡ã¢ãªã296Mi足ããªãã¦4ã¤ãã®Podãè¡åããå¾ ã£ã¡ãã£ã¦ããããheapsteråãèæ ®ãã¦Podãã¨ã®Requestã1.3Giã«ãããã4ã¤åãã¾ããã
ã¡ã¢ãªããããã使ãå¥ã¢ããªãéªéãã¦ããã¨ãããã¡ãã¨ã·ã¹ãã ãåä½ããã®ãï¼
Kubernetesã§ã¯ãResource Requestsãã§å®£è¨ããåã®ã¡ã¢ãªããã£ã¡ã確ä¿ãã¦Podãã¹ã±ã¸ã¥ã¼ãªã³ã°ãã¦ããã®ãåããã¾ããããã®Resource Requestsã¯ãå®éã®ã¡ã¢ãªã®ä½¿ç¨éã§ã¯ãªããã¯ã©ã¹ã¿ã«å²ãå½ã¦ããã¦ãããªã½ã¼ã¹ã«åºã¥ãã¦ãããã¨ããããã¾ãããããã§ã¯ãã¡ã¢ãªãªã½ã¼ã¹ãä½ã£ã¦ããã¯ã©ã¹ã¿ä¸ã«ããResource Requestsãã®å®£è¨ãªãã«ã¡ã¢ãªããããã使ãéè¯Podããããããããã¤ããããã©ããªãã§ããããï¼
ã¾ãå®é¨ã®ããã次ã®ãããªã¡ã¢ãªã1.0GBã¤ããDockerã¤ã¡ã¼ã¸ãä½ãã¾ããããããã«ããã¦mem-stressã¨ããååã®Dockerã¤ã¡ã¼ã¸ãä½ãã¾ãã
FROM ubuntu:latest RUN apt-get -y update && apt-get -y upgrade RUN apt-get -y install stress # 1ã¤ã®stressããã»ã¹ãèµ·åããããã»ã¹ããã1GBã®ã¡ã¢ãªã®è² è·ãããã CMD ["stress", "-m","1", "--vm-bytes" ,"1G","--vm-hang","0","-q"]
ãããDocker HubãAzure Container Registryãªã©ã®ã¬ã¸ã¹ããªã§å ¬éãã¾ãã
次ã«ãã®Dockerã¤ã¡ã¼ã¸ãåããPodãèµ·åããReplicaSetã®ããã¥ãã§ã¹ã(mem-stress.yaml)ãä½ãã¾ãããã®ä¾ã§ã¯ä¸è¨ã®Dockerfileããã«ããããimage: asashiho/mem-stress:latestãããçæããã³ã³ããã1ã¤å«ã¾ããPodããã³ãã¬ã¼ãã§å®ç¾©ãããã®Podã2ã¤åãããããreplicas: 5ãã¨å®ç¾©ãã¦ãã¾ããã¯ã©ã¹ã¿ã«ã¯çè«ä¸åNodeã«3.5GBãã¤ã¡ã¢ãªãããã¾ãã®ã§ããã£ãã5ã¤ãããã®éè¯Podãèµ·åãã¦ã¿ã¾ãã
ãã®ããã¥ãã§ã¹ãã®ãã¤ã³ãã¯ãä¸ã®Nginxã®Podã¨ç°ãªãã¡ã¢ãªã«å¯¾ãããªã½ã¼ã¹è¦æ±(Resource Request)ãæå®ãã¦ããªããã¨ã§ãã ãã®ã³ã³ãããä½ã£ãå¼µæ¬äººã§ããç§ã¯ã¢ããªãã¡ã¢ãªã1.0G使ããã¨ãç¥ã£ã¦ãã¾ãããKubernetes ã¯ã©ãã ããªã½ã¼ã¹ã使ãã³ã³ãããå ¥ã£ãPodãªã®ãä¸åç¥ããªãã®ã§ãã
apiVersion: apps/v1 kind: ReplicaSet metadata: name: mem-exp spec: replicas: 5 selector: matchLabels: app: mem-stress-temp template: metadata: labels: app: mem-stress-temp spec: containers: - name: pod-sample image: asashiho/mem-stress:latest
次ã®ã³ãã³ããå®è¡ããã¨ãæ°ãã1Gã®ã¡ã¢ãªã使ãPodã5ã¤åããããããã¯ãã§ã
$ kubectl create -f mem-stress.yaml replicaset.apps "mem-exp" created
ãªãã»ã©ã
ãmem-exp-xxxãã®Podã¯4ã¤ããèµ·åããããã¡ããããã®1ã¤ã¯CrashLoopBackOffâErrorã§åèµ·åãç¹°ãè¿ãã¦ãã¾ãã
$ kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE mem-exp-6dcgh 0/1 CrashLoopBackOff 2 1m 10.244.3.188 aks-nodepool1-12354740-1 mem-exp-dnwjk 1/1 Running 1 1m 10.244.3.186 aks-nodepool1-12354740-1 mem-exp-grxvz 1/1 Running 0 1m 10.244.2.155 aks-nodepool1-12354740-2 mem-exp-v5j29 1/1 Running 0 1m 10.244.2.154 aks-nodepool1-12354740-2 mem-exp-x9gxl 1/1 Running 2 1m 10.244.3.187 aks-nodepool1-12354740-1 reqest-exp-9kztw 1/1 Running 0 26m 10.244.2.153 aks-nodepool1-12354740-2 reqest-exp-b4t8h 1/1 Running 0 26m 10.244.3.184 aks-nodepool1-12354740-1 reqest-exp-fgrpn 0/1 Pending 0 13m <none> <none> reqest-exp-wzg7t 1/1 Running 0 18m 10.244.3.185 aks-nodepool1-12354740-1
çµµã«ããã¨æ¬¡ã®æãã§ãã
Podã®ãã°ã確èªããã¨ã¨ã©ã¼ãåºã¦ããã®ãåããã¾ãã
$ kubectl logs mem-exp-6dcgh stress: FAIL: [1] (415) <-- worker 5 got signal 9 stress: FAIL: [1] (421) kill error: No such process stress: FAIL: [1] (451) failed run completed in 39s
ã·ã¹ãã å ¨ä½ã®ã¡ã¢ãªä½¿ç¨éã¯ãã¡ãã¨ä¸ãã£ã¦ãã¾ãã
$ kubectl top node NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% aks-nodepool1-12354740-1 33m 3% 2275Mi 68% aks-nodepool1-12354740-2 127m 12% 2573Mi 77%
ãããã40åã»ã©æ¾ç½®ãã¾ãããã®éã«å¤é£¯ã®ããããã
$ kubectl get po -o wide NAME READY STATUS RESTARTS AGE IP NODE mem-exp-6dcgh 0/1 CrashLoopBackOff 11 44m 10.244.3.188 aks-nodepool1-12354740-1 mem-exp-dnwjk 1/1 Running 6 44m 10.244.3.186 aks-nodepool1-12354740-1 mem-exp-grxvz 1/1 Running 0 44m 10.244.2.155 aks-nodepool1-12354740-2 mem-exp-v5j29 1/1 Running 0 44m 10.244.2.154 aks-nodepool1-12354740-2 mem-exp-x9gxl 1/1 Running 6 44m 10.244.3.187 aks-nodepool1-12354740-1 reqest-exp-9kztw 1/1 Running 0 1h 10.244.2.153 aks-nodepool1-12354740-2 reqest-exp-b4t8h 1/1 Running 0 1h 10.244.3.184 aks-nodepool1-12354740-1 reqest-exp-fgrpn 0/1 Pending 0 56m <none> <none> reqest-exp-wzg7t 1/1 Running 0 1h 10.244.3.185 aks-nodepool1-12354740-1
ä½ãèµ·ãã£ã¦ãããããã¼ãè¦ã¦ã¿ã¾ãã
1ï¼Node1ã«ã¹ã±ã¸ã¥ã¼ãªã³ã°ãããéè¯Pod3ã¤
ãmem-exp-6dcghãã¨ãmem-exp-dnwjkãã¨ãmem-exp-x9gxlãã¯Podã稼åããããã¦ãå®éã®ã¡ã¢ãªã足ããªãããããã¡1ã¤ã®ãããããåèµ·åãç¹°ãè¿ããCrashLoopBackOffãã®ã¹ãã¼ã¿ã¹ã«ãªã£ã¦ãã¾ãã
2ï¼Node2ã«ã¹ã±ã¸ã¥ã¼ãªã³ã°ãããéè¯Pod2ã¤
ãmem-exp-grxvzãã¨ãmem-exp-v5j29ãã¯åèµ·åããããã¨ããªãé 調ã«ç¨¼åãã¦ãã¾ãã
3.ããã¥ãã§ã¹ãã§ã¡ã¢ãªã®ä½¿ç¨éãããããã宣è¨ããPod4ã¤
ãreqest-exp-9kztwãã¯åèµ·åããããã¨ãªã3ã¤ã稼åä¸ãããã¦ç©ºã容éå¾ ã¡ãreqest-exp-fgrpnãã¯Penddingã§ãè¡åããå¾ ã£ã¦ãããã¨åããã¾ãã
ãªãã»ã©ï¼
ã©ã®ãããªããã¿ã§Podãã¹ã±ã¸ã¥ã¼ãªã³ã°ãããã®ã
Kubernetesã®Resource Requestsã§ã¡ã¢ãªãè¨è¿°ããªãã¨ããPodããã¤ã¡ã¢ãªä¸è¶³ã§çµäºããã¦ãæ§ããªããã¨ããæå³ã«ãªãã¾ãããªã«ãããããã¦ãããã¨ããã¨ããããã
Pod QoSã«ã¤ãã¦
Kubernetesã¯Podã«å¯¾ãã¦3ã¤ã®Quality of Service (QoS)ã¯ã©ã¹ãæä¾ãã¦ãã¾ãããã®QoSã¯ãä»åæ¤è¨¼ããResource Requestsã¨ãªã½ã¼ã¹ã®ä¸éã決ããResource Limitsã®2ã¤ãã次ã®æ¡ä»¶ã§classã決ã¾ãã¾ãã
BestEffort
podå ã®ã©ã®ã³ã³ããã«ãResource Requestsã¨Resource Limitsãè¨å®ããã¦ããªãæã«è¨å®ããã
Burstable
BestEffortãGuaranteedãè¨å®ããã¦ããªãã¨ãã«è¨å®ããã
Guaranteed
CPUã¨ã¡ã¢ãªã®ä¸¡æ¹ã«ãResouce Requestsã¨Resource Limitsãã»ããããã¦ãããã¨ï¼Podå ã®ããããã®ã³ã³ããã«ã»ããããã¦ãããã¨ï¼Resouce Requestsã¨Resource Limitsã®å¤ãããããåãã§ãããã¨ãã§è¨å®ããã
ãã®QoSã®ç¢ºèªã¯ãkubectl describeã§ã§ãã¾ããä¾ãã°ãmem-exp-96vdnãã®QoSã確èªããã¨ãã¯æ¬¡ã®ã³ãã³ãã«ãªãã¾ãã
$ kubectl describe pod mem-exp-96vdn |grep QoS
QoS Class: BestEffort
ã¡ãªã¿ã«podå ã«è¤æ°ã®ã³ã³ãããåå¨ããå ´åã¯ã¾ãåã³ã³ããã«ä¸è¨ã®ã«ã¼ã«ã«å¾ã£ã¦QoSãå²ãå½ã¦ã¾ããå ¨ã¦ã®ã³ã³ãããBestEffortãªãPodã®QoSã¯BestEffortã¨ãªããå ¨ã¦ã®ã³ã³ãããGuaranteedãªãPodã®QoSã¯Guaranteedã«ãªãã¨ã®ãã¨ã§ããããã¦ããããã®æ¡ä»¶ã«ãå½ã¦ã¯ã¾ããªãå ´åBestEffortã«ãªãã¨ã®ãã¨ã§ãã
ä»åã®æ¤è¨¼ã§ã¯ã1.5Gã®Resouce Requestsãæå®ããPodã®QoSã¯ãBurstableãããªã«ãæå®ããªãéè¯Podã¯ãBestEffortããè¨å®ããã¦ãã¾ããã
Nodeã®ã¡ã¢ãªä¸éã«éããå ´åãã©ããã£ãå¤æã§killãããã
Kubernetesã¯ã©ã¹ã¿ã¯éæ³ã®ç®±ã§ã¯ãªãã®ã§ãå®éã®ã¡ã¢ãªãè¶ ããã¢ããªã¯å®è¡ã§ãã¾ãããä»åã®æ¤è¨¼ã®Node1ã§ãªã«ãããã¦ãããã¨ããã¨ããã
Kubernetesã§ã¯ãQoSã«å¾ã£ã¦ã©ã®Podã®ã³ã³ãããkillãããã決ã¾ãã¾ããæãåªå 度ãä½ãæåã«killãããã®ã¯BestEffortãã¤ãã«ã¯Burstableãæå¾ã«Guaranteedãkillããã¾ãããã®Guaranteedã¯system processãã¡ã¢ãªãå¿ è¦ã¨ããå ´åã®ã¿killããã¾ãã
ããåãQoSã¯ã©ã¹ã ã£ãå ´åãOutOfMemory (OOM) scoreã®ãã£ã¦ã©ã®ããã»ã¹ãkillããããæ¯è¼ãã¦æ±ºãã¦ããããã§ãã決ãã¦ãé©å½ã«killãã¦ããããã§ã¯ãªããKubernetesã¯ã¡ããã¨å¿åº¦ããªããkillãã¦ãã¾ãã
ä»åã®æ¤è¨¼ã§ã¯ãã¡ã¢ãªã足ãã¦ããªãNode0ä¸ã§ãåªå 度ã®ä½ãéè¯Podãkillãããåèµ·åããã¦ãã¾ããããã®åèµ·åã®ã«ã¼ã«ããå®ã¯ã¨ã¦ãèå³æ·±ãå¦çæ¹å¼ã§åãã¦ãã¾ãããã¡ãã¯å¾æ¥å¥ããã°ã§ã
ã¾ã¨ã
Kubernetesã§ã¯ãã¢ããªã±ã¼ã·ã§ã³(ã³ã³ãã)ã使ãã¡ã¢ãªã«å¶éããããã¨ãã¯ã©ã¹ã¿ä¸ã®çè«çãªãªã½ã¼ã¹ãé åããã¦Podãã¹ã±ã¸ã¥ã¼ãªã³ã°ããããã¨ããããã¾ãããã¾ããPodã®åªå 度ãé«ããªããã¯ã©ã¹ã¿ã®å®éã®ä½¿ç¨ã¡ã¢ãªãå¤ããªã£ãã¨ãããkillãããå¯è½æ§ãä½ããªããã¨ãåããã¾ããã
æ¤è¨¼ãã¦ãã¾ããããServiveãIngressã§ãµã¼ãã¹ãã£ã¹ã«ããªã¼ãå®ç¾©ãã¦ããã°ãä»åã®ã±ã¼ã¹ã§ã¯ããããã®Podã¯åãã¦ããã¯ãã§ãã®ã§ãã¯ã©ã¹ã¿å¤é¨ããã®ã¢ã¯ã»ã¹ãã¿ã¦ã¿ãã¨ããµã¼ãã¹ãæ£ããåä½ãã¦ããç¶æ ãç¶æã§ãã¦ããã¯ãã§ãã
ãããã
ãªããä»åã¯è¨å®ãã¾ããã§ãããã¡ã¢ãªã«Request Limitsãä¸ããã¨ãã®åãããCPUã«é¢ãã¦ãå¾æ¥ã²ã¾ãè¦ã¤ãã¦æ¤è¨¼ãã¦ã¾ã¨ãã¦ã¿ããã¨æãã¾ãã
ã¨ããããã§ãã¯ã©ã¦ãã®Kubernetesããã¼ã¸ããµã¼ãã¹ã使ãã¨ãã¯ã©ã¹ã¿ãã®ãã®ã®æ§ç¯ãMasterã®ã¡ã³ãã¯ãä»»ãã§ãã¾ãã®ã§ãåæ£åºç¤ã®ããã©ããã¿ãããã¬ãã«ã®ã¤ã³ãã©ã¨ã³ã¸ãã¢ãããªãã¦ããå¿«é©ãªãããã¤ç°å¢ãä½ãã¾ãããä¸æ¹ãããç¥èã¨ãã¦ã®ã¤ã³ãã©æè¡ã¯ãããç¨åº¦åå¼·ãã¦ãããªãã¨ãé害æã«ä¸ã§ãªã«ãããã£ã¦ããã®ããã ãã§ãªãé©åãªåºç¤æ¹å¼è¨è¨ãã§ããªããã¨ãããã¨ã«ããªãã¾ããé£ããã§ããåå¼·ã ããã
ããã