probe-failed

Kubernetes 探针失败的定位与修复

现象

Pod 反复重启,Events 显示 Liveness probe failed、Readiness probe failed 或 Startup probe failed。服务可能实际已启动,但探针判断失败。

快速定位

kubectl describe pod <pod> -n <ns>
kubectl logs <pod> -n <ns> --previous
kubectl get pod <pod> -n <ns> -o yaml | grep -A10 -E 'Probe:'
kubectl exec -it <pod> -n <ns> -- sh

在容器内手动验证:

curl -v http://127.0.0.1:<port>/healthz
wget -qO- http://127.0.0.1:<port>/ready

常见根因

  1. 探针路径、端口或协议配置错误。
  2. 应用启动慢,initialDelaySeconds 或 startupProbe 不足。
  3. 依赖服务(数据库、缓存)未就绪,readiness 一直失败。
  4. 探针超时太短,或应用在高负载下响应慢。
  5. liveness 和 readiness 用了同一个重接口,导致误杀。
  6. 容器内没有 curl/wget,exec 探针本身失败。

修复

相关命令