TL;DR: OPA decouples policy from application code so the same authorization logic can govern Kubernetes, API gateways and Terraform pipelines with consistent Rego decisions, according to Orca Security. That helps reduce policy fragmentation, but it also makes logging, modular design and control mapping non-negotiable for identity governance.
NHIMG editorial — based on content published by Orca Security: Open Policy Agent explained and its policy-as-code implications
Questions worth separating out
Q: How should security teams implement policy as code across Kubernetes and Terraform?
A: Start with one policy language, one decision engine and separate enforcement points.
Q: Why do fragmented policy engines create governance risk?
A: Fragmented policy engines create risk because the same identity or infrastructure rule can be enforced differently in each system.
Q: How do you know if OPA is actually improving control consistency?
A: Look for fewer policy rewrites across systems, stable deny behaviour under testing and clear decision logs that can be matched to control requirements.
Practitioner guidance
- Map each policy to a named control Tie Rego rules to a specific compliance benchmark or internal standard so every deny decision is auditable and explainable.
- Separate policy packages by enforcement domain Use modular Rego packages for admission control, gateway authorization and pipeline checks, with shared helper functions only where the logic truly overlaps.
- Turn on decision logging from day one Forward OPA decision logs into your SIEM so you can prove what was evaluated, what was denied and which policy bundle was active at the time.
What's in the full article
Orca Security's full article covers the operational detail this post intentionally leaves for the source:
- The Rego and OPA evaluation model in more implementation detail, including how structured input becomes an allow or deny decision.
- Gatekeeper usage patterns for Kubernetes admission control and how constraint templates are applied in practice.
- Decision logging fields and how they support audit evidence for control reviews and compliance checks.
- Performance guidance for high-throughput environments, including partial evaluation and webhook timeout considerations.
👉 Read Orca Security's analysis of Open Policy Agent and policy-as-code →
OPA and policy as code: what IAM teams need to watch?
Explore further
Policy fragmentation is an identity governance failure, not just an engineering inconvenience. When the same access rule lives separately in Kubernetes, Terraform and gateway code, enforcement diverges even if the written intent is identical. That produces different outcomes for the same actor depending on where the request lands, which is exactly how audit exceptions and misconfigurations accumulate. Practitioners should treat consistency of decision logic as a governance requirement, not a tooling preference.
A few things that frame the scale:
- 1 in 4 organisations are already investing in dedicated NHI security capabilities, with an additional 60% planning to do so within the next twelve months, according to The State of Non-Human Identity Security.
- 85% of organisations lack full visibility into third-party vendors connected via OAuth apps, which shows how quickly policy enforcement can outgrow access visibility.
A question worth separating out:
Q: What should organisations do when policy evaluation becomes too slow?
A: Measure latency, simplify expensive rules and use partial evaluation where the same base data is checked repeatedly. If evaluations slow admission or time out, the control is no longer reliable enough to depend on in production, even if the policy logic is correct.
👉 Read our full editorial: OPA centralises policy enforcement across cloud identity controls