Q7
以下のPodをデプロイし、ログをliveness-exec.logに保存してファイルの内容を確認せよ。
※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
A7
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 15s kubeuser@master01:~$ kubectl logs liveness-exec > ./livensss-exec.log kubeuser@master01:~$ cat livensss-exec.log
おまけ:削除
kubeuser@master01:~$ rm livensss-exec.log 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
参照本家サイト
Configure Liveness, Readiness and Startup Probes
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/