探针 & 健康检查

三种 Probe

k8s 存在三种探针来实现健康检查

  • Readiness Probe

  • Liveness Probe

  • Startup Probe

Readiness Probe

Readiness Probe 用于展示 Pod 的 Ready 状态

如果 Pod Ready 不为 true,service 不会路由流量到 pod 上

Liveness Probe

Liveness Probe 与 Readiness Probe 不同点在于,如果 liveness probe 未通过,会直接重启 pod(相比之下,readiness probe 只会修改 ready 状态)

Startup Probe

Readiness Probe 和 Liveness Probe 更多的是用于判断正在运行中的 pod 的健康状态;虽然可以利用 initialDelaySeconds 来做到容忍慢启动,但这也会导致 pod 的成功/失败状态被延迟

Startup Probe 专用于处理这种情况,当 Startup Probe 不通过时,Readiness Probe 和 Liveness Probe 不会运行