Policy as Code from IDE to Runtime: OPA, Kyverno, Conftest
Where OPA, Conftest, Gatekeeper, Kyverno and native Kubernetes admission policies belong, from IDE to runtime, and how to run one rulebook across all five.
On 12 November 2026, Kyverno 1.20 shipped. Its release notes contain a line that will break some upgrades: "remove legacy policy execution from admission binaries". Kyverno had deprecated ClusterPolicy, the policy type most Kyverno users have written for years, with 1.19 in August. Now the engine that evaluated it is gone, and by default the Helm chart refuses to install or upgrade while legacy policies are still on the cluster.
Most organisations still run policy as code in pieces: Conftest in one pipeline, Gatekeeper via Azure Policy on AKS, Kyverno somewhere else. This article is for the people who have to tidy that up: platform leads, CISOs and architects. We map the five points where a policy can decide, say which tool fits each, and show how to keep one rulebook behind all five.
TL;DR / Key takeaways
- Five decision points, not one. IDE, pull request, CI, admission and runtime each catch different mistakes. Early stages are cheap to fix; late stages are hard to bypass.
- Admission is the only gate that sees every change.
kubectl, portal clicks, operators and break-glass accounts skip your pipeline. They never skip the API server. - CEL is winning inside Kubernetes. Kyverno's CEL policy types reached v1 in 1.17, and its legacy types stopped enforcing in 1.20. VAP and MAP are both GA upstream.
- Rego still wins outside Kubernetes. Conftest and OPA cover Terraform plans, Dockerfiles, SBOMs and API authorisation, where CEL tooling is thin.
- One rulebook, one rule ID. The same rule should carry the same identifier, tests and exception process at every stage. Otherwise you are running five policy programmes.
Download: Editable draw.io file · Open in diagrams.net · Chart data (CSV)
Why this matters now
Kyverno went CEL-first. Kyverno graduated in the CNCF on 16 March 2026. Version 1.17 (2 February) promoted the CEL-based types such as ValidatingPolicy and MutatingPolicy to policies.kyverno.io/v1. Version 1.19 declared feature parity and deprecated ClusterPolicy and Policy. Version 1.20 removed legacy execution. If you run Kyverno, migrating is no longer optional.
Kubernetes now has in-process policy. ValidatingAdmissionPolicy has been stable since 1.30, and MutatingAdmissionPolicy became stable in 1.36. Both evaluate CEL in the API server, so there is no webhook to time out. Gatekeeper and Kyverno can generate these native objects from their own policies, and Azure Policy for AKS supports them behind a feature flag.
OPA kept moving after its creators moved. In August 2025 the creators of OPA and many Styra staff joined Apple. OPA remains CNCF graduated and its cadence did not slow: our GitHub API count shows 37 releases in the twelve months to 15 November 2026, 12 of them minor versions.
Five decision points, one rulebook
The numbers match the callouts in the hero diagram.
① IDE and pre-commit
This is the cheapest place to fail, because nobody else has seen the mistake yet. Regal, now part of the OPA project, is a linter, debugger and language server for Rego. For infrastructure authors, conftest test and the Kyverno CLI run the same policies locally or as pre-commit hooks.
Treat this stage as advice. A hook is skipped with --no-verify, and that is fine. Its job is to make sure the pipeline rarely tells developers something they could have known earlier.
② Pull request
The pull request is where policy becomes a conversation. Conftest can write results as github, azuredevops, junit or sarif output. A failing rule then appears as an annotation on the exact line, or as a code-scanning alert, instead of as a red build log nobody opens. Gatekeeper's gator verify and kyverno apply do the same job for Kubernetes manifests in the diff.
The most common mistake we see is running every policy against every file. Scope checks to changed paths, and write messages for the developer, not the auditor.
③ CI pipeline
CI is where you check what will actually be deployed: the rendered Helm chart, not the template, and the Terraform plan, not the HCL. A module default can turn a harmless-looking diff into a public storage account.
A Conftest rule against terraform show -json output looks like this:
package main
deny contains msg if {
some rc in input.resource_changes
rc.type == "azurerm_storage_account"
rc.change.after.public_network_access_enabled == true
msg := sprintf("POL-STG-001: %s allows public network access", [rc.address])
}Kyverno can now do the same: a ValidatingPolicy with spec.evaluation.mode: JSON can be applied to any JSON payload, including a Terraform plan, through the Kyverno CLI. Conftest still covers far more formats, from HCL2 and Dockerfiles to CycloneDX and SPDX SBOMs.
④ Admission
Admission is the only gate every change has to pass: your pipeline, an engineer's kubectl edit at 2 a.m., a GitOps controller, an operator, a break-glass account. That is the warm arrow in the diagram. Stages ① to ③ protect the paved road. Admission protects the cluster.
You have three serious options. Native ValidatingAdmissionPolicy and MutatingAdmissionPolicy are fast and need no extra pods. Kyverno's ValidatingPolicy is a superset of VAP:
apiVersion: policies.kyverno.io/v1
kind: ValidatingPolicy
metadata:
name: require-owner-label
spec:
validationActions: [Deny]
matchConstraints:
resourceRules:
- apiGroups: ['apps']
apiVersions: [v1]
operations: [CREATE, UPDATE]
resources: [deployments]
validations:
- message: "POL-K8S-004: label 'owner' is required"
expression: "'owner' in object.metadata.?labels.orValue({})"Gatekeeper uses constraint templates in Rego or CEL and can sync them into native VAP objects. Whatever you choose, start new rules in Warn or Audit, and set the failure policy deliberately: a webhook that fails closed mid-incident can block your own fix.
⑤ Runtime audit and authorisation
Resources outlive the rules that admitted them. Gatekeeper's audit and Kyverno's background scans re-evaluate existing resources and write policy reports. Native VAP only sees requests as they arrive.
Runtime is also OPA's home turf: API authorisation, via the Envoy plugin or as a library. Kyverno now has a separate kyverno-authz project. Ship decision logs to your SIEM. They prove the rule ran, not just that it existed.
What the numbers say
The matrix is our analysis of each project's documentation, not a benchmark. No single tool covers all seven columns: Kyverno is strong inside Kubernetes and partial outside, OPA with Conftest the reverse. Native VAP and MAP cover exactly one column, as an excellent admission engine and nothing else. And Azure Policy for AKS has no pipeline story, which is why AKS teams still need Conftest or Kyverno in CI.
The second chart is our own data from the GitHub releases API: five repositories, non-draft and non-prerelease releases, 15 November 2025 to 15 November 2026. We show cadence rather than stars because cadence is what you live with. OPA's 37 releases are 37 upgrade decisions unless you pin and batch them. Kyverno shipped only four minor versions, but one of them removed a policy API. Budget for upgrades, not just the install.
In a recent engagement…
Reviewing the platform of a European financial-services group this year, we found three policy programmes unaware of each other. The cloud team ran Conftest on Terraform. The AKS clusters used Azure Policy, so Gatekeeper enforced Microsoft's built-in initiatives. One product team had installed Kyverno for image verification. The rules overlapped but disagreed in small ways. "No public endpoints" meant one thing in Terraform and another at admission. Exceptions lived in three places, mostly without expiry dates.
The fix was mostly organisational. One policy repository; every rule with a stable ID, an owner, a severity, a unit test and its target stages. Conftest and Azure Policy stayed. We migrated the Kyverno image rules to ImageValidatingPolicy ahead of the 1.20 removal. Exceptions became pull requests against a single file, with an expiry date that CI checks. The auditors ignored the tooling. They cared that one rule ID appeared in the PR annotation, the admission denial and the quarterly report.
Which tool where: the decision table
| Stage | Default choice | Choose instead when… | Enforcement mode |
|---|---|---|---|
| ① IDE / pre-commit | Conftest + Regal | Kubernetes-only estate: Kyverno CLI | Advisory |
| ② Pull request | Conftest with --output github or sarif | Manifests only: kyverno apply or gator verify | Annotate; block on high severity |
| ③ CI | Conftest on plan JSON and rendered manifests | Kyverno shop that wants CEL everywhere: ValidatingPolicy in JSON mode | Fail the build |
| ④ Admission | Kyverno CEL policies, or Gatekeeper | Simple guardrails, no extra pods: native VAP/MAP. AKS with Azure governance: Azure Policy add-on | Warn, then deny |
| ⑤ Runtime | Kyverno background scans or Gatekeeper audit | Service-to-service authorisation: OPA with Envoy | Report and alert |
Rule of thumb: write each rule in the language native to the stage where it matters most, reuse it upstream where you can, and never enforce at admission before two weeks in audit mode.
Governance for European enterprises
Policy as code is not a legal requirement in itself, but it is one of the cleanest ways to evidence requirements that already apply.
NIS2. Article 21(2)(e) of Directive (EU) 2022/2555 covers "security in network and information systems acquisition, development and maintenance". Article 21(2)(f) asks for "policies and procedures to assess the effectiveness of cybersecurity risk-management measures". Versioned rules with tests, plus policy reports showing violations trending down, answer both. Our NIS2 technical guide maps the wider obligations.
DORA. Article 9(4)(e) of Regulation (EU) 2022/2554 requires financial entities to ensure that "all changes to ICT systems are recorded, tested, assessed, approved, implemented and verified in a controlled manner". Policy checks in the pull request, enforcement at admission and a decision log are that control, automated.
Cyber Resilience Act. Annex I, Part I, point (2)(b) of Regulation (EU) 2024/2847 requires products with digital elements to be "made available on the market with a secure by default configuration". If you ship deployment manifests or Terraform modules, CI policies prove your defaults stay secure release after release.
On Azure, AKS admission policies sit next to Azure Policy at the ARM layer, covered in our Azure Policy as Code guide. Keep both in one repository so rule IDs line up.
A pragmatic adoption path
- Weeks 1–2: inventory. List every place a policy decides today: Conftest jobs, Azure Policy assignments, Gatekeeper or Kyverno installations, scripts that fail builds. Count rules and exceptions.
- Weeks 3–4: one repository, one ID scheme. Move the rules into a single repository with an owner, a severity, tests and target stages per rule. Add
opa testandkyverno testto its own CI. Our DevSecOps pipeline design guide shows where these jobs sit. - Month 2: shift left in advisory mode. Annotate only, fix the noisy rules, then fail builds on high severity.
- Month 3: admission in audit, then enforce. Kyverno users migrate to the CEL types before upgrading to 1.20. Everyone else picks from the table above. Run two weeks in
AuditorWarnbeforeDeny. Harden the pipeline that publishes the policies too, as in our GitHub Actions hardening controls. - Ongoing: close the loop. Feed audit results and decision logs into your SIEM, review exceptions monthly and let expired ones fail.
The verdict
The tooling debate matters less than it looks. OPA with Conftest is the best general-purpose choice outside Kubernetes. Kyverno, now CEL-first, is the most complete inside it. Native VAP and MAP are the fastest admission engine if that is all you need. Gatekeeper remains solid, especially where Azure Policy already runs it.
What decides success is whether you treat the five stages as one system. Our view: treat admission as the non-negotiable backstop, because it is the only gate nobody bypasses. Then move each rule as far left as it will go, so admission denials become rare. And give every rule one ID, one owner and one exception process. Without that, you have five tools and no programme.
If you want help untangling an existing estate, our DevSecOps team runs a fixed-scope policy-as-code review. You leave with an inventory of every decision point, a consolidated rule catalogue and a migration plan for Kyverno 1.20.
FAQ
What is the difference between OPA, Conftest and Gatekeeper?
Open Policy Agent (OPA) is the general-purpose policy engine and the Rego language. Conftest is a CLI built on OPA that tests structured configuration files such as Terraform plans, Kubernetes YAML and Dockerfiles. Gatekeeper runs OPA inside a Kubernetes cluster as an admission controller with an audit function, using Rego or CEL constraint templates. All three are part of the OPA project, which has been a CNCF graduated project since January 2021.
Should we choose Kyverno or OPA Gatekeeper for Kubernetes?
Both are CNCF graduated and both enforce at admission and audit at runtime. Pick Kyverno if your platform team wants Kubernetes-native YAML with CEL expressions, built-in mutation, generation and image verification, and policy reports. Pick Gatekeeper if you already write Rego for other systems, or you use Azure Policy for AKS, which runs Gatekeeper for you. Running both in one cluster doubles the webhook surface, so avoid it unless you are migrating.
Do Kubernetes ValidatingAdmissionPolicy and MutatingAdmissionPolicy replace Kyverno and Gatekeeper?
Not entirely. ValidatingAdmissionPolicy has been stable since Kubernetes 1.30 and MutatingAdmissionPolicy since 1.36. Both run CEL in the API server without a webhook, which makes them fast and resilient. They do not scan existing resources, test files in CI, handle exceptions with expiry or produce compliance reports. Kyverno and Gatekeeper can generate these native policies for you and add the missing parts around them.
What changed in Kyverno 1.19 and 1.20?
Kyverno 1.17 promoted the CEL-based policy types such as ValidatingPolicy and MutatingPolicy to v1 in February 2026. Kyverno 1.19, released on 20 August 2026, reached feature parity and formally deprecated ClusterPolicy and Policy. The 1.20 release of 12 November 2026 removes legacy policy execution from the admission, background and reports controllers and blocks new legacy policies, so migrate to the policies.kyverno.io types before upgrading.
Can Kyverno check Terraform or other non-Kubernetes files?
Yes. A Kyverno ValidatingPolicy with spec.evaluation.mode set to JSON can be applied to any JSON payload, including a Terraform plan exported with terraform show -json, and evaluated with the Kyverno CLI. The older kyverno json scan command, based on the separate kyverno-json subproject, was removed in 1.20. Conftest remains the broader option for non-Kubernetes files because it ships parsers for HCL2, Dockerfiles, INI, TOML, XML, CycloneDX, SPDX and more.
Does policy as code help with NIS2 or DORA compliance?
It helps you produce evidence. NIS2 Article 21(2)(e) and (f) ask for security in development and maintenance and for procedures to assess whether measures are effective. DORA Article 9(4)(e) requires ICT changes to be recorded, tested, assessed, approved and verified in a controlled manner. Versioned, tested policies with decision logs and policy reports show exactly that. They do not replace the organisational measures.
Sources
All sources checked on 15 November 2026. Release counts come from the GitHub REST API on the same day; the method is in the chart script and data.csv.
Tier A: primary, standards and regulatory
- Kyverno 1.20.0 release notes (12 Nov 2026): https://github.com/kyverno/kyverno/releases/tag/v1.20.0
- Kyverno, "Announcing Kyverno 1.19" (20 Aug 2026): https://github.com/kyverno/website/blob/main/src/content/blog/announcing-kyverno-release-1.19/index.md
- Kyverno, "Announcing Kyverno 1.17" (2 Feb 2026): https://github.com/kyverno/website/blob/main/src/content/blog/announcing-kyverno-release-1.17/index.md
- Kyverno documentation, ValidatingPolicy (incl. JSON payloads): https://kyverno.io/docs/policy-types/validating-policy/
- CNCF, Kyverno project page (graduated 16 Mar 2026): https://www.cncf.io/projects/kyverno/
- CNCF, Open Policy Agent project page (graduated 29 Jan 2021): https://www.cncf.io/projects/open-policy-agent-opa/
- Kubernetes documentation, ValidatingAdmissionPolicy (stable since v1.30): https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/
- Kubernetes documentation, MutatingAdmissionPolicy (stable since v1.36): https://kubernetes.io/docs/reference/access-authn-authz/mutating-admission-policy/
- OPA v1.22.0 release notes (rego.v2 import): https://github.com/open-policy-agent/opa/releases/tag/v1.22.0
- Conftest documentation (parsers and output formats): https://www.conftest.dev/
- Gatekeeper v3.22.0 release notes (gator bench, gator policy, VAP sync): https://github.com/open-policy-agent/gatekeeper/releases/tag/v3.22.0
- Gatekeeper documentation, ValidatingAdmissionPolicy integration: https://open-policy-agent.github.io/gatekeeper/website/docs/validating-admission-policy/
- Gatekeeper documentation, gator CLI: https://open-policy-agent.github.io/gatekeeper/website/docs/gator/
- Microsoft Learn, Azure Policy for Kubernetes: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/policy-for-kubernetes
- Directive (EU) 2022/2555 (NIS2), Article 21: https://eur-lex.europa.eu/eli/dir/2022/2555/oj/eng
- Regulation (EU) 2022/2554 (DORA), Article 9: https://eur-lex.europa.eu/eli/reg/2022/2554/oj/eng
- Regulation (EU) 2024/2847 (Cyber Resilience Act), Annex I: https://eur-lex.europa.eu/eli/reg/2024/2847/oj/eng
Tier B: research and project communications
- OPA blog, "Note from Teemu, Tim, and Torin to the Open Policy Agent community" (20 Aug 2025): https://www.openpolicyagent.org/blog/note-from-teemu-tim-and-torin-to-the-open-policy-agent-community-2dbbfe494371
- Regal repository (linter, debugger and language server for Rego): https://github.com/open-policy-agent/regal
- OPA Envoy plugin: https://github.com/open-policy-agent/opa-envoy-plugin
- Kyverno Authz: https://github.com/kyverno/kyverno-authz
- CC Conceptualise, release counts per repository via GitHub REST API (our data, N = 5): https://www.conceptualise.de/blog/policy-as-code-opa-kyverno-conftest/data.csv
Tier C: vendor, directional
- None used. Tool positioning in the matrix is our own analysis of the Tier A documentation.
Topics