
- 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.
- 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.
- Validate requests (accept or reject).
- Mutate requests (modify the object before persistence).
- Take other side effects (for example, auto-provision a Namespace).
- Block images from Docker Hub, allow only an internal registry.
- Reject use of the
latestimage tag. - Deny containers that run as root.
- Enforce required labels or metadata.
- Inject sidecar containers or default environment variables.
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
NamespaceExistsis enabled, creating a Pod in that namespace will be rejected:
- If
NamespaceAutoProvisionis enabled, the API server will create the namespace automatically and allow the Pod creation to proceed:
/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,...
- systemd unit ExecStart (if API server runs as a systemd service):
- kube-apiserver static Pod manifest (common with kubeadm):
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).- 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.
- Kubernetes Documentation — Admission Controllers
- Kubernetes Documentation — Using RBAC Authorization
- Kube-apiserver flags reference
--enable-admission-plugins / --disable-admission-plugins flags on a test cluster to understand how they affect API requests.