Course contentsShow
← Security
Lesson 1670 of 3,05233. Container SecurityFree lesson

Admission Controllers and Webhooks

Leveraging admission controllers (PodSecurityAdmission, validating/mutating webhooks) to enforce security policies at creation time.

Admission Controllers and Webhooks

What you'll learn: How Kubernetes admission controllers and webhooks act as gatekeepers that enforce security policies before any resource gets created in your cluster.

The Gatekeeper Concept

Imagine a nightclub bouncer checking IDs and dress codes before anyone enters. Admission controllers work the same way for Kubernetes: they intercept every API request after authentication and authorization but before the resource is persisted to etcd. This is your last line of defense to enforce security policies at creation time.

Types of Admission Control

Built-in Controllers like PodSecurityAdmission automatically enforce Pod Security Standards you've already learned about. When enabled, they reject pods that violate security baselines without requiring custom code.

Validating Webhooks are HTTP callbacks that examine incoming requests and say "yes" or "no." They can reject a deployment if it requests privileged containers or lacks resource limits—essentially custom security gates.

Mutating Webhooks go further: they can modify requests on-the-fly. For example, automatically injecting seccomp profiles, adding sidecar containers for security monitoring, or removing dangerous capabilities before the pod even reaches the API server.

Real-World Application

When a developer runs kubectl apply, the admission chain fires:

  1. API server receives the request
  2. Mutating webhooks modify it (add security context, labels)
  3. Validating webhooks check compliance (no host network? no privileged mode?)
  4. Built-in controllers apply final policy checks
  5. Only compliant resources reach etcd

This prevents misconfigurations from ever entering your cluster—shifting security left to creation time rather than discovering issues during runtime audits.

Key Takeaway: Admission controllers and webhooks enforce security policies at resource creation time, preventing non-compliant workloads from ever running in your Kubernetes cluster—making them essential for proactive container security.