Kubernetes 存活检查与就绪检查
Kubernetes 存活检查与就绪检查
有
存活检查(livenessProbe)没有就绪检查(readinessProbe)滚动更新过程中会出现502 Bad Gateway
存活检查
livenessProbe:用于判断容器是否存活(running状态),如果探针探测到容器不健康,则kubelet杀掉该容器,并根据容器的重启策略做相应的处理。如果一个容器不包含livenessProbe探针,则kubelet认为该容器的存活检查探针返回的值永远是Success。
配置方式
方式一:HTTP
containers:
- name: xxx
image: xxx
# 存活检查
livenessProbe:
httpGet:
scheme: HTTP # 协议
path: /actuator/health # 路径
port: 8080 # 端口
initialDelaySeconds: 30 # 延迟探测时间(秒) 【 在k8s第一次探测前等待秒 】
periodSeconds: 10 # 执行探测频率(秒) 【 每隔秒执行一次 】
timeoutSeconds: 1 # 超时时间
successThreshold: 1 # 健康阀值
failureThreshold: 3 # 不健康阀值
方式二:TCP
containers:
- name: xxx
image: xxx
# 存活检查
livenessProbe:
tcpSocket: # TCP
port: 8090 # 端口
initialDelaySeconds: 50 # 延迟探测时间(秒) 【 在k8s第一次探测前等待秒 】
periodSeconds: 10 # 执行探测频率(秒) 【 每隔秒执行一次 】
timeoutSeconds: 1 # 超时时间
successThreshold: 1 # 健康阀值
failureThreshold: 3 # 不健康阀值
就绪检查
readinessProbe:用于判断容器是否启动完成(ready状态),可以接收请求。如果探针检测到失败,则Pod的状态被修改。Endpoint Controller将从Service的Endpoint中删除包含该容器所在Pod的Endpoint。
配置方式
containers:
- name: xxx
image: xxx
# 就绪检查
readinessProbe:
httpGet:
scheme: HTTP # 协议
path: /actuator/health # 路径
port: 8080 # 端口
initialDelaySeconds: 30 # 延迟探测时间(秒)【 在k8s第一次探测前等待秒 】
periodSeconds: 2 # 执行探测频率(秒) 【 每隔秒执行一次 】
timeoutSeconds: 1 # 超时时间
successThreshold: 1 # 健康阀值
failureThreshold: 3 # 不健康阀值

浙公网安备 33010602011771号