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.
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
ifandcontainsin rule heads. Older v0 policies need the--v0-compatibleflag. - Know the server basics:
opa run --serverlistens onlocalhost:8181by default and decisions come fromPOST /v1/data/{path}. - Testing is a common interview topic:
opa test, thetest_prefix, mocking withwithand 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.
| Week | Topic | What you should be able to show |
|---|---|---|
| 1 | Rego basics: packages, rules, input, data, iteration | A policy that allows or denies an HTTP request by method, path and role |
| 2 | Rego v1 syntax, partial rules with contains, functions, every and in | A policy that returns a set of human-readable deny messages |
| 3 | Testing: opa test, with mocks, coverage | A test file with passing and failing cases and a coverage report |
| 4 | OPA as a server, the REST Data API, bundles, decision logs | A curl call that returns a decision from a running OPA |
| 5 | Kubernetes: Gatekeeper ConstraintTemplates, Constraints, audit | A constraint that blocks pods without required labels in a kind or minikube cluster |
| 6 | CI checks with Conftest, interview rehearsal | A 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
- 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.
- 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.
- What are
inputanddata?inputis the request sent with a query.dataholds loaded policies and external data, such as role mappings pushed in a bundle. - What happens when no rule body matches? The rule is undefined. A
defaultvalue turns that into an explicit result, which is safer forallowrules. - How do multiple rule definitions combine? Definitions with the same name are ORed. Expressions inside one body are ANDed.
- What is the difference between a complete rule and a partial (multi-value) rule? A complete rule produces one value. A rule declared with
containsbuilds a set from every body that matches, which suits deny messages. - What changed in OPA 1.0? The v1 syntax became the default, so
ifandcontainsare part of normal rule heads. A--v0-compatiblemode runs older policies. - Is OPA a CNCF project? Yes. The project site says it is a CNCF graduated project.
Testing and operations
- How do you unit test a policy? Write
test_rules, set input withwith input as, and runopa test . -vin CI. - How do you test a policy that calls an external function? Replace the function with
withand a mock of the same arity. - How do you measure test coverage? Run
opa test --coverage --format=json. Uncovered rule heads mean the body was never true in any test. - What port does an OPA server use by default?
localhost:8181when started withopa run --server. - How does a service ask OPA for a decision? It sends
POST /v1/data/<package path>/<rule>with aninputobject, or uses the Go SDK when OPA is embedded. - 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.
- Why enable decision logs? They record each query, input and result for audit and debugging. Mask sensitive input fields before shipping them.
- 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
- 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.
- 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.
- Why run audit as well as admission control? Admission only checks new or changed objects. Audit reports resources that existed before the policy.
- Scenario: a new policy blocks a production deployment at 2 a.m. What do you do? Confirm the denial message, change the constraint's
enforcementActiontowarnordryrunthrough Git, let the deploy proceed, then fix the policy and add a test for the case. - Scenario: how do you roll out a strict policy safely? Start with
enforcementAction: dryrunorwarn(the default isdeny), publish violations to the teams that own them, set a date, then switch to deny. - 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. - 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.
- 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
ifkeywords straight away. - Forgetting a
defaultonallowand 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
- OPA documentation: introduction
- OPA documentation: policy testing
- OPA documentation: REST API
- OPA documentation: v0 compatibility
- OPA documentation: Kubernetes admission control
- Gatekeeper documentation: enforcement actions
- Conftest documentation
- Linux Foundation: CKS exam page
- OPA releases on GitHub
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0