OPA (Open Policy Agent)
What is OPA (Open Policy Agent)?
OPA (Open Policy Agent)A CNCF-graduated, general-purpose policy engine that decouples authorization decisions from applications and Kubernetes admission control using the Rego language.
OPA (Open Policy Agent) is an open-source, general-purpose policy engine created at Styra by Tim Hinrichs and Torin Sandall and open-sourced in 2016. It was donated to the Cloud Native Computing Foundation in March 2018, reached incubating status in April 2019, and graduated on 4 February 2021 — the first CNCF project focused on authorization to do so. The core model is simple: a service sends OPA a JSON input, OPA evaluates it against policies written in the declarative Rego language (plus any loaded data), and returns a decision document. This decouples "can this action happen?" from business logic.
OPA runs as a sidecar, a standalone server with a REST API, an in-process Go library, or WebAssembly. Common deployments include Kubernetes admission control via OPA Gatekeeper (a validating/mutating webhook that rejects non-compliant manifests before they persist to etcd), per-request microservice authorization through Envoy's ext_authz gRPC filter, Terraform plan checks, and CI/CD guardrails. Operational best practices: unit-test policies with opa test, ship versioned signed bundles, stream decision logs for audit, and keep Rego readable with well-named rules. Rego's logic-programming style — where undefined means "no decision" — trips up newcomers, so thorough tests matter.
flowchart LR
API[K8s API server] -->|AdmissionReview| GK[Gatekeeper webhook]
GK --> OPA{OPA / Rego}
POL[Rego policies] --> OPA
DATA[External data bundles] --> OPA
OPA -->|allow| ADMIT[Resource persisted]
OPA -->|deny + reason| REJECT[Request rejected]
SVC[Microservice / Envoy] -->|JSON input| OPA● Examples
- 01
Gatekeeper using OPA to deny Kubernetes pods running as root.
- 02
Envoy ext_authz delegating per-request authorization to OPA over gRPC.
● Frequently asked questions
What is OPA (Open Policy Agent)?
A CNCF-graduated, general-purpose policy engine that decouples authorization decisions from applications and Kubernetes admission control using the Rego language. It belongs to the Cloud Security category of cybersecurity.
What does OPA (Open Policy Agent) mean?
A CNCF-graduated, general-purpose policy engine that decouples authorization decisions from applications and Kubernetes admission control using the Rego language.
How do you defend against OPA (Open Policy Agent)?
Defences for OPA (Open Policy Agent) typically combine technical controls and operational practices, as detailed in the full definition above.
What are other names for OPA (Open Policy Agent)?
Common alternative names include: Open Policy Agent, Rego policy engine.