4. Pod生命周期管理
· 阅读需 2 分钟
4.1 Liveness command
通过命令行实现Liveness检查
# 编写Yaml
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: radial/busyboxplus
imagePullPolicy: IfNotPresent
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 60; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
# 验证方法
kubectl exec -it liveness-exec -- ls /tmp
kubectl get pod