KubernetesIntermediate

Kubernetes Admission Control: Webhooks and Policies

DeveloperHat Team
9 min read

TL;DR

Admission control is where Kubernetes decides what gets into etcd. Webhooks, ValidatingAdmissionPolicy, and MutatingAdmissionPolicy compared — with the failure modes that take clusters down.

Every kubectl apply ends the same way: the API server either writes the object to etcd or rejects it. Admission control is the layer that makes that decision — it runs after authentication and authorization, and before anything is persisted. If you want to stop privileged pods, force image registries, or default a label onto every workload, this is where that enforcement lives. There is no later checkpoint.

The short version: use the built-in admission controllers for the standard guarantees, use ValidatingAdmissionPolicy (GA since Kubernetes 1.30) for simple rules you can express in CEL, and reach for a validating or mutating webhook only when a rule needs data the API server does not have — an external registry check, a call to your CMDB, a signature verification. Webhooks are the most powerful option and the most dangerous one: a down or slow webhook with the wrong failurePolicy can block every write in the cluster, including the writes you need to fix it.

One write, four gates — admission is the last one Reads bypass admission entirely. Writes pass every gate or reach nothing. kubectl apply Authn + Authz who · may they? Mutating change the object Validating allow or reject etcd persisted A rejection anywhere stops the request no partial writes, no retries past the gate Mutating runs first, then schema validation, then validating — a validator always sees the final object.

Where admission sits in the request path

A write request passes through four stages in the API server. Admission is the third, and it is the only one that can change the object or reject it based on its contents.

  • Authentication — who is making the request.
  • Authorization (RBAC) — whether that identity may perform this verb on this resource.
  • Admission control — mutating controllers first, then schema validation, then validating controllers. A rejection anywhere in this chain rejects the whole request.
  • Persistence — the object is written to etcd.
  • Two consequences matter in practice. First, admission cannot see reads: get, watch, and list bypass it entirely, so it is a write gate, not a data-access control. Second, because it runs before persistence, a validating controller sees the final object — including anything a mutating controller changed. The Kubernetes admission control reference documents the full phase order and the default plugin set for Kubernetes 1.37, the current release as of November 2026 (1.37.0 shipped August 26, 2026; 1.34 reached end of life on October 27, 2026; 1.38 is planned for December 16, 2026).

    The default plugin list in 1.37 already does a lot of quiet work: PodSecurity enforces pod security standards, ResourceQuota and LimitRanger cap consumption, NamespaceLifecycle blocks writes into terminating namespaces, ServiceAccount injects the default service account, and DefaultStorageClass fills in a storage class when none is named. Most teams get further by configuring these built-ins than by writing a webhook on day one.

    The options

    There are four extension points, and they split cleanly along two axes: mutate or validate, and in-process or out-of-process.

    Four extension points, two questions Mutate or validate — and does the rule need data outside the API server? IN-PROCESS · CEL / BUILT-IN Built-in plugins PodSecurity · Quota ValidatingPolicy GA in 1.30 IN-PROCESS · MUTATION MutatingPolicy stable in 1.36 Defaults labels · annotations OUT-OF-PROCESS · WEBHOOKS Validating webhook allow / deny Mutating webhook return a patch POLICY ENGINES ON WEBHOOKS Kyverno policies as YAML Gatekeeper OPA · Rego In-process rules cannot take the cluster down; a webhook can — so it must earn its place.

    Option 1: Built-in admission controllers

    Compiled into kube-apiserver and enabled with --enable-admission-plugins. No service to run, no network call, no failure mode beyond a misconfigured flag. PodSecurity is the one most teams should configure first: label a namespace pod-security.kubernetes.io/enforce: restricted and privileged containers, host networking, and host-path volumes are rejected at the door. Our Kubernetes security best practices guide walks through the RBAC, NetworkPolicy, and Pod Security combination that makes a namespace a real boundary rather than a label.

    Option 2: ValidatingAdmissionPolicy (VAP)

    A declarative policy written in CEL that runs inside the API server — no webhook service to deploy, secure, or keep available. A ValidatingAdmissionPolicy defines what to match and the rules; a ValidatingAdmissionPolicyBinding decides where it applies and what happens on a match (Deny, Warn, or Audit). It reached general availability in Kubernetes 1.30, so any supported cluster today can use it. The official ValidatingAdmissionPolicy reference is the authoritative source for the CEL functions available.

    # Reject any Deployment whose containers lack a memory limit.
    # CEL runs in-process: no service, no TLS, no timeout to tune.
    apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingAdmissionPolicy
    metadata:
      name: require-memory-limits
    spec:
      failurePolicy: Fail
      matchConstraints:
        resourceRules:
          - apiGroups: ["apps"]
            apiVersions: ["v1"]
            operations: ["CREATE", "UPDATE"]
            resources: ["deployments"]
      validations:
        - expression: >-
            object.spec.template.spec.containers.all(
              c, has(c.resources) && has(c.resources.limits)
              && has(c.resources.limits.memory))
          message: "Every container must declare a memory limit."
    ---
    apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingAdmissionPolicyBinding
    metadata:
      name: require-memory-limits-binding
    spec:
      policyName: require-memory-limits
      validationActions: [Deny]
      matchResources:
        namespaceSelector:
          matchLabels:
            policy.example.com/enforce: "true"

    Start new policies with validationActions: [Warn] (or Audit) and watch the audit log before switching to Deny. A rule that rejects a legitimate workload at 2 a.m. is worse than no rule at all until you have seen what it catches.

    Option 3: MutatingAdmissionPolicy (MAP)

    The declarative counterpart for mutation: a CEL-based patch applied in-process, either as an ApplyConfiguration merge or a JSONPatch. It was alpha in 1.30, beta in 1.34, and became stable in Kubernetes 1.36 — so it is only available on clusters running 1.36 or later (1.35 and 1.37 also ship it, but 1.35 has it in beta). The classic use is defaulting: add a team label, inject a standard annotation, set a default imagePullPolicy. The official MutatingAdmissionPolicy reference documents the patch formats and their limits.

    Prefer MAP over a mutating webhook whenever the mutation is a static default. A webhook that only adds labels is an availability risk you do not need.

    Option 4: Admission webhooks

    When a rule needs data outside the API server — checking an image against a registry allowlist, verifying a signature, querying an external policy service — you register a webhook. The API server sends an AdmissionReview over HTTPS to your service, which answers allowed or denied (validating) or returns a patch (mutating). Policy engines such as Kyverno and OPA Gatekeeper are built on this mechanism: they run as webhook services and evaluate policies you write in their own languages. The dynamic admission control reference documents the configuration fields.

    apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingWebhookConfiguration
    metadata:
      name: image-policy.example.com
    webhooks:
      - name: image-policy.example.com
        rules:
          - apiGroups: [""]
            apiVersions: ["v1"]
            operations: ["CREATE", "UPDATE"]
            resources: ["pods"]
            scope: "Namespaced"
        clientConfig:
          service:
            namespace: policy
            name: image-policy-webhook
          caBundle: <BASE64_CA_BUNDLE>
        admissionReviewVersions: ["v1"]
        sideEffects: None
        timeoutSeconds: 5
        failurePolicy: Fail

    The trade-offs

    Built-in controllersValidatingAdmissionPolicyMutatingAdmissionPolicyWebhooks
    Runs whereIn the API serverIn the API serverIn the API serverYour service, over HTTPS
    Needs external dataNoNoNoYes — the whole point
    Availability riskNoneNoneNoneCan block all writes
    ExpressivenessFixed behaviourCEL expressionsCEL patchesArbitrary code
    Available sinceAlwaysGA in 1.30Stable in 1.36Stable for years
    Best forStandard guaranteesSimple reject/default rulesStatic defaultsRegistry, signature, CMDB checks

    The pattern that survives contact with production: built-ins for the baseline, VAP for most custom validation, MAP for defaults on 1.36+, webhooks only for rules that genuinely need an external system.

    The failure modes that take clusters down

    Admission webhooks sit on the write path of every matching request, so their failure modes are cluster-wide. Get these five things right before you ship one.

    1. failurePolicy is the blast radius. Fail means a webhook that is down, slow, or misconfigured rejects the request. Ignore means the request proceeds unvalidated. For a security-critical webhook, Fail is the honest setting — but then the webhook is a single point of failure for the cluster, and you must treat it like one: multiple replicas, a pod disruption budget, and a liveness story. For anything advisory, Ignore is the only sane choice.

    2. Timeouts are short by design. The default webhook timeout is 10 seconds, and the docs encourage setting a shorter one — the example above uses 5. A webhook that takes seconds to answer makes every kubectl apply feel broken long before it fails. Keep webhook handlers fast and do expensive work (image scanning, signature verification) out of band where possible.

    3. Exclude the namespaces that keep the cluster alive. A validating webhook that matches all namespaces will happily reject the pods its own service needs to run, or block the CNI, DNS, or metrics components during an upgrade. Use namespaceSelector to exclude kube-system and the webhook's own namespace, and test upgrades with the webhook enabled.

    4. A mutating webhook can loop. When a mutating webhook changes an object, webhooks that already ran may be called again, depending on reinvocationPolicy (default Never; set IfNeeded when a later webhook's decision depends on an earlier mutation). A webhook that mutates on every invocation and triggers re-invocation can loop. Make mutations idempotent: if the label is already there, change nothing.

    5. Keep the escape hatch tested, not theoretical. If a bad webhook blocks writes, you fix it by deleting the ValidatingWebhookConfiguration or MutatingWebhookConfiguration — which is itself a write the webhook may block if it matches its own resource type. Scope webhooks to the resources they need (pods, deployments), never *, and rehearse the deletion from a break-glass kubeconfig before you need it in anger.

    Recommendation

    Pick the simplest mechanism that can express the rule Start at the top. Stop at the first yes. Is it a standard guarantee? Pod Security · quota · defaults? Built-in plugin configure it ValidatingPolicy CEL · Warn first Webhook external data only A webhook that only adds labels is an availability risk you do not need — use MutatingAdmissionPolicy.

    For a team setting this up in November 2026 on a supported cluster (1.35, 1.36, or 1.37):

  • Turn on the built-ins first — PodSecurity at restricted on workload namespaces, ResourceQuota, and a default-deny NetworkPolicy. That combination is covered in our multi-tenancy guide, which explains why a namespace alone is not a security boundary.
  • Write your first custom rules as ValidatingAdmissionPolicy with Warn actions, graduate to Deny after a week of clean audit logs.
  • Replace label-and-annotation mutating webhooks with MutatingAdmissionPolicy once you are on 1.36.
  • Keep webhooks for the one or two rules that need an external system, run them highly available, set short timeouts, and rehearse the escape hatch.
  • When NOT to use admission control

    Admission control is a write gate, not a runtime control. It cannot stop a pod that is already running from doing something bad, it cannot see reads, and it cannot fix an image that is vulnerable but correctly labelled. Runtime behaviour needs runtime tools — seccomp and AppArmor profiles, runtime security monitoring, and image scanning in the pipeline. It is also the wrong place for business logic: if a rule changes weekly and belongs to an application team, put it in the application or the CI pipeline, not in the cluster's write path. And if your cluster is a single-team dev environment, the built-ins plus Pod Security are enough; a webhook fleet there is operational theatre.

    Admission control earns its keep when it enforces invariants nobody should be able to override by accident: no privileged pods, only approved registries, every workload labelled and limited. Enforce the few rules that matter, in the simplest mechanism that can express them, and keep the write path fast and available — because the day admission control fails is the day nobody can deploy, including you.

    Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

    Share this articleShare on XShare on LinkedIn

    Keep the decision frameworks coming

    One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.