解决 Istio 报错 Sidecar injection failed 边车自动注入失败修复
排查 Kubernetes 创建 Pod 报 Internal error: failed calling webhook "sidecar-injector.istio.io",分析 istiod 状态与标签配置。
问题现象
在注入了 Istio 的命名空间中部署 Pod 时创建失败:
Error from server (InternalError): Internal error occurred: failed calling webhook "sidecar-injector.istio.io": Post "https://istiod.istio-system.svc:443/inject?timeout=10s": dial tcp 10.96.0.25:443: connect: connection refused
触发根因
istiod控制面 Pod 宕机、升级中或未成功启动;- MutatingWebhookConfiguration 的
failurePolicy设置为了Fail,在控制面短暂波动时将整个集群的 Pod 创建操作锁死。
解决步骤
检查并恢复 istiod 控制面 Pod
定位故障并确保副本处于 Running 状态:
kubectl get pods -n istio-system -l app=istiod
kubectl logs -n istio-system deploy/istiod
应急场景下临时将 Webhook failurePolicy 改为 Ignore
允许业务 Pod 先行以无代理模式正常拉起:
kubectl patch mutatingwebhookconfiguration istio-sidecar-injector \
--type='json' -p='[{"op": "replace", "path": "/webhooks/0/failurePolicy", "value": "Ignore"}]'
验证确认
重新拉起应用 Pod:
istio-proxy 边车容器秒级注入成功,Pod 状态显示为完整的 2/2 Running。


