Build and deploy a validating admission webhook for a Kubernetes CRD

domain: kubernetes.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Generate the webhook scaffolding with `kubebuilder create webhook --group apps --version v1alpha1 --kind MyApp --programmatic-validation`
  2. Implement `ValidateCreate`, `ValidateUpdate`, and `ValidateDelete` methods in the generated webhook file
  3. Provision a TLS certificate for the webhook server; use cert-manager with the `InjectCAFromSecret` annotation or inject a self-signed cert
  4. Register the webhook endpoint in a `ValidatingWebhookConfiguration` manifest referencing the service and CA bundle
  5. Set `failurePolicy: Fail` for security-critical checks; use `Ignore` only for non-blocking advisory checks
  6. Test with `kubectl apply` of a deliberately invalid CR and confirm the admission error message is returned

Known gotchas

Related routes

Configure a Kubernetes admission webhook with cert-manager for TLS provisioning and implement a ValidatingWebhookConfiguration to enforce custom policies
kubernetes.io · 5 steps · unrated
Configure a CRD conversion webhook to support multiple API versions
kubernetes.io · 6 steps · unrated
Implement a mutating admission webhook to inject a sidecar container into pods
kubernetes.io · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans