Skip to main content
In this lesson we cover Kubernetes admission controllers: what they are, where they run in the API request lifecycle, and how to list, enable, or disable them on your API server.
A presentation slide titled "Admission Controllers" against a white and dark-blue curved background. On the right is a gear/settings icon with three horizontal slider controls.
What happens when you run kubectl?
  • kubectl sends an HTTPS request to the Kubernetes API server.
  • The API server authenticates the request (for example, using client certificates from your kubeconfig).
  • The API server authorizes the requested action (for example, via RBAC).
  • Admission controllers then validate or mutate the request.
  • If the request is allowed, the object is persisted to etcd.
Example kubeconfig showing client certificate and API server endpoint:
Authentication vs Authorization
  • Authentication verifies who sent the request.
  • Authorization checks whether that identity is permitted to perform the requested action.
  • Role-Based Access Control (RBAC) is the standard Kubernetes mechanism for authorization.
Example RBAC Role allowing a developer to manage Pods:
Example RBAC Role restricted to creating only specific pod names:
Why admission controllers? RBAC controls which API operations a user can call, but it does not inspect or change the object content. Admission controllers run after authentication and authorization, but before the object is stored in etcd. They can:
  • Validate requests (accept or reject).
  • Mutate requests (modify the object before persistence).
  • Take other side effects (for example, auto-provision a Namespace).
Common use-cases:
  • Block images from Docker Hub, allow only an internal registry.
  • Reject use of the latest image tag.
  • Deny containers that run as root.
  • Enforce required labels or metadata.
  • Inject sidecar containers or default environment variables.
Built-in admission controllers (examples) When admission controllers run Order: Authentication → Authorization (RBAC) → Admission controllers → Persist to etcd. Because they execute before persistence, admission controllers are the right place to enforce cluster-wide policy, validate API objects, or mutate requests. Example — NamespaceExists vs NamespaceAutoProvision
  • If a namespace does not exist and NamespaceExists is enabled, creating a Pod in that namespace will be rejected:
  • If NamespaceAutoProvision is enabled, the API server will create the namespace automatically and allow the Pod creation to proceed:
Listing and changing enabled admission plugin flags To see which admission controllers are enabled by the API server binary:
On many kubeadm clusters, the API server runs as a static Pod (manifest in /etc/kubernetes/manifests) or as a systemd service. Edit the appropriate manifest or unit and update these flags:
  • To enable controllers: --enable-admission-plugins=ControllerA,ControllerB,...
  • To disable controllers: --disable-admission-plugins=ControllerX,ControllerY,...
Examples
  1. systemd unit ExecStart (if API server runs as a systemd service):
  1. kube-apiserver static Pod manifest (common with kubeadm):
After editing the unit file or the static Pod manifest, the API server process will restart and pick up the new flags (kubelet restarts static Pods when their manifests change).
The NamespaceExists and NamespaceAutoProvision controllers have been superseded by the NamespaceLifecycle admission controller. NamespaceLifecycle enforces that requests to non-existent namespaces are rejected and prevents deletion of core namespaces (for example, default, kube-system, kube-public).
Best practices and next steps
  • Use validating admission controllers or validating webhooks to enforce custom policies (for example, image registries or security contexts).
  • Use mutating admission controllers or mutating webhooks to inject defaults or sidecars.
  • Prefer central, cluster-wide policies (e.g., PodSecurityAdmission, OPA/Gatekeeper) over ad-hoc per-cluster scripts.
  • Test changes to the API server flags in a non-production environment first.
Links and references Practice working with admission controllers and the --enable-admission-plugins / --disable-admission-plugins flags on a test cluster to understand how they affect API requests.

Watch Video

Practice Lab