Course contentsShow
← Security
Lesson 1973 of 3,05239. Cloud Security - Compute and ServerlessFree lesson

Kubernetes Admission Controllers

Configure ValidatingWebhooks, MutatingWebhooks, and tools like OPA Gatekeeper to enforce security policies at admission time.

Kubernetes Admission Controllers

You'll learn how admission controllers act as security gatekeepers that intercept and validate or modify Kubernetes API requests before resources are created.

What Are Admission Controllers?

Imagine a security checkpoint at an airport—every passenger (API request) must pass through inspection before boarding the plane (entering the cluster). Admission controllers work the same way: they intercept every request to create, update, or delete Kubernetes resources and can either validate (approve/reject) or mutate (modify) them before they're persisted.

There are two types of webhooks you can configure:

ValidatingWebhooks check if requests meet your security policies. For example, "Does this pod request privileged mode?" or "Is this image from an approved registry?" If validation fails, the request is rejected.

MutatingWebhooks actually modify requests on-the-fly. They might add security labels, inject sidecar containers, or set resource limits automatically before the resource is created.

Real-World Security Enforcement

OPA Gatekeeper is a popular tool that uses admission controllers to enforce policy-as-code. You write policies in Rego (OPA's language) that define what's allowed—like "all containers must run as non-root" or "no host path volumes permitted." Gatekeeper deploys as both validating and mutating webhooks, evaluating every resource against your policies at admission time.

This happens before the resource reaches etcd (Kubernetes' data store), so you catch problems early. It's far better than detecting violations after deployment when damage might already be done.

Why This Matters

Combined with RBAC and Pod Security Standards you've already learned, admission controllers complete your defense-in-depth strategy. RBAC controls who can make requests; admission controllers control what those requests can actually do.

Key Takeaway: Admission controllers are security enforcement points that use ValidatingWebhooks and MutatingWebhooks (often via tools like OPA Gatekeeper) to validate or modify Kubernetes API requests, preventing insecure configurations from ever entering your cluster.