livenessProbe (存活检查) # 如果检查失败,将杀死容器,根据Pod的restartPolicy来操作
readinessProbe(就绪检查) # 如果检查失败,kubernetes会把Pod从service endpoints中剔除
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: busybox
args:
- /bin/sh
- -c # Probe支持一下三种检查方法;
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy ## httpGet
livenessProbe: ### 发送HTTP请求, 返回200-400范围状态码为成功。
exec: ## exec
command:
- cat ### 执行shell命令返回状态码为0为成功
- /tmp/healthy
initialDelaySeconds: 5 ## tcpSocket
periodSeconds: 5 ### 发起TCP Socket建立成功
根据上一步的执行成功否的状态码进行健康检查