Define a Kubernetes ValidatingAdmissionPolicy using CEL to enforce that all Deployments set replica counts above a minimum without an external webhook

domain: security/compliance · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Confirm your Kubernetes cluster is on a version that has ValidatingAdmissionPolicy as stable or as a feature gate; the feature graduated to stable in Kubernetes 1.30 (verify against current docs).
  2. Write a ValidatingAdmissionPolicy manifest with spec.matchConstraints specifying the resource kinds (Deployment) and operations (CREATE, UPDATE), and spec.validations containing CEL expressions such as object.spec.replicas >= 2.
  3. Create a ValidatingAdmissionPolicyBinding that binds the policy to a scope (cluster-wide or specific namespaces) and sets spec.validationActions to Deny or Audit.
  4. Apply both the ValidatingAdmissionPolicy and the ValidatingAdmissionPolicyBinding; test by creating a Deployment with too few replicas.
  5. Use paramKind and paramRef in the policy and binding to externalize configuration values (such as the minimum replica count) into a separate ConfigMap or custom resource, avoiding hardcoding in the policy.

Known gotchas

Related routes

Write a ValidatingAdmissionPolicy using CEL expressions to enforce resource limits
kubernetes.io · 5 steps · unrated
Configure a Kubernetes admission webhook with cert-manager for TLS provisioning and implement a ValidatingWebhookConfiguration to enforce custom policies
kubernetes.io · 5 steps · unrated
Build and deploy a validating admission webhook for a Kubernetes CRD
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