OPA Interview Prep: Rego Study Plan and Practice (2027)

Six-week OPA interview prep plan: Rego v1, opa test, the REST API on port 8181, Gatekeeper and Conftest, plus 24 questions. No official OPA certification.

Sep 27, 2025 - 12:38
Nov 11, 2026 - 02:04
 0  51
OPA Interview Prep: Rego Study Plan and Practice (2027)

To prepare for an Open Policy Agent (OPA) interview, learn to write and test Rego policies in the OPA 1.x syntax, run OPA as a server and query its Data API, and explain how Gatekeeper uses OPA for Kubernetes admission control. There is no official OPA certification, so interviewers judge you on working policies you can explain.

This guide is a preparation plan, not another long question bank. It tells you what to study in what order, gives you practice tasks with the commands to run, and ends with 24 interview questions you should be able to answer after the plan. For a broader view of where OPA fits, read how policy-as-code tools like OPA help DevOps governance first.

Key takeaways

  • OPA is a general-purpose policy engine and a CNCF graduated project. Software sends it JSON input and OPA returns a decision.
  • OPA has no official certification. Treat any "OPA certified" label as a third-party course, and prepare with hands-on work instead.
  • OPA 1.0 made the Rego v1 syntax the default, so practise with if and contains in rule heads. Older v0 policies need the --v0-compatible flag.
  • Know the server basics: opa run --server listens on localhost:8181 by default and decisions come from POST /v1/data/{path}.
  • Testing is a common interview topic: opa test, the test_ prefix, mocking with with and coverage reports.
  • For Kubernetes, the OPA docs recommend Gatekeeper, which adds ConstraintTemplates, Constraints and audit on top of OPA.

Is there an official OPA certification?

No. The OPA project publishes documentation, a playground and community channels, but it does not run a certification exam. Some training companies sell their own OPA courses with certificates of completion. Those can help you learn, but they are not issued by the OPA maintainers or the CNCF, and you should not describe them as an official credential on your CV.

That changes how you prepare. Without an exam blueprint, the interview is the test, and interviewers usually ask you to read or write a small Rego policy, explain how a decision reaches the service that enforces it, and talk through a rollout. Our OPA certification interview questions post covers the certification question in more detail and has a separate question set on bundles and decision logs.

If you want a recognised exam near this area, the Linux Foundation's Certified Kubernetes Security Specialist (CKS) is a 2-hour, performance-based exam that requires a passed CKA first. Its published curriculum does not name OPA or Gatekeeper, but it does cover pod security standards and permitted image registries, which are rules teams often enforce with OPA.

What OPA does, in one paragraph you can say out loud

The OPA documentation describes OPA as an open source, general-purpose policy engine that unifies policy enforcement across the stack. The service that needs a decision (an API gateway, a Kubernetes API server, a CI job, a microservice) sends structured input to OPA. OPA evaluates Rego policies against that input and any data it has loaded, and returns a decision such as true, false or a list of violations. The calling service enforces the decision. That split between deciding and enforcing is the first thing most interviewers want to hear, because it explains why one engine can serve many systems.

A six-week study plan

The plan assumes about an hour on weekdays. Stretch it if you are new to Kubernetes. Each week ends with something you can show in an interview.

WeekTopicWhat you should be able to show
1Rego basics: packages, rules, input, data, iterationA policy that allows or denies an HTTP request by method, path and role
2Rego v1 syntax, partial rules with contains, functions, every and inA policy that returns a set of human-readable deny messages
3Testing: opa test, with mocks, coverageA test file with passing and failing cases and a coverage report
4OPA as a server, the REST Data API, bundles, decision logsA curl call that returns a decision from a running OPA
5Kubernetes: Gatekeeper ConstraintTemplates, Constraints, auditA constraint that blocks pods without required labels in a kind or minikube cluster
6CI checks with Conftest, interview rehearsalA pipeline step that fails on a bad Kubernetes manifest or Terraform plan

Week 1 and 2: write Rego in the current syntax

Install the latest OPA binary (v1.22.4 was the newest release in November 2026) and check it with opa version. Then write a small authorization policy. Since OPA 1.0, the v1 syntax is the default: rule bodies need if, and multi-value rules use contains.

package httpapi.authz

default allow := false

allow if {
    input.method == "GET"
    input.path == ["salaries", input.user]
}

allow if {
    input.role == "admin"
}

deny contains msg if {
    input.method == "DELETE"
    input.role != "admin"
    msg := sprintf("user %v may not delete", [input.user])
}

Evaluate it locally before you touch a server:

echo '{"method":"GET","path":["salaries","asha"],"user":"asha","role":"dev"}' > input.json
opa eval -d policy.rego -i input.json "data.httpapi.authz.allow"

Practise explaining three ideas from this example. Rules with the same name are combined with a logical OR, so either allow body can make the result true. Expressions inside one body are joined with AND. The default keyword gives a value when no body matches, which turns an undefined result into an explicit false.

If you inherit older policies written in the v0 style, the OPA docs say v1.0 can run them in a backwards compatible mode with the --v0-compatible flag. Importing rego.v1 in a module applies the v1 restrictions, which is how teams migrated before 1.0. Expect a question on this, because many public examples still use the old syntax.

Week 3: test every policy

The OPA policy testing docs require test rules to start with test_. Putting tests in a package ending in _test is a recommended convention. Rules prefixed with todo_ are reported as skipped.

package httpapi.authz_test

import data.httpapi.authz

test_owner_can_read if {
    authz.allow with input as {"method": "GET", "path": ["salaries", "asha"], "user": "asha", "role": "dev"}
}

test_dev_cannot_delete if {
    count(authz.deny) == 1 with input as {"method": "DELETE", "user": "ravi", "role": "dev"}
}
opa test . -v
opa test --coverage --format=json policy.rego policy_test.rego

The with keyword can replace input, data documents, other rules and even built-in functions during a test. That is how you test a JWT-based policy without a real token: you replace io.jwt.decode_verify with a mock function of the same arity. The docs list limits: you cannot replace internal.* functions, eq or relations such as walk.

Week 4: run OPA as a service

opa run --server --addr localhost:8181 policy.rego
curl -s -X POST localhost:8181/v1/data/httpapi/authz/allow \
  -d '{"input":{"method":"GET","path":["salaries","asha"],"user":"asha","role":"dev"}}'
curl -s localhost:8181/health

The REST API docs say POST /v1/data/{path} takes a body with an input key and returns the document at that path. GET /health runs a simple built-in query and returns 200 when the server is working, with optional checks for bundles and plugins. In production, OPA usually runs as a sidecar or host-level daemon next to the service, so the decision call stays local. Policies and data arrive as bundles from an HTTP server, and decision logs go to a remote collector for audit.

Week 5: Kubernetes admission control with Gatekeeper

The OPA Kubernetes docs recommend Gatekeeper for admission control. Gatekeeper adds Kubernetes custom resources on top of OPA: ConstraintTemplates hold the Rego and a parameter schema, and Constraints instantiate a template with parameters and a match scope. Gatekeeper also audits existing resources, which matters because admission control only sees new or changed objects.

The alternative is plain OPA with the kube-mgmt sidecar, which loads policies from ConfigMaps and can replicate Kubernetes objects into data. The docs mention this route for teams that want OPA's own management features such as bundles, status and decision logs. The API server uses a deny-overrides model: if any admission controller denies a request, the request fails. Install the current Gatekeeper release (v3.23.1 at the time of writing) in a test cluster and write a constraint that requires an owner label on every namespace. For the wider comparison, read how Gatekeeper and Kyverno differ.

Week 6: policy checks in CI and rehearsal

Use Conftest, which writes its checks in Rego and runs them with conftest test, to test structured files such as Kubernetes YAML, Dockerfiles or a Terraform plan exported as JSON. A failing check stops the pipeline before a bad change reaches a cluster. Our post on policy as code in CI/CD pipelines walks through where each gate belongs. Spend the rest of the week answering the questions below out loud, with your own repository open so you can point at real code.

Interview questions to rehearse

These 24 questions follow the plan. Answer each in two or three sentences first, then expect a follow-up.

Fundamentals

  1. What problem does OPA solve? It moves authorization and policy logic out of application code into one engine. Services ask OPA for a decision, so policy can change without redeploying each service.
  2. What is Rego? The declarative language OPA uses for policies. The docs describe it as built for expressing policies over hierarchical data such as JSON.
  3. What are input and data? input is the request sent with a query. data holds loaded policies and external data, such as role mappings pushed in a bundle.
  4. What happens when no rule body matches? The rule is undefined. A default value turns that into an explicit result, which is safer for allow rules.
  5. How do multiple rule definitions combine? Definitions with the same name are ORed. Expressions inside one body are ANDed.
  6. What is the difference between a complete rule and a partial (multi-value) rule? A complete rule produces one value. A rule declared with contains builds a set from every body that matches, which suits deny messages.
  7. What changed in OPA 1.0? The v1 syntax became the default, so if and contains are part of normal rule heads. A --v0-compatible mode runs older policies.
  8. Is OPA a CNCF project? Yes. The project site says it is a CNCF graduated project.

Testing and operations

  1. How do you unit test a policy? Write test_ rules, set input with with input as, and run opa test . -v in CI.
  2. How do you test a policy that calls an external function? Replace the function with with and a mock of the same arity.
  3. How do you measure test coverage? Run opa test --coverage --format=json. Uncovered rule heads mean the body was never true in any test.
  4. What port does an OPA server use by default? localhost:8181 when started with opa run --server.
  5. How does a service ask OPA for a decision? It sends POST /v1/data/<package path>/<rule> with an input object, or uses the Go SDK when OPA is embedded.
  6. How do policies reach many OPA instances? Package them as bundles served over HTTP. Each OPA polls for new versions, so the source of truth stays in Git.
  7. Why enable decision logs? They record each query, input and result for audit and debugging. Mask sensitive input fields before shipping them.
  8. How do you check OPA is healthy in Kubernetes? Point liveness and readiness probes at /health, adding the bundle check if the instance must not serve before policies load.

Kubernetes and scenarios

  1. Gatekeeper or plain OPA for admission control? Gatekeeper for most clusters, because it gives reusable templates, parameters and audit. Plain OPA with kube-mgmt when you need bundles or decision logs from OPA itself.
  2. What is a ConstraintTemplate? A CRD that holds the Rego and parameter schema. A Constraint creates an instance of it with parameters and a match scope.
  3. Why run audit as well as admission control? Admission only checks new or changed objects. Audit reports resources that existed before the policy.
  4. Scenario: a new policy blocks a production deployment at 2 a.m. What do you do? Confirm the denial message, change the constraint's enforcementAction to warn or dryrun through Git, let the deploy proceed, then fix the policy and add a test for the case.
  5. Scenario: how do you roll out a strict policy safely? Start with enforcementAction: dryrun or warn (the default is deny), publish violations to the teams that own them, set a date, then switch to deny.
  6. Scenario: decisions are slow. Keep OPA close to the caller, avoid large data loads per query, profile with opa eval --profile, and check whether the policy loops over large collections.
  7. Scenario: a policy in Git and the one running differ. Check the bundle revision OPA reports in its status, then fix the build or polling that failed.
  8. How would you use OPA outside Kubernetes? Examples include API authorization behind an Envoy proxy, Terraform plan checks with Conftest and per-request checks inside a microservice.

Mistakes that cost candidates the interview

  • Writing v0 syntax without knowing it is the old form. Interviewers notice missing if keywords straight away.
  • Forgetting a default on allow and not explaining what an undefined result means to the caller.
  • Claiming an "OPA certification". Say you have no official one because none exists, and show your tests instead.
  • Describing Gatekeeper as a separate policy language. It runs Rego inside ConstraintTemplates.
  • No plan for rollout. Most real policy failures come from switching straight to deny.

Where to go next

Once you can do the six weeks above, work through the scenario-based OPA interview questions and the 80+ OPA interview questions list for breadth. If you want guided practice with policy as code, Kubernetes admission control and CI security gates, the DevSecOps training runs in our Kharadi, Pune classroom and live online across India.

Frequently asked questions

Is there an official OPA certification?

No. The OPA project does not run a certification exam. Course certificates from training companies are not official OPA credentials, so prepare with working policies and tests you can show.

How long does it take to prepare for an OPA interview?

About six weeks at an hour a day if you already know basic Kubernetes. Spend the first three weeks on Rego and tests, then OPA as a server, Gatekeeper and CI checks.

Should I learn Rego v0 or v1 syntax?

Learn v1. OPA 1.0 made it the default. Know how to read v0 policies and that the --v0-compatible flag runs them.

What port does OPA listen on?

An OPA server started with opa run --server listens on localhost:8181 by default. You can change it with --addr.

Do I need Kubernetes to learn OPA?

No. You can learn Rego, testing and the REST API with only the OPA binary. Kubernetes matters when the role involves admission control with Gatekeeper.

Which certification is closest to OPA work?

The Linux Foundation's CKS exam covers Kubernetes security, including pod security standards and permitted registries. Its curriculum does not name OPA or Gatekeeper, so treat it as related, not equivalent.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.