Admission control and policy
The step between authorization and storage: built-in admission plugins, CEL validating and mutating policies, webhooks, and Kyverno or Gatekeeper.
Admission control and policy
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Admission runs after authentication and authorization and before an object is stored. Mutating admission changes requests, then validating admission accepts or rejects them, then the object is persisted.
- Much of Kubernetes is admission plugins compiled into the API server: ServiceAccount, LimitRanger, ResourceQuota, PodSecurity and others, each enabled by default or by flag.
- ValidatingAdmissionPolicy (GA 1.30) and MutatingAdmissionPolicy (GA 1.36) run CEL expressions inside the API server. A policy says what to check, and a binding says where and with what action: Deny, Warn or Audit.
- CEL policies are type-checked against the schema, so a typo shows up in the policy's status instead of silently never matching.
- Webhooks call your own HTTPS service. They can do anything, but with failurePolicy: Fail an unreachable webhook blocks every matching request, so they are an availability risk.
- Kyverno and OPA Gatekeeper add policy libraries, reporting, exceptions and generation on top. Kyverno can now emit native CEL policies.
RBAC can’t say “only from our registry”
RBAC answers whether a user may create a Deployment. It can’t look inside the Deployment. It can’t require images from your registry, demand memory limits, cap replicas, or forbid latest tags. Pod Security Admission checks a fixed list of fields and nothing else. Organisations need rules about the content of objects, and sometimes want to fill in defaults automatically.
That is admission control: a stage in the API server, after authentication and authorization and before the object is written to etcd, where code can change or reject the request.
The pipeline
Every write request goes through, in order: authentication → authorization → mutating admission → schema validation → validating admission → persistence. Mutators run first so validators see the final object. Reads don’t pass through admission at all.
Much of Kubernetes’ everyday behaviour is admission plugins compiled into the API server. The lab API server logged the default set at start-up:
Loaded 14 mutating admission controller(s) successfully in the following order: NamespaceLifecycle,LimitRanger,
ServiceAccount,TaintNodesByCondition,Priority,DefaultTolerationSeconds,DefaultStorageClass,
StorageObjectInUseProtection,PodGroupProtection,RuntimeClass,DefaultIngressClass,PodTopologyLabels,
MutatingAdmissionPolicy,MutatingAdmissionWebhook.
Loaded 15 validating admission controller(s) successfully in the following order: LimitRanger,ServiceAccount,
PodSecurity,Priority,PersistentVolumeClaimResize,RuntimeClass,CertificateApproval,CertificateSigning,
ClusterTrustBundleAttest,CertificateSubjectRestriction,NodeDeclaredFeatureValidator,PodResizeValidator,
ValidatingAdmissionPolicy,ValidatingAdmissionWebhook,ResourceQuota.
ServiceAccount is what injected the token volume in the authentication lesson. PodSecurity is PSA. ResourceQuota comes last so quota is charged only for requests that passed everything else. Some important plugins are opt-in. NodeRestriction, which stops a kubelet from modifying other nodes’ objects, needs --enable-admission-plugins, and every production cluster should have it. The extension points are the last plugins in each list: CEL policies and webhooks.
ValidatingAdmissionPolicy: rules in CEL
A ValidatingAdmissionPolicy holds CEL (Common Expression Language) expressions evaluated inside the API server. A binding attaches it to resources and picks the action:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: trusted-registry-and-limits
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups: ["apps"]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["deployments"]
variables:
- name: containers
expression: "object.spec.template.spec.containers"
validations:
- expression: "variables.containers.all(c, c.image.startsWith('registry.example.com/'))"
messageExpression: "'images must come from registry.example.com, got: ' + variables.containers.map(c, c.image).join(', ')"
reason: Forbidden
- expression: "variables.containers.all(c, has(c.resources.limits) && 'memory' in c.resources.limits)"
message: "every container needs a memory limit"
- expression: "object.spec.replicas <= 20"
message: "more than 20 replicas needs a platform review"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
name: trusted-registry-and-limits-prod
spec:
policyName: trusted-registry-and-limits
validationActions: [Deny]
matchResources:
namespaceSelector:
matchLabels:
env: prod
Applied to a lab API server, then tested in a namespace labelled env=prod:
$ kubectl -n payments create deployment web --image=nginx:1.29 --replicas=30
error: failed to create deployment: deployments.apps "web" is forbidden: ValidatingAdmissionPolicy
'trusted-registry-and-limits' with binding 'trusted-registry-and-limits-prod' denied request:
images must come from registry.example.com, got: nginx:1.29
The same command in an unlabelled namespace was allowed, since the binding didn’t match. A compliant Deployment passed. An image from the right registry without a memory limit hit the second rule, and because that rule set no reason, the response was is invalid (422) rather than forbidden (403). The denial reports the first failing expression.
Two features make CEL policies safer than they look:
- Type checking. I applied a policy with
object.spec.replica(missing an s). The API server accepted it and wrote the problem into its status:undefined field 'replica'. A webhook with the same typo would just never fire. - Rehearsal. A second binding for
env=devnamespaces withvalidationActions: [Warn, Audit]let a non-compliant Deployment through, printed both failures asWarning:lines, and added avalidation.policy.admission.k8s.io/validation_failureannotation to the audit event listing each failed expression.
Policies can also take parameters from a ConfigMap or custom resource through paramKind, so one policy serves different thresholds per namespace.
MutatingAdmissionPolicy: defaults in CEL
Mutation used to require a webhook. MutatingAdmissionPolicy, GA in 1.36, does it in-process. This one sets a default seccomp profile on any Deployment that doesn’t have one:
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingAdmissionPolicy
metadata:
name: default-seccomp
spec:
matchConstraints:
resourceRules:
- apiGroups: ["apps"]
apiVersions: ["v1"]
operations: ["CREATE"]
resources: ["deployments"]
matchConditions:
- name: no-seccomp-set
expression: "!has(object.spec.template.spec.securityContext) || !has(object.spec.template.spec.securityContext.seccompProfile)"
reinvocationPolicy: IfNeeded
mutations:
- patchType: ApplyConfiguration
applyConfiguration:
expression: >
Object{spec: Object.spec{template: Object.spec.template{spec: Object.spec.template.spec{
securityContext: Object.spec.template.spec.securityContext{
seccompProfile: Object.spec.template.spec.securityContext.seccompProfile{type: "RuntimeDefault"}}}}}}
With a binding in place, a server-side dry-run of a Deployment that set no security context came back with {"seccompProfile":{"type":"RuntimeDefault"}}. The mutation uses server-side apply semantics, so it merges rather than overwriting.
Webhooks: power with an availability cost
Admission webhooks send an AdmissionReview to your HTTPS service and act on its answer. They can call external systems, verify image signatures, or run logic CEL can’t express. The cost is that the API server now depends on your service. I registered a validating webhook for ConfigMaps in env=dev namespaces, pointing at a port with nothing listening:
error: failed to create configmap: Internal error occurred: failed calling webhook "validate.policy.example.com":
failed to call webhook: Post "https://policy-webhook.kube-system.svc:9999/validate?timeout=5s":
dial tcp [::1]:9999: connect: connection refused
With failurePolicy: Fail, nobody can create ConfigMaps there until the webhook returns. Switching to Ignore let the same request succeed, which fails open. Scope webhooks tightly, exclude system namespaces, set short timeoutSeconds, and run them with replicas and a PDB.
Policy engines
Kyverno (policies as Kubernetes YAML, v1.20 when checked) and OPA Gatekeeper (Rego, v3.23) are webhook-based engines that add policy libraries, background scans of existing resources, reports, exceptions, and in Kyverno’s case generating and cleaning up resources. Both now lean on the native APIs: Kyverno can produce ValidatingAdmissionPolicies, and Gatekeeper can enforce through them. A sensible default today: write simple rules as native CEL policies, and reach for an engine when you need its library, reporting or cross-resource logic.
About the video
The embed is Is it Observable’s “Kubernetes v1.33 Admission Controller – Game-Changing Updates!”, September 2025, 20 minutes, presented by Henrik Rexed. Going by its chapters and description, it covers the admission controller (mutation, schema validation and policy validation), the policy resources, CEL, and how to observe admission. It was made around 1.33, when MutatingAdmissionPolicy was still pre-GA, so treat version details accordingly. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the title, description and English caption track. The page shows no audio-language flag. The KubeCon talk in deeper is about migrating real policies to ValidatingAdmissionPolicy.
What was run: the plugin lists, the CEL denials, the 422 response, the type-checking warning, the Warn and Audit binding with its audit annotation, the MutatingAdmissionPolicy default, and both webhook outcomes are real output from a local Kubernetes v1.37.3 API server whose nodes run no containers. Kyverno and Gatekeeper weren’t installed. Their versions are from their GitHub releases, and GA versions are from the feature-gate reference, checked 2026-11-28.
Where this fits
Every allow and deny above can be recorded. Next: audit logging and cluster hardening.
Check yourself
A request is rejected with 'denied request' from a ValidatingAdmissionPolicy. Which stages has it already passed, and was anything stored?
It passed authentication, authorization (RBAC) and mutating admission. Validating admission rejected it, so nothing was written to etcd.
You want to try a new policy across all namespaces without breaking anyone. How do you deploy it?
Bind it with validationActions [Warn, Audit]. Clients see a warning, the audit log records validation_failure annotations, and requests still succeed. Switch the binding to Deny once the violations are fixed.
Your policy engine's webhook Pods crash and suddenly nobody can create Pods in the cluster. Why, and what limits the blast radius?
The webhook has failurePolicy: Fail, so every matching request fails when the API server can't reach it. Narrow its rules and namespaceSelector, exclude kube-system and the engine's own namespace, run it highly available, and prefer in-process CEL policies where they suffice.
What does a MutatingAdmissionPolicy do that a ValidatingAdmissionPolicy can't, and why is it better than a mutating webhook for simple defaults?
It changes the incoming object, for example setting a default seccompProfile, using a CEL apply configuration or JSON patch. It runs in-process, so there is no extra service to deploy, secure or keep available.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.