k8s-webhook-timeout

Kubernetes Admission Webhook 超时的定位

现象

创建/更新资源报 failed calling webhook ... context deadline exceeded、connection refused 或 x509 错误,API 请求被拒绝或明显变慢。

快速定位

kubectl get validatingwebhookconfigurations
kubectl get mutatingwebhookconfigurations
kubectl describe validatingwebhookconfiguration <name>
kubectl get svc,endpoints -n <webhook-ns>
kubectl logs -n <webhook-ns> <pod> --tail=100

常见根因

  1. webhook Pod 未运行或全部不可用。
  2. Service selector/端口错误,Endpoints 为空。
  3. TLS 证书/CA 不匹配,apiserver 无法验证 webhook。
  4. 超时时间太短,webhook 处理慢。
  5. 网络策略/防火墙阻断 apiserver 到 webhook。
  6. failurePolicy: Fail 让 webhook 故障放大为 API 拒绝。

修复

相关命令