What is
OPA
?
OPA (Open Policy Agent) is an open source, general-purpose policy engine. Software sends it structured data such as JSON, and OPA evaluates that input against policies written in the Rego language to return a decision.
At a glance
Attribute | Value |
|---|---|
Primary use case | Policy as code decision-making across the stack |
API compatibility | Query APIs; structured data input such as JSON |
Supported integrations | Including microservices, Kubernetes, CI/CD pipelines, API gateways |
AEP branch | Tooling |
AEP category | Security Plane |
AEP subcategory | Policy Control |
Profile
OPA separates the decision about what a policy allows from the code that enforces it. When an application needs a decision, it queries OPA through simple APIs and supplies arbitrary structured input. OPA evaluates that input against loaded policies and data, then returns the result. Policies are written in Rego. Rego and OPA are domain-agnostic, so the same engine can express rules about roles, network egress, container registries, access times or system calls.
Focus
Teams that want one way to write and enforce policy across their stack, covering development, security and audit needs. Typical targets are microservices, Kubernetes, CI/CD pipelines and API gateways.
Background
OPA is open source and a graduated Cloud Native Computing Foundation (CNCF) project.
Features
Rego policy language
Rego is a high-level declarative language built for writing policies over complex hierarchical data, with implicit iteration much like SQL. Complete and partial rules capture if-then logic, and the some and every keywords express FOR SOME and FOR ALL conditions.
Structured decision output
Policies can return arbitrary structured data, not only allow or deny. One query can return, for example, the set of port IDs connected to public networks.
Built-in functions
A library of built-in functions handles string manipulation, regular expression matching, arithmetic, aggregation and other common operations inside policies.
Playground and CLI evaluation
An online playground runs Rego against sample input in the browser. The opa eval command runs the same evaluations locally.
Pros and cons
Pros
One policy engine and language can cover authorization, infrastructure and pipeline rules across the whole stack.
Policy is written as code and kept out of application logic, so rules no longer sit scattered through each service.
Compliance teams can reuse the policies that block bad changes at provisioning time to audit existing systems for violations.
Cons
Teams must learn Rego, a purpose-built declarative language, before they can write or review policies.
OPA only returns decisions; each integrating service still has to call OPA and act on the result.
FAQs
What is OPA?
Open Policy Agent, pronounced "oh-pa", is a general-purpose policy engine. Applications send it structured data, and it checks that data against Rego policies to produce a decision.
Is OPA open source?
Yes. OPA is an open source project, and it has graduated within the Cloud Native Computing Foundation.
Where can OPA enforce policies?
OPA can be used with microservices, Kubernetes, CI/CD pipelines, API gateways and other systems. It is domain-agnostic, so it can express almost any kind of rule.
Can a policy return more than yes or no?
Yes. A Rego policy can produce any structured data as its result, such as a set of resource IDs that break a rule.
How can I try OPA before adopting it?
The online Rego Playground lets you edit policies and input and see the output in the browser. You can also evaluate policies on your own machine with the opa eval command.
