Interview Prep/DevSecOps/Kubernetes admission control and Pod Security

`Error from server (InternalError): Internal error occurred: failed calling webhook "validation.gatekeeper.sh": ... context deadline exceeded` blocks every deploy

IntermediateTroubleshootingKubernetes admission control and Pod Security
Answer

Likely causes → Gatekeeper pods are down, overloaded, or unreachable from the API server (network policy, private cluster firewall on port 8443), and the webhook is failurePolicy: Fail.

Diagnose →

kubectl -n gatekeeper-system get pods
kubectl -n gatekeeper-system get endpoints gatekeeper-webhook-service
kubectl get validatingwebhookconfiguration gatekeeper-validating-webhook-configuration -o yaml | grep -E "failurePolicy|timeoutSeconds"

Fix → Restore the pods (scale, resources), open API-server-to-webhook traffic (GKE private clusters need a firewall rule for the webhook port).

Prevent → Run 3 replicas with a PDB and anti-affinity, exempt kube-system, set reasonable timeoutSeconds, and alert on webhook latency/rejections.

All DevSecOps questions Roadmap: Policy as code

More on Kubernetes admission control and Pod Security