Where Kubernetes Admission Controllers Enforce Policy

Where Kubernetes admission controllers enforce security: the API server request path, built-in plugins, PodSecurity, CEL admission policies and webhooks.

Aug 25, 2025 - 16:47
Nov 9, 2026 - 18:49
 0  79
Where Kubernetes Admission Controllers Enforce Policy

Kubernetes admission controllers enforce security policies inside the API server, after a request is authenticated and authorized and before the object is saved to etcd. Mutating admission runs first and can change the object; validating admission runs second and can only accept or reject it. Admission applies to create, update, delete and connect requests, not to reads.

This guide follows a request through the API server and shows which policy is enforced at each point: built-in plugins such as PodSecurity and NodeRestriction, in-process CEL policies, and webhooks such as Gatekeeper and Kyverno. It also covers what admission cannot see, so you know which other controls you still need. For a tool comparison, see Gatekeeper vs Kyverno. The wider cluster design is in our Kubernetes architecture pillar.

Key takeaways

  • Enforcement happens in the kube-apiserver request pipeline: authentication, authorization, mutating admission, schema validation, validating admission, then persistence.
  • Admission controllers act on writes (create, update, delete, connect). They do not filter get, list or watch requests; RBAC handles reads.
  • Built-in plugins are compiled into the API server and enabled with --enable-admission-plugins. Examples include PodSecurity, NodeRestriction, LimitRanger and ResourceQuota.
  • Pod Security Admission replaced PodSecurityPolicy, which was removed in Kubernetes v1.25.
  • ValidatingAdmissionPolicy (stable since v1.30) and MutatingAdmissionPolicy (stable since v1.36) run CEL policies inside the API server without a webhook.
  • Webhooks extend admission with external engines, but a misconfigured fail-closed webhook can block every write in the cluster.

The request path: where each check happens

kubectl apply / controller / CI pipeline
        |
        v
[1] Authentication      who are you?            (certs, tokens, OIDC)
        |
[2] Authorization       may you do this?        (RBAC, Node authorizer)
        |
[3] Mutating admission  change the object       built-in mutating plugins,
        |                                       MutatingAdmissionPolicy,
        |                                       mutating webhooks
[4] Schema validation   is the object valid?    (OpenAPI, field rules)
        |
[5] Validating admission accept or reject       built-in validating plugins,
        |                                       ValidatingAdmissionPolicy,
        |                                       validating webhooks
[6] Persist to etcd
        |
        v
Scheduler, kubelet and controllers act on the stored object

If any admission controller rejects the request, the whole request fails and the user gets the error message. Mutating webhooks can be called again if a later mutation changes the object (controlled by reinvocationPolicy), and validating admission always sees the final object, which is why security checks belong in the validating phase.

StageQuestion it answersSecurity policies enforced here
AuthenticationWho is calling?Client certificates, service account tokens, OIDC
AuthorizationIs this verb on this resource allowed?RBAC roles, Node authorizer
Mutating admissionShould the object be changed?Default security context, inject sidecars, add labels, pin image digests
Validating admissionIs the final object acceptable?Pod Security Standards, allowed registries, required labels, no privileged pods, resource limits
Runtime (after admission)What does the workload do?seccomp, AppArmor or SELinux, NetworkPolicies, runtime detection

Layer 1: built-in admission plugins

These plugins are part of the kube-apiserver binary. Many are on by default; you can add or remove them with --enable-admission-plugins and --disable-admission-plugins. On managed services (EKS, AKS, GKE) the provider chooses the set.

PluginPhaseSecurity role
PodSecurityValidatingEnforces Pod Security Standards (privileged, baseline, restricted) per namespace
NodeRestrictionValidatingLimits each kubelet to modifying its own Node and the Pods bound to it
ServiceAccountMutating and validatingSets service accounts and token volumes on Pods
LimitRangerMutating and validatingApplies default and maximum CPU and memory per namespace
ResourceQuotaValidatingRejects requests that exceed namespace quotas, limiting resource abuse
NamespaceLifecycleValidatingBlocks objects in terminating or missing namespaces
AlwaysPullImagesMutating and validatingForces image pulls so private images cannot be reused by Pods without credentials
DenyServiceExternalIPsValidatingRejects new uses of Service externalIPs, a known traffic interception risk
EventRateLimitValidatingLimits event flooding of the API server
ImagePolicyWebhookValidatingAsks an external service to approve images

Pod Security Admission in practice

PodSecurity is the built-in way to block privileged containers, host namespaces, hostPath volumes and similar risky settings. You set it with namespace labels:

apiVersion: v1
kind: Namespace
metadata:
  name: payments
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/audit: restricted

enforce rejects violating Pods, warn returns a warning to the user and audit records the violation in the API audit log. A common rollout is warn and audit first, then enforce. One detail catches teams out: enforcement applies to Pods, so a Deployment with a bad Pod template is accepted, and its ReplicaSet then fails to create Pods. The warn mode reports on workload resources at creation time, which helps catch that earlier.

Layer 2: in-process CEL policies

ValidatingAdmissionPolicy lets you write rules in Common Expression Language that run inside the API server. There is no webhook to deploy, so there is no extra network hop and no separate service to keep alive.

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: trusted-registry-only
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
      - apiGroups: [""]
        apiVersions: ["v1"]
        operations: ["CREATE", "UPDATE"]
        resources: ["pods"]
  validations:
    - expression: "object.spec.containers.all(c, c.image.startsWith('registry.example.com/'))"
      message: "Images must come from registry.example.com"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: trusted-registry-only-binding
spec:
  policyName: trusted-registry-only
  validationActions: [Deny]
  matchResources:
    namespaceSelector:
      matchLabels:
        environment: production

The policy holds the logic; the binding decides where and how it applies (Deny, Warn or Audit). A complete rule would also check initContainers and ephemeralContainers. MutatingAdmissionPolicy uses the same model for changes such as adding labels or default security contexts, and the Kubernetes docs list it as stable and enabled by default since v1.36.

Layer 3: admission webhooks

When you need a policy library, audit reports of existing objects, external data or features like resource generation, you add a webhook-based engine. The API server sends an AdmissionReview request over HTTPS to the webhook service and acts on its answer.

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: policy-engine
webhooks:
  - name: validate.policy.example.com
    admissionReviewVersions: ["v1"]
    sideEffects: None
    failurePolicy: Fail
    timeoutSeconds: 5
    namespaceSelector:
      matchExpressions:
        - key: kubernetes.io/metadata.name
          operator: NotIn
          values: ["kube-system", "policy-system"]
    rules:
      - apiGroups: ["*"]
        apiVersions: ["*"]
        operations: ["CREATE", "UPDATE"]
        resources: ["pods", "deployments"]
    clientConfig:
      service:
        name: policy-webhook
        namespace: policy-system
        path: /validate

Settings that matter for security and availability:

  • failurePolicy: Fail blocks requests if the webhook cannot be reached, which is secure but can stop deployments during an outage. Ignore keeps the cluster working but lets requests through unchecked.
  • namespaceSelector should exclude the webhook's own namespace and kube-system, or a broken webhook can prevent its own repair.
  • timeoutSeconds defaults to 10 seconds and has a maximum of 30; keep it low.
  • matchConditions (CEL) can skip requests early, which reduces load on the webhook.

OPA Gatekeeper and Kyverno are the common engines in this layer. The operating model for writing and reviewing these policies as code is covered in policy as code for admission controls.

Choosing the layer for each policy

PolicyBest layerReason
No privileged or host-namespace PodsPodSecurityBuilt in, maintained by Kubernetes
Kubelets cannot edit other nodesNodeRestrictionOnly the API server can enforce it
Namespace CPU and memory capsResourceQuota, LimitRangerBuilt in
Images from approved registries onlyValidatingAdmissionPolicySimple CEL check, no webhook
Required labels or annotationsValidatingAdmissionPolicySimple CEL check
Verify image signaturesWebhook engineNeeds registry and key lookups
Unique Ingress hostnames across clusterWebhook engineNeeds data about other objects
Report violations in existing objectsWebhook engine with auditAdmission only sees new requests

What admission controllers cannot enforce

  • Reads. Who can list Secrets is an RBAC question.
  • Objects created before the policy. Admission only sees new requests; use audit features or scans for existing objects.
  • Runtime behaviour. A permitted container can still run a malicious process. Use seccomp, AppArmor or SELinux, NetworkPolicies and runtime detection.
  • Changes made outside the API server. Static Pods from manifests on a node and direct etcd access bypass admission, so protect node file systems and etcd.
  • Image content. Admission can check where an image came from and whether it is signed, but vulnerability scanning happens in CI and the registry.

Our guides to Kubernetes security best practices and cluster hardening steps cover those other layers. Supply chain controls start before the cluster, for example by keeping separate artifact repositories per environment; see segregating artifact repositories by environment.

Monitoring and troubleshooting admission

# Which webhooks and policies are installed?
kubectl get validatingwebhookconfigurations,mutatingwebhookconfigurations
kubectl get validatingadmissionpolicies,validatingadmissionpolicybindings

# Test a manifest against admission without saving it
kubectl apply -f pod.yaml --dry-run=server

# Check enabled built-in plugins on a self-managed control plane
ps -ef | grep kube-apiserver | tr ' ' '\n' | grep admission-plugins

Server-side dry run sends the request through admission, including webhooks that declare sideEffects: None, without persisting it, so it is a good CI check. The API server exposes admission latency and rejection metrics (for example apiserver_admission_webhook_admission_duration_seconds), and the audit log records which policies denied or warned on each request. Alert on webhook errors and rising latency, because a slow webhook slows every deployment.

Admission control, Pod Security Standards and policy engines are tested in the Certified Kubernetes Security Specialist exam. Our CKS training in Pune covers them hands-on, in Kharadi or live online.

FAQ

Where do admission controllers run in Kubernetes?

Inside the kube-apiserver. They run after authentication and authorization and before the object is written to etcd. Webhook controllers run as separate services, but the API server calls them at the same point.

What is the order of mutating and validating admission?

Mutating admission runs first and can change the object. Schema validation follows, then validating admission, which can only accept or reject the final object. Security checks belong in the validating phase because it sees the result of all mutations.

Do admission controllers apply to kubectl get?

No. Admission applies to create, update, delete and connect operations. Reads such as get, list and watch are controlled by RBAC authorization.

What replaced PodSecurityPolicy?

Pod Security Admission, the built-in PodSecurity plugin, which enforces the Pod Security Standards through namespace labels. PodSecurityPolicy was removed in Kubernetes v1.25. Teams needing finer rules add ValidatingAdmissionPolicy or an engine such as Kyverno or Gatekeeper.

What is the difference between ValidatingAdmissionPolicy and a validating webhook?

ValidatingAdmissionPolicy runs CEL rules inside the API server with no external service. A validating webhook calls an external HTTPS service, which allows more complex logic and data lookups but adds latency and a failure point.

What happens if an admission webhook goes down?

It depends on failurePolicy. With Fail, matching requests are rejected until the webhook returns. With Ignore, requests pass unchecked. Run webhooks with several replicas and exclude system namespaces.

How can I test whether a manifest passes admission policies?

Run kubectl apply --dry-run=server -f file.yaml. The request goes through authentication, authorization and admission but is not saved, so you see any denial or warning.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.