K8s by Example: Admission Webhooks
| Admission webhooks intercept API requests before resources are persisted. ValidatingWebhooks reject invalid resources. MutatingWebhooks modify resources (inject sidecars, add labels). Misconfigured webhooks can block all deployments and crash clusters. |
| validatingwebhook.yaml | |
| ValidatingWebhookConfiguration defines when to call your webhook. | |
| Configure the webhook service endpoint and TLS. The API server calls this service for each matching request. | |
| mutatingwebhook.yaml | |
| MutatingWebhookConfiguration modifies resources. Common uses: inject sidecars (Istio), add default labels, set security context. Mutations happen before validation. | |
| Use | |
| webhook-failurepolicy.yaml | |
|
| |
| Critical: | |
| terminal | |
| List all webhooks in the cluster. When deployments fail mysteriously, check if a webhook is rejecting them. | |
| Check webhook details when debugging. Look at rules, failure policy, and service endpoint. | |
| terminal | |
| Webhook rejections appear in pod events. Look for | |
| Check webhook pod logs to understand why requests are rejected. The webhook service must be running and healthy. | |
| terminal | |
| Emergency fix: Delete the webhook configuration to unblock deployments. This removes the webhook entirely until you fix and redeploy it. | |
| Alternative: patch the webhook to | |
| webhook-service.yaml | |
| The webhook must be highly available. Use multiple replicas, proper resource limits, and PodDisruptionBudget. A down webhook with | |
Index | Use arrow keys to navigate