K8S - livenessProve - 存活性探测
livenessProbe: 是指容器是否正在运行。如果存活性探测失败,则kubelete会杀死容器,并且容器受重启策略的影响。如果容器不提供存活性探针,则默认状态为Success。[root@k8s-master01 k8s-test]# cat liveness.yamlapiVersion: v1kind: Podmetadata:name: liveness-exec-po...
·
livenessProbe: 是指容器是否正在运行。如果存活性探测失败,则kubelete会杀死容器,并且容器受重启策略的影响。如果容器不提供存活性探针,则默认状态为Success。
[root@k8s-master01 k8s-test]# cat liveness.yaml
apiVersion: v1
kind: Pod
metadata:
name: liveness-exec-pod
namespace: default
spec:
containers:
- name: liveness-exec-container
image: kone.com/library/busybox
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c", "touch /tmp/live-test; sleep 60; rm -f /tmp/live-test; sleep 3600"]
livenessProbe:
exec:
command: ["test", "-e", "/tmp/live-test"]
initialDelaySeconds: 1
periodSeconds: 3
[root@k8s-master01 k8s-test]#
kubectl create -f liveness.yaml
创建容器后
kubectl get pod -w
查看容器liveness-exec-pod在不断的重启
[root@k8s-master01 k8s-test]# kubectl get pod -w
NAME READY STATUS RESTARTS AGE
liveness-exec-pod 1/1 Running 1 2m51s
liveness-exec-pod 1/1 Running 2 3m20s
liveness-exec-pod 1/1 Running 3 4m59s
liveness-exec-pod 1/1 Running 4 6m38s
liveness-exec-pod 1/1 Running 5 8m17s
liveness-exec-pod 1/1 Running 6 9m56s
更多推荐
已为社区贡献19条内容
所有评论(0)