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
initialDelaySeconds 或 startupProbe 不足。curl/wget,exec 探针本身失败。startupProbe,并放宽 failureThreshold。k8s 分支的 deployment 页面 — 探针配置合上页面,先回答,再展开对照。
curl/wget 时怎么处理?kubectl describe pod 看 Events 中哪类探针失败,用 kubectl logs --previous 看上次日志,用 kubectl get pod -o yaml 检查 Probe 配置,并 exec 进容器手动请求探针地址。startupProbe 并放宽 failureThreshold;探针命令改用容器内确实存在的工具,或改用 HTTP/TCP 探针。
小程序版
微信扫码,随时查命令