Q6
①以下のLiveness Probeを実行して挙動を確認せよ。
※https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/exec-liveness.yamlからダウンロード可
apiVersion: v1 kind: Pod metadata: labels: test: liveness name: liveness-exec spec: containers: - name: liveness image: registry.k8s.io/busybox args: - /bin/sh - -c - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600 livenessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 5 periodSeconds: 5
②以下のLiveness Probeを実行して挙動を確認せよ。
※https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/http-liveness.yamlからダウンロード可
apiVersion: v1 kind: Pod metadata: labels: test: liveness name: liveness-http spec: containers: - name: liveness image: registry.k8s.io/liveness args: - /server livenessProbe: httpGet: path: /healthz port: 8080 httpHeaders: - name: Custom-Header value: Awesome initialDelaySeconds: 3 periodSeconds: 3
③以下のLiveness Probeを実行して挙動を確認せよ。
※https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/tcp-liveness-readiness.yamlからダウンロード可
apiVersion: v1 kind: Pod metadata: name: goproxy labels: app: goproxy spec: containers: - name: goproxy image: registry.k8s.io/goproxy:0.1 ports: - containerPort: 8080 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 15 periodSeconds: 10 livenessProbe: tcpSocket: port: 8080 initialDelaySeconds: 15 periodSeconds: 10
A6
①以下のLiveness Probeを実行して挙動を確認せよ。
kubeuser@master01:~$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/exec-liveness.yaml pod/liveness-exec created kubeuser@master01:~$ kubectl get pods liveness-exec NAME READY STATUS RESTARTS AGE liveness-exec 2/2 Running 0 62s kubeuser@master01:~$ kubectl events pods liveness-exec LAST SEEN TYPE REASON OBJECT MESSAGE 5m24s (x227 over 19h) Warning FailedScheduling Pod/loki-0 0/4 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/4 nodes are available: 4 No preemption victims found for incoming pod.. 4m4s (x8482 over 35h) Normal FailedBinding PersistentVolumeClaim/storage-loki-0 no persistent volumes available for this claim and no storage class is set 2m49s Normal Scheduled Pod/liveness-exec Successfully assigned default/liveness-exec to worker02 2m24s Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 2m22s Normal Created Pod/liveness-exec Created container istio-init 2m22s Normal Started Pod/liveness-exec Started container istio-init 2m9s Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 2m9s Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 3.942127479s (3.942149594s including waiting) 2m8s Normal Created Pod/liveness-exec Created container istio-proxy 2m8s Normal Started Pod/liveness-exec Started container istio-proxy 2m (x6 over 2m7s) Warning Unhealthy Pod/liveness-exec Readiness probe failed: Get "http://10.0.30.77:15021/healthz/ready": dial tcp 10.0.30.77:15021: connect: connection refused 116s (x421 over 35h) Normal CIDRNotAvailable Node/worker02 Node worker02 status is now: CIDRNotAvailable 88s Normal Killing Pod/liveness-exec Container liveness failed liveness probe, will be restarted 57s (x2 over 2m13s) Normal Pulling Pod/liveness-exec Pulling image "registry.k8s.io/busybox" 56s Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 1.43090061s (1.43122917s including waiting) 55s (x2 over 2m9s) Normal Started Pod/liveness-exec Started container liveness 55s (x2 over 2m9s) Normal Created Pod/liveness-exec Created container liveness 31s (x418 over 35h) Normal CIDRNotAvailable Node/worker01 Node worker01 status is now: CIDRNotAvailable 23s (x4 over 98s) Warning Unhealthy Pod/liveness-exec Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
②以下のLiveness Probeを実行して挙動を確認せよ。
kubeuser@master01:~$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/http-liveness.yaml pod/liveness-http created kubeuser@master01:~$ kubectl get pods liveness-http NAME READY STATUS RESTARTS AGE liveness-http 2/2 Running 1 (19s ago) 51s kubeuser@master01:~$ kubectl events pods liveness-http LAST SEEN TYPE REASON OBJECT MESSAGE 11m (x227 over 19h) Warning FailedScheduling Pod/loki-0 0/4 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/4 nodes are available: 4 No preemption victims found for incoming pod.. 8m54s Normal Scheduled Pod/liveness-exec Successfully assigned default/liveness-exec to worker02 8m29s Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 8m27s Normal Created Pod/liveness-exec Created container istio-init 8m27s Normal Started Pod/liveness-exec Started container istio-init 8m14s Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 3.942127479s (3.942149594s including waiting) 8m14s Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 8m13s Normal Created Pod/liveness-exec Created container istio-proxy 8m13s Normal Started Pod/liveness-exec Started container istio-proxy 8m5s (x6 over 8m12s) Warning Unhealthy Pod/liveness-exec Readiness probe failed: Get "http://10.0.30.77:15021/healthz/ready": dial tcp 10.0.30.77:15021: connect: connection refused 7m33s Normal Killing Pod/liveness-exec Container liveness failed liveness probe, will be restarted 7m2s (x2 over 8m18s) Normal Pulling Pod/liveness-exec Pulling image "registry.k8s.io/busybox" 7m1s Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 1.43090061s (1.43122917s including waiting) 7m (x2 over 8m14s) Normal Started Pod/liveness-exec Started container liveness 7m (x2 over 8m14s) Normal Created Pod/liveness-exec Created container liveness 6m28s (x4 over 7m43s) Warning Unhealthy Pod/liveness-exec Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory 2m4s Normal Scheduled Pod/liveness-http Successfully assigned default/liveness-http to worker02 2m2s Normal Pulled Pod/liveness-http Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 2m1s Normal Created Pod/liveness-http Created container istio-init 2m Normal Started Pod/liveness-http Started container istio-init 114s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 3.101228405s (3.101244264s including waiting) 113s Normal Pulled Pod/liveness-http Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 112s Normal Created Pod/liveness-http Created container istio-proxy 112s Normal Started Pod/liveness-http Started container istio-proxy 93s (x423 over 35h) Normal CIDRNotAvailable Node/worker02 Node worker02 status is now: CIDRNotAvailable 92s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 1.963979177s (1.964314532s including waiting) 91s (x2 over 113s) Normal Started Pod/liveness-http Started container liveness 89s (x419 over 35h) Normal CIDRNotAvailable Node/worker01 Node worker01 status is now: CIDRNotAvailable 73s (x2 over 94s) Normal Killing Pod/liveness-http Container liveness failed liveness probe, will be restarted 73s (x6 over 100s) Warning Unhealthy Pod/liveness-http Liveness probe failed: HTTP probe failed with statuscode: 500 73s (x3 over 117s) Normal Pulling Pod/liveness-http Pulling image "registry.k8s.io/liveness" 71s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 1.567516706s (1.567648861s including waiting) 71s (x3 over 113s) Normal Created Pod/liveness-http Created container liveness 9s (x8522 over 35h) Normal FailedBinding PersistentVolumeClaim/storage-loki-0 no persistent volumes available for this claim and no storage class is set
③以下のLiveness Probeを実行して挙動を確認せよ。
kubeuser@master01:~$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/probe/tcp-liveness-readiness.yaml pod/goproxy created kubeuser@master01:~$ kubectl get pods goproxy NAME READY STATUS RESTARTS AGE goproxy 2/2 Running 0 79s kubeuser@master01:~$ kubectl events pods goproxy LAST SEEN TYPE REASON OBJECT MESSAGE 17m (x227 over 19h) Warning FailedScheduling Pod/loki-0 0/4 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/4 nodes are available: 4 No preemption victims found for incoming pod.. 14m Normal Scheduled Pod/liveness-exec Successfully assigned default/liveness-exec to worker02 14m Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 14m Normal Started Pod/liveness-exec Started container istio-init 14m Normal Created Pod/liveness-exec Created container istio-init 14m Normal Pulled Pod/liveness-exec Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 14m Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 3.942127479s (3.942149594s including waiting) 14m Normal Created Pod/liveness-exec Created container istio-proxy 14m Normal Started Pod/liveness-exec Started container istio-proxy 14m (x6 over 14m) Warning Unhealthy Pod/liveness-exec Readiness probe failed: Get "http://10.0.30.77:15021/healthz/ready": dial tcp 10.0.30.77:15021: connect: connection refused 13m Normal Killing Pod/liveness-exec Container liveness failed liveness probe, will be restarted 13m (x2 over 14m) Normal Pulling Pod/liveness-exec Pulling image "registry.k8s.io/busybox" 13m Normal Pulled Pod/liveness-exec Successfully pulled image "registry.k8s.io/busybox" in 1.43090061s (1.43122917s including waiting) 13m (x2 over 14m) Normal Created Pod/liveness-exec Created container liveness 13m (x2 over 14m) Normal Started Pod/liveness-exec Started container liveness 12m (x4 over 13m) Warning Unhealthy Pod/liveness-exec Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory 8m5s Normal Scheduled Pod/liveness-http Successfully assigned default/liveness-http to worker02 8m3s Normal Pulled Pod/liveness-http Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 8m2s Normal Created Pod/liveness-http Created container istio-init 8m1s Normal Started Pod/liveness-http Started container istio-init 7m55s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 3.101228405s (3.101244264s including waiting) 7m54s Normal Pulled Pod/liveness-http Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 7m53s Normal Created Pod/liveness-http Created container istio-proxy 7m53s Normal Started Pod/liveness-http Started container istio-proxy 7m33s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 1.963979177s (1.964314532s including waiting) 7m32s (x2 over 7m54s) Normal Started Pod/liveness-http Started container liveness 7m14s (x3 over 7m58s) Normal Pulling Pod/liveness-http Pulling image "registry.k8s.io/liveness" 7m14s (x2 over 7m35s) Normal Killing Pod/liveness-http Container liveness failed liveness probe, will be restarted 7m14s (x6 over 7m41s) Warning Unhealthy Pod/liveness-http Liveness probe failed: HTTP probe failed with statuscode: 500 7m12s (x3 over 7m54s) Normal Created Pod/liveness-http Created container liveness 7m12s Normal Pulled Pod/liveness-http Successfully pulled image "registry.k8s.io/liveness" in 1.567516706s (1.567648861s including waiting) 2m24s (x420 over 35h) Normal CIDRNotAvailable Node/worker01 Node worker01 status is now: CIDRNotAvailable 2m Normal Scheduled Pod/goproxy Successfully assigned default/goproxy to worker02 117s Normal Pulled Pod/goproxy Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 117s Normal Created Pod/goproxy Created container istio-init 116s Normal Started Pod/goproxy Started container istio-init 115s Normal Pulling Pod/goproxy Pulling image "registry.k8s.io/goproxy:0.1" 112s Normal Pulled Pod/goproxy Successfully pulled image "registry.k8s.io/goproxy:0.1" in 3.542853363s (3.542899255s including waiting) 111s Normal Created Pod/goproxy Created container goproxy 111s Normal Started Pod/goproxy Started container goproxy 111s Normal Pulled Pod/goproxy Container image "docker.io/istio/proxyv2:1.19.3" already present on machine 111s Normal Created Pod/goproxy Created container istio-proxy 110s Warning Unhealthy Pod/goproxy Readiness probe failed: Get "http://10.0.30.80:15021/healthz/ready": dial tcp 10.0.30.80:15021: connect: connection refused 110s Normal Started Pod/goproxy Started container istio-proxy 96s (x425 over 35h) Normal CIDRNotAvailable Node/worker02 Node worker02 status is now: CIDRNotAvailable 70s (x8542 over 35h) Normal FailedBinding PersistentVolumeClaim/storage-loki-0 no persistent volumes available for this claim and no storage class is set
おまけ:削除
①
kubeuser@master01:~$ kubectl delete pods liveness-exec --force Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. pod "liveness-exec" force deleted
②
kubeuser@master01:~$ kubectl delete pods liveness-http --force Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. pod "liveness-http" force deleted
③
kubeuser@master01:~$ kubectl delete pods goproxy --force Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. pod "goproxy" force deleted
参照本家サイト
Configure Liveness, Readiness and Startup Probes
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/