All articles

Policy as Code Tools in 2026: OPA, Kyverno, Sentinel, Checkov and Where Each One Runs

OPA, Conftest, Kyverno, Gatekeeper, Sentinel, Checkov and Trivy compared by where they run, and how to roll out policy as code without blocking teams.

Ask for the best policy as code tool and you get lists that mix engines, scanners and cloud services as if they were interchangeable. They are not. A rule such as "no storage bucket open to the internet" can be checked in a pull request, against a Terraform plan in CI, inside HCP Terraform, at the Kubernetes API or in the cloud provider's own control plane, and each of those points has its own tools. This article sorts the 2026 options by where they run and answers the questions teams ask most about choosing between them. For how policy as code sits next to infrastructure as code, see our guide to infrastructure as code and policy as code.

Key takeaways

  • Policy engines such as OPA, Kyverno and Sentinel evaluate rules you write; scanners such as Checkov and Trivy ship rules for known misconfigurations.
  • The same rule can run before merge, on the plan in CI, in HCP Terraform, at Kubernetes admission and in the cloud control plane, and each point has its own tools.
  • For Kubernetes admission, Kyverno, written in YAML and CEL, and OPA Gatekeeper, written in Rego, are the two mainstream choices.
  • OPA's creators joined Apple in 2025, but OPA remains a CNCF graduated project with unchanged governance and licensing.
  • Start every policy in audit or advisory mode, fix what it finds, then enforce.
Illustration of an engineer sending a change up to the cloud from a server, standing for the policy checks a change passes before it reaches cloud infrastructure.

What are policy as code tools?

Two kinds of tools share the label, and most teams end up needing both. A few terms make the differences easier to see:

Policy engine
Evaluates rules you write against structured input and returns a decision. Open Policy Agent (OPA) is general-purpose, Kyverno is built for Kubernetes, and Sentinel is HashiCorp's framework.
Scanner
Ships with built-in rules for known misconfigurations and lets you add your own. Checkov and Trivy are the common choices for infrastructure code.
Rego
OPA's policy language. Conftest and OPA Gatekeeper use it too, so one skill covers several enforcement points.
Admission control
The moment an API, such as the Kubernetes API server or a cloud control plane, accepts or rejects a create or update request.

Which policy as code tool runs where?

Where a check runs decides what it can see. A check on source files is fast but cannot see values that only exist at plan time; a check at the API catches changes from any path but gives feedback late. Our policy as code guide covers those trade-offs. This is the tool map:

Where it runsWhat it checksTools
Pull request or pre-commitSource files: Terraform, Kubernetes YAML, DockerfilesConftest with Rego policies; Checkov and Trivy with built-in rules; the Kyverno CLI for Kubernetes manifests
CI, on the Terraform planThe JSON plan: what will really changeOPA or Conftest on the output of terraform show -json
HCP Terraform runsThe plan of every runTerraform policy, Sentinel or OPA policy sets
Kubernetes admissionEach create or update request to the API serverKyverno or OPA Gatekeeper
Cloud control planeRequests to the cloud API, from any pathAzure Policy with the deny effect; service control policies in AWS Organizations

Two details are easy to miss. Azure Policy's deny effect stops a non-compliant create or update request before it reaches the resource provider, and its Kubernetes mode takes OPA Gatekeeper constraint templates, so Rego written for Gatekeeper also runs there (Microsoft Learn). AWS service control policies never grant permissions: they set the maximum that IAM policies in member accounts can use (AWS Organizations).

OPA Gatekeeper or Kyverno for Kubernetes?

Both run as admission controllers, and both can report instead of block. The difference is the language and the scope.

Kyverno

Kubernetes-native, with policies in YAML and CEL, so there is no new language to learn. It can validate, mutate, generate and clean up resources and verify container images (Kyverno docs). It graduated in the CNCF in March 2026, with users such as Bloomberg, Deutsche Telekom, LinkedIn, Spotify and Vodafone (CNCF).

OPA Gatekeeper

OPA for Kubernetes admission: constraint templates hold the Rego logic, and each constraint can deny, warn or run as a dry run (Gatekeeper docs). It pays off when the same people already write Rego for Terraform plans or APIs.

A workable rule: if Kubernetes is the only place you need policy, Kyverno is the shorter path. If one platform team writes rules for plans, pipelines and clusters, a single language across all of them is worth more, and that language is Rego.

Is OPA still a safe bet after its creators joined Apple?

In August 2025 the creators of OPA, along with many team members from Styra, the company behind its commercial products, joined Apple. The project's own announcement is explicit about what did not change: OPA "remains a CNCF graduated open source project", with "no changes to the project governance or licensing", and the maintainer list is the same apart from the employer of those who moved (Open Policy Agent blog, August 2025).

The people moved, the project did not

Governance and license stayed as they were. For a dependency you build compliance evidence on, watch the same signals as for any open source project: release cadence, open security issues and who maintains it.

Sentinel, OPA or Terraform policy in HCP Terraform?

If you run Terraform through HCP Terraform, policy enforcement is built in: it checks the plan against your policy sets during each run, and depending on the enforcement level, a failed policy can stop the run (HashiCorp). It now supports three frameworks, each with its own enforcement levels (HashiCorp):

  • Terraform policy. The native, HCL-based framework. It requires Terraform v1.17 or later and works for both workspaces and Stacks.

  • Sentinel. HashiCorp's own policy language, with three levels: advisory, soft mandatory, where a failure can be overridden, and hard mandatory, which stops the run.

  • OPA. Rego policies, with two levels: advisory, and mandatory, which users with the Manage Policy Overrides permission can override.

Choose OPA if your rules also run outside HCP Terraform, since the same Rego works in CI and at admission. Sentinel and Terraform policy are tied to HashiCorp's tooling.

Are Checkov and Trivy policy as code?

Partly. Checkov "scans cloud infrastructure configurations to find misconfigurations before they're deployed", across Terraform, Terraform plans, CloudFormation, Kubernetes, ARM templates, Serverless, Helm and AWS CDK, and lets you write your own policies in Python or as graph-based YAML (Checkov). Trivy covers similar ground for infrastructure code and absorbed tfsec: the tfsec repository now states that "Tfsec is now part of Trivy" and asks its community to move over (aquasecurity/tfsec).

A scanner is not a gate on its own

Scanners read source files, so they miss values that only exist at plan time, and they run where developers choose to run them. Use them for fast feedback and breadth, and put the rules that must always hold on the plan check and at admission.

How do you roll out policy as code without blocking every team?

A policy that starts in enforce mode tends to block a release on its first day and get switched off soon after. Every tool above has a reporting mode, so use it:

  1. Pick three to five rules that matter

    Start from your last incidents and audit findings, not from a vendor's full rule pack.

  2. Run them in report-only mode

    Kyverno's Audit mode admits the resource and records the violation in a policy report (Kyverno docs), Gatekeeper constraints can run as dryrun or warn, and HCP Terraform policies can be advisory.

  3. Fix what exists, or record exceptions

    Clear the violations the report shows, or log each exception with an owner and an expiry date.

  4. Switch to enforcement

    Kyverno Enforce, Gatekeeper deny and mandatory levels in HCP Terraform, with the plan check as a required pipeline step.

  5. Treat policies as code

    Keep them in Git, review changes to them like any other change, and add new rules through the same path.

Where to start

Take the rule your last audit or incident would have caught, write it once and run it against the Terraform plan in CI in advisory mode this week. Add admission control for Kubernetes next, then cloud guardrails for anything that can bypass the pipeline. Our infrastructure as code and policy as code guide shows where each check sits in the workflow, and our article on infrastructure as code drift and policy covers what policy buys a regulated team.

Sources

  1. Note from Teemu, Tim, and Torin to the Open Policy Agent community - Open Policy Agent blog, August 20, 2025
  2. Cloud Native Computing Foundation Announces Kyverno's Graduation - Cloud Native Computing Foundation, March 24, 2026
  3. Introduction - Kyverno documentation
  4. Validate Rules - Kyverno documentation
  5. Handling Constraint Violations - Gatekeeper documentation
  6. Conftest - conftest.dev
  7. Policy enforcement overview - HashiCorp Developer, HCP Terraform documentation
  8. Manage policies and policy sets in HCP Terraform - HashiCorp Developer, HCP Terraform documentation
  9. Checkov: Policy-as-code for everyone - checkov.io
  10. aquasecurity/tfsec - Aqua Security, GitHub
  11. Service control policies (SCPs) - AWS Organizations User Guide
  12. Azure Policy definitions deny effect - Microsoft Learn

Where to start

Start with your last release

The free Release Check shows where your last release spent its time and what that costs a year, in under 5 minutes and without a call.

Keep reading