The Ultimate Gatekeepers: Kubernetes Dynamic Admission Controllers
If you’ve been working with Kubernetes for a while, you know it’s incredibly powerful. But out of the box, Kubernetes is also surprisingly trusting. If a developer asks it to run a container, Kubernetes usually says, “Sure, right away!”
But what if that container is configured to run as a root user? What if it requests 100 GPUs for a tiny background task, blowing up your AWS bill? Or what if it’s missing the required billing-department label your company needs for tracking costs?
This is where Dynamic Admission Controllers come in. They are the ultimate gatekeepers of your cluster.
Let’s break down exactly what they do, why you desperately need them, and how they work in the real world.
1. What Does a Dynamic Admission Controller Do?
Every time you run a command like kubectl apply -f app.yaml, your request goes to the Kubernetes API Server. Before that YAML file is actually saved to the cluster's database (called etcd) and executed, it has to pass through a gauntlet of checks.
A Dynamic Admission Controller (often implemented as an Admission Webhook) is a custom piece of code that intercepts this API request at the very last millisecond.
It asks a simple question: “I see someone is trying to create/update/delete this resource. Should I modify it, allow it, or reject it?”
There are two types:
- Mutating Webhooks (The Modifiers): They look at your request and say, “Before I let this through, I’m going to add or change some things.” (e.g., automatically injecting a security proxy into your pod).
- Validating Webhooks (The Bouncers): They look at the final, modified request and give a strict YES or NO. “Does this meet our company security policies? No? Request denied.”
2. The Analogy: What Happens If They Aren’t There?
To truly understand their value, let’s look at a step-by-step comparison of a cluster without an Admission Controller versus a cluster with one.
Get Sravanmeduri’s stories in your inbox
Join Medium for free to get updates from this writer.
Imagine your Kubernetes cluster is an exclusive, high-end nightclub. The API Server is the front door.
Scenario A: The Nightclub WITHOUT Admission Controllers
- Step 1: A guest (Developer) walks up to the front door.
- Step 2: The door scanner (Authentication) checks their ID. “Yep, you are a registered employee.”
- Step 3: The manager (Authorization/RBAC) checks the guest list. “Yep, developers are allowed in the main room.”
- Step 4 (The Problem): The guest walks right in. But they are wearing flip-flops, carrying outside drinks, and sneaking in their friends.
- The Result: The club is a mess. In Kubernetes terms, developers are deploying unoptimized, insecure apps that hog resources because nobody checked what they were bringing inside.
Scenario B: The Nightclub WITH Admission Controllers
- Step 1: The guest walks up.
- Step 2: ID is checked (Authentication).
- Step 3: Guest list is checked (Authorization).
- Step 4 (Mutating Controller): The Coat Check Attendant steps in. “Before you go in, you must wear this VIP wristband, and I’m adding a tracker to your jacket so we don’t lose it.” (In Kubernetes, this is automatically adding labels, or sidecar containers like Istio).
- Step 5 (Validating Controller): The Bouncer steps in. “Let me look at you. Flip-flops? No. Sneaking in outside drinks? No. Access denied. Go home and change.” (In Kubernetes, this blocks insecure configurations).
- The Result: Only perfectly dressed, rule-abiding guests get in. Your cluster remains clean, secure, and cost-efficient.
3. Why Do We Need Them?
Kubernetes is built for the masses, which means it cannot predict your company’s specific business logic.
We need Dynamic Admission Controllers because:
- Humans Make Mistakes: Developers forget to add memory limits, or they accidentally pull from a public Docker registry instead of your secure private one.
- Security is Non-Negotiable: You cannot rely on the “honor system” to ensure teams aren’t running privileged containers that could compromise the whole node.
- Automation is King: Instead of forcing developers to write 500 lines of complex YAML, they can write 50 lines, and your mutating controllers can automatically fill in the missing 450 lines behind the scenes.
4. Real-World Benefits & Examples
Here is how top-tier engineering teams are actually using them today:
Benefit 1: Absolute Security (Using Validating Webhooks)
- Real-World Example: Tools like OPA Gatekeeper or Kyverno act as validating webhooks. You can write a policy that says: “Deny any Pod that tries to run as the
rootuser." If a developer tries to deploy an insecure app,kubectlwill literally throw an error in their terminal saying:Error: container must not run as root, preventing the breach before it even happens.
Benefit 2: Invisible Infrastructure (Using Mutating Webhooks)
- Real-World Example: The Istio Service Mesh relies entirely on mutating webhooks. When a developer deploys a simple 1-container application, Istio intercepts it and injects an
Envoy proxysidecar container into the pod automatically. The developer doesn't have to know how Istio works; they just deploy their app, and the admission controller magically adds the required networking infrastructure.
Benefit 3: Cost Control & FinOps
- Real-World Example: Imagine a developer makes a typo in their
Deployment.yamland requests1000Giof memory instead of10Gi. Without an admission controller, Kubernetes will desperately try (and fail) to provision massive AWS EC2 instances to satisfy this, costing you thousands of dollars. A validating webhook can be set up to instantly reject any deployment requesting more than32Giof memory per pod.
Benefit 4: Mandatory Tagging
- Real-World Example: Your finance team needs to track AWS costs by department. You can create a validating webhook that rejects any resource creation unless it has a specific label (e.g.,
team: frontend). No label? No deployment.
Conclusion
Dynamic Admission Controllers transform Kubernetes from a wild west into a highly governed, automated, and secure platform. They catch mistakes, enforce security, and automate tedious configurations — all without the developer ever having to change how they work.







