What is Open Policy Agent (OPA) and where does it fit in a DevSecOps pipeline?
Quick Answer
Open Policy Agent (OPA) is used for policy as code, running at the deploy stage. Explain the class of problem it catches, why catching it there is cheaper than catching it in production, and how it reports findings back to developers.
Detailed Answer
Describe Open Policy Agent (OPA) by the failure it prevents, not by its feature list. It belongs to policy as code and runs at the deploy stage of delivery, which matters because the cost of fixing a defect rises sharply the later it is found — the core argument behind shifting security left.
Strong answers cover the Rego language, OPA as a general decision engine vs Gatekeeper for Kubernetes admission, ConstraintTemplates and Constraints, policy unit testing with opa test, dry-run/audit mode before enforcing, and conftest for validating IaC before apply. Interviewers also listen for the operational side: who owns the rules, how findings reach the developer who introduced them, how false positives get suppressed without silently disabling coverage, and what the break-glass path is when a fix genuinely cannot ship in time.
Tie it to the wider toolchain. Security scanning is only useful when its output is actionable, deduplicated across tools, and attached to a specific commit, image digest or resource — otherwise teams learn to ignore it.
Code Example
# Where Open Policy Agent (OPA) sits in the pipeline # stage: deploy # 1. run the scan against the artifact produced by this stage # 2. compare findings against the agreed severity threshold # 3. an admission webhook denying a Pod that runs as root or lacks resource limits # 4. publish the report so developers see it on the commit or pull request
Interview Tip
Anchor Open Policy Agent (OPA) to a stage and a gate: what it scans, when it runs, and what makes the build stop.