K8s Admission Controllers: The Silent Enforcement

K8s Admission Controllers: The Silent Enforcement

Reading time1 min
#kubernetes#devops#compliance#automation

Kubernetes looks calm on the surface. Sleek. Efficient. Like it’s got everything under control.

But here’s the truth—it doesn’t care if your app is secure, compliant, or even a good idea. You can deploy a dumpster fire, and Kubernetes will orchestrate it with a smile.

That’s where things get risky. One sloppy config, and your whole system could be in trouble.

Picture this: your team has been grinding for months. Finally, the big release is ready. CI/CD pipelines run smooth. Everything’s green.

Then—bam. You find out someone accidentally pushed a container with a critical vulnerability. No one noticed. Now your production environment is wide open to attackers.

Could this have been avoided? Absolutely. With an Admission Controller in place, that container would’ve never made it past the gate.

Let’s Talk About the Gatekeepers

Admission Controllers are like the bouncers of your Kubernetes cluster. They check every request before it’s allowed in. No valid ID? No entry.

They come in two flavors:

  • Validating Admission Controllers: They look at incoming requests and decide whether to let them in or not.
  • Mutating Admission Controllers: They tweak the request before saving it—like adding a sidecar or filling in defaults.

Together, they help enforce all kinds of rules—security policies, naming conventions, resource limits, and more. Automatically. No humans chasing down mistakes.

A Real-World Example: Stop Bad Images at the Door

Say your company has a rule: no container gets deployed unless it’s been scanned for vulnerabilities.

Now be honest—are you going to trust every developer to run that scan manually?

Didn’t think so.

Instead, you can use a ValidatingAdmissionWebhook to require a scan before anything goes live.

Here’s a basic example that hooks into a scanner like Trivy or Clair:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: image-scan-webhook
webhooks:
  - name: image-scanner.example.com
    clientConfig:
      service:
        name: image-scanner
        namespace: default
        path: /v1/scan
      caBundle: <CA_BUNDLE_BASE64>
    rules:
      - operations: ["CREATE"]
        apiGroups: ["apps"]
        apiVersions: ["v1"]
        resources: ["deployments"]
    admissionReviewVersions: ["v1"]
    sideEffects: None

Every time a new deployment is requested, this webhook steps in. It checks the container image. If it finds a critical vulnerability, the deployment gets blocked.

Result? No more surprises in prod. Just clean, compliant images—every time.

What Happens When You Skip It

Let me tell you about TechCorp. Mid-sized SaaS company. Fast-moving. Big on “just ship it.”

They skipped Admission Controllers to avoid slowing things down.

Then came the breach.

A rushed deployment included a vulnerable backend component. It got exploited. Sensitive user data leaked. Regulatory fine? $1.5 million.

Ouch.

They learned the hard way and pivoted. Fast. Started enforcing admission policies across the board—vulnerability scans, naming standards, quota enforcement.

Six months later:

  • 60% fewer misconfigured deployments
  • Zero security incidents in the next audit

Sometimes, guardrails are what keep the wheels from flying off.

Don’t Worry—It’s Not About Slowing Down

Sure, some devs might grumble at first. They’ll say it's friction. Another blocker. More red tape.

But it’s not.

Good automation removes busywork. It surfaces issues early—when they’re easier to fix and less costly.

Think of Admission Controllers like unit tests for your infrastructure. Quick feedback. Clear expectations. Safer code.

And once it’s set up? Most teams forget it’s even there.

More Than Just Vulnerability Checks

Admission Controllers aren’t just about security. You can use them to:

  • Enforce label and annotation standards for logging and cost tracking
  • Validate resource limits to prevent noisy neighbors
  • Block deprecated APIs before they break things
  • Require compliance tags or deployment metadata

And you don’t have to write everything from scratch. Tools like:

  • OPA/Gatekeeper
  • Kyverno
  • K-Rail

…make building policies way easier. Plus, they play nice with GitOps and scale with your team.

Bottom Line: They’re Guardrails, Not Handcuffs

Admission Controllers don’t slow down your team. They help you move smarter.

They keep risky configs out. They make sure everyone follows the same rules. And they give you peace of mind—whether you’re aiming for SOC 2, fending off threats, or just trying to deploy without drama.

Want to see them in action?

kubectl apply -f ./webhook-configuration.yaml

One command—and now your cluster watches every deployment like a hawk.

Because security isn’t just about building walls. It’s about knowing what you’re letting through the door.