A. B. Khan

The policy you wrote isn’t the policy you enforce

The Mesh Series · Article 21

Policy as codeKubernetesAuthorizationPolicyNetwork policyCompliance evidence

Cover: The policy you wrote isn’t the policy you enforce

Policy-as-code: Gatekeeper, Kyverno, and the day the API server learned to say no.

You spent the last three articles writing controls. A default-deny AuthorizationPolicy. A PeerAuthentication set to STRICT. A NetworkPolicy that fences the cardholder zone off from everything else. Each one is correct. Each one is applied. And each one is exactly one kubectl apply away from being skipped by the next deployment that forgets it exists.

That gap — between a policy exists in the cluster and no workload can enter without satisfying it — is where admission control lives. It’s the least glamorous piece of the platform and the one an auditor cares about most. Because a control you can bypass isn’t a control. It’s a comment.

Diagram: admission

Where a non-compliant workload gets stopped: apply → API server admission → etcd or reject

Admission control is a checkpoint the Kubernetes API server runs on every create and update, before the object is persisted to etcd. Authentication asks who you are. Authorization asks whether you’re allowed to touch this resource. Admission asks a different question: is what you’re submitting allowed to look like this. A pod with no resource limits, a namespace with no default-deny, a deployment that quietly disables mTLS — authentication and authorization wave all of them through. Admission is the layer that stops them.

There are two kinds. Mutating admission runs first and can rewrite the object — inject a sidecar, add a label, set a default. Validating admission runs after and can only say yes or no. Get rejected at validating admission and your apply fails with an error; the object never reaches etcd, so it never reaches a node. That’s the whole point. The rejection happens at the door, not in production three weeks later when someone runs a scan.

Why an auditor cares more about this than about the policy itself

Here’s the demo-to-audit gap in one sentence. In the demo, someone applied the PeerAuthentication by hand and showed you green. In the audit, the question is whether the next deploy can skip it — and whether anyone would notice if it did.

Regulated institutions don’t get graded on whether a control exists on the day of the review. They get graded on whether it holds continuously. SAMA’s Cyber Security Framework assesses you on a maturity model — you’re proving the control operates as a matter of course, not that you passed once. RBI’s IT framework for NBFCs puts the same expectation on the board. PCI-DSS 4.0 goes further and tests your segmentation: an assessor tries to open a connection from the general zone into the cardholder environment and expects it to fail. “We wrote a NetworkPolicy” is not evidence. “The cluster refuses to admit a namespace in scope that has no NetworkPolicy” is.

That’s the shift admission control buys you. Without it, your compliance posture is the sum of everyone’s discipline — every engineer remembering every control on every deploy, forever. With it, the posture is a property of the platform. The engineer who forgets gets a failed pipeline, not a finding six months later. You’ve moved the control from hoped-for to enforced, and that word — enforced — is the one the auditor is listening for.

Where this sits in everything you’ve built

Admission control is the layer that guarantees the rest of the series actually runs. Every mesh primitive from the last dozen articles — STRICT PeerAuthentication, default-deny AuthorizationPolicy, the NetworkPolicy belt from Article 20 — is only as real as the weakest deploy that could ship without it. Admission control is where you write the rule about the rules: no namespace in scope goes live without its baseline. It’s the meta-policy that makes the mesh policies non-optional.

Two ways to run it. The long-standing way is a validating admission webhook — the API server calls out over HTTPS to a policy engine (Gatekeeper or Kyverno) that holds your rules, evaluates the incoming object, and returns admit or reject. The engine runs in your cluster as a deployment you operate, scale, and keep available, because if the webhook is down and configured to fail closed, nothing gets admitted at all. That failure mode is not hypothetical; sizing and availability of the admission tier is real operational work. The newer way needs no webhook, and it changes this article’s math. More on that after the code.

The two engines, side by side

Start with the same rule expressed in each: reject any namespace labelled in scope that doesn’t carry a default-deny marker. A deliberately small rule — the point is the shape of the language, not the logic.

Gatekeeper is the OPA project’s admission controller. You write policy in Rego, OPA’s purpose-built language, split across two objects: a ConstraintTemplate that defines the logic, and a Constraint that parameterizes and applies it.

Code: gatekeeper

Gatekeeper ConstraintTemplate (Rego) + Constraint

Kyverno takes the opposite bet: no new language. Policies are Kubernetes YAML, and as of the 1.18 line the engine expresses conditions in CEL — the same expression language the API server itself now speaks. Here’s the equivalent as a Kyverno ValidatingPolicy, the newer type that’s replacing the older ClusterPolicy (which Kyverno has flagged for deprecation later in 2026).

Code card — code-21b-kyverno.pngKyverno ValidatingPolicy (YAML + CEL)

Same outcome, two philosophies. Rego is a real language — you can express logic that would be painful in CEL, and the same Rego runs outside Kubernetes too, against Terraform plans, CI checks, API gateways. That reach is Gatekeeper’s genuine edge. The cost is that someone on your team owns Rego, and Rego is a language people learn for exactly one job and forget between incidents. Kyverno asks nothing new of a team that already reads YAML, and it treats mutation and resource generation as first-class — Gatekeeper bolted mutation on later and doesn’t generate at all. Kyverno also verifies image signatures natively, which matters the moment supply-chain provenance shows up in your control set. The tradeoff there is reach: Kyverno is Kubernetes-only, by design.

Security · Audit · Integration

Security property gained. A non-compliant workload cannot be admitted. The control moves from convention to invariant — a forgotten baseline becomes a rejected apply, not a silent gap in production. This is the enforcement half of every “we have a policy” claim you’ll make to an assessor.

Audit evidence produced. Both engines emit machine-readable results. Kyverno writes PolicyReport and ClusterPolicyReport objects; Gatekeeper exposes constraint status and audit results. Those reports are the raw material your evidence pipeline scrapes — every rejection with a reason and a timestamp. A continuous stream of “the control held,” which is exactly what a maturity-model assessment (SAMA) and a segmentation test (PCI-DSS) want, rather than a screenshot from review day.

Integration. Admission control is the enforcement point for everything upstream — the mesh’s PeerAuthentication and AuthorizationPolicy, the L3/L4 NetworkPolicy, image provenance, resource governance — and it feeds the audit layer downstream (Articles 24–28) with a signal you didn’t have to ask a human to generate.

The alternative that changes the question

For years the honest answer to “Gatekeeper or Kyverno” was “whichever language your team will maintain at 2 a.m.” That answer is still right. But in 2026 there’s a third option that wasn’t viable before, and pretending otherwise would be selling you last year’s architecture.

Kubernetes now does admission policy natively, in-process, with no webhook to run. ValidatingAdmissionPolicy went GA in Kubernetes 1.30. MutatingAdmissionPolicy — the mutation half — reached GA in 1.36. Both use CEL, evaluated inside the API server. No deployment to scale, no webhook to keep available, no fail-open-or-fail-closed dilemma, no extra hop on the critical path of every write to the cluster. For a class of rules — require this label, forbid that field, enforce this default — the native mechanism is simply less machinery to own and to get flagged for.

Look at the same rule again, native this time:

Code: kyverno
Illustration

Native Kubernetes ValidatingAdmissionPolicy (CEL, no webhook)

That CEL is byte-for-byte the expression from the Kyverno policy above. Same rule, same language — one runs in an engine you operate, the other in the API server you already run. When the two forms are that close, the honest question isn’t which engine, it’s whether this particular rule needs an engine at all. (A companion ValidatingAdmissionPolicyBinding activates it against the namespaces you choose.)

So before you install anything, ask whether you need an engine at all. The native policies handle a real slice of what teams historically reached for Gatekeeper to do. What they don’t do is the hard part: cross-resource lookups (does a referenced config exist), resource generation (create the default-deny for a new namespace automatically), image signature verification, background auditing of objects already in the cluster, and rich reporting. That’s the space Gatekeeper and Kyverno still own — and it’s not a small space if you’re building a compliance product on top of it.

The 2026 read, plainly: reach for native admission policy first, for the simple structural rules — it’s the least you can operate. Add Kyverno when you want mutation, generation, image verification, and reporting without teaching anyone a new language; its CNCF graduation in March 2026 and its use at the scale of firms running hundreds of clusters make it a safe institutional bet. Reach for Gatekeeper when you already run OPA elsewhere and want one policy language spanning Kubernetes, pipelines, and gateways. Most regulated platforms end up with two layers, not one: native policy for the cheap structural guarantees, one engine for the rich compliance logic. Belt and suspenders, again — the Article 20 lesson keeps being true one layer up.

From a single rule to a compliance guardrail — and the question I have to ask myself

Scale the toy example and you get a policy library: every namespace in scope must carry a default-deny AuthorizationPolicy, a STRICT PeerAuthentication, an L3/L4 NetworkPolicy, resource limits, a signed image, an owner label for the audit trail. Ship that as code, version it in Git, and admission control becomes the thing that makes your mesh baseline a property of the cluster instead of a page in a runbook nobody reads.

Now the uncomfortable part, since this series is also the story of building a compliance product on exactly this ground. If you’re writing an operator that consumes a ComplianceProfile and enforces mesh primitives, admission control is where you’re most tempted to build your own engine — and where you’d be most wrong to. Kyverno is a CNCF-graduated project with a third-party security audit, adoption at Bloomberg and LinkedIn and Vodafone, and a governance model you will not reproduce. Native admission policy is maintained by the Kubernetes project itself and shipped in every cluster you’ll ever target. Writing a fourth admission engine to sit next to those three is rebuild-the-world syndrome with a compliance logo on it. The moat was never the enforcement mechanism. The moat is the translation — regulation to enforced primitive to signed evidence — and the mapping that says this RBI clause means these three policies must exist and here’s the continuous proof they do. Everything underneath that should be composed, not rebuilt. The day you find yourself reimplementing CEL evaluation, stop and go read the Kyverno source instead.

Writing the policy is the easy twenty percent. Guaranteeing no workload skips it — and proving that to someone who gets paid to doubt you — is the job.

“A control you can bypass isn’t a control. It’s a comment.”

Next: egress control and the locked-down cluster. Admission control governs what comes in. Egress governs what your workloads are allowed to talk to on the way out — and in a regulated network, the call you didn’t authorize is the one the auditor finds first.

Article 21 in a series building an audit-ready, zero-trust .NET platform on Kubernetes, Istio, and Microsoft Entra ID for regulated institutions across India and the Middle East. Full runnable policies for both engines — plus the native ValidatingAdmissionPolicy equivalents — are in the companion repo.

Key skills & topics in this article

Policy as codeKubernetesAuthorizationPolicyNetwork policyCompliance evidence

  • #Kubernetes
  • #PolicyAsCode
  • #Kyverno
  • #OPA
  • #ServiceMesh
  • #Istio
  • #ZeroTrust
  • #Compliance

Also on LinkedIn.