如果一个吊舱活性探针失败,而一个吊舱准备探测器池失败了,会发生什么情况?
发布于 2020-11-13 22:40:02
活性探针和准备性探针之间几乎没有什么区别。但主要的区别之一是,一个失败的准备探测器从池中移除了吊舱,但不要重新启动。另一方面,一个失败的活性探针从池中移除吊舱并重新启动吊舱。
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness-vs-readiness
name: liveness-vs-readiness-exec
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; touch /tmp/liveness; sleep 999999
livenessProbe:
exec:
command:
- cat
- /tmp/liveness
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5让我们创建这个吊舱并展示它的作用: oc创建-f活性-readiness.yaml. this
当我们在舱内执行动作时,荚状态的输出。名称前面的数字与吊舱内所做的操作相互响应:
oc get pods -w
NAME READY STATUS RESTARTS AGE
[1] liveness-vs-readiness-exec 1/1 Running 0 44s
[2] liveness-vs-readiness-exec 0/1 Running 0 1m
[3] liveness-vs-readiness-exec 1/1 Running 0 2m
[4] liveness-vs-readiness-exec 0/1 Running 1 3m
liveness-vs-readiness-exec 1/1 Running 1 3m容器内的操作:
[root@default ~]# oc rsh liveness-vs-readiness-exec
# [1] we rsh to the pod and do nothing. Pod is healthy and live
# [2] we remove health probe file and see that pod goes to notReady state
# rm /tmp/healthy
#
# [3] we create health file. Pod goes into ready state without restart
# touch /tmp/healthy
#
# [4] we remove liveness file. Pod goes into notready state and is restarted just after that
# rm /tmp/liveness
# command terminated with exit code 137https://stackoverflow.com/questions/64828951
复制相似问题