Kubernetes, EKS, GitOps & releases
Open Policy Agent
Open Policy Agent (OPA) is a general-purpose policy engine. You write rules as code in a language called Rego, give OPA some JSON describing a request or a configuration, and it returns a decision: allow or deny, plus reasons. In Kubernetes it usually runs as Gatekeeper, blocking non-compliant objects at admission time; in CI it runs as conftest, failing pipelines before bad manifests or Terraform plans reach production. Senior interviews expect you to explain policy-as-code, write a basic Rego rule, design a safe rollout of policies across clusters, and compare Gatekeeper with Kyverno and Kubernetes' built-in options.
After this topic you can
- Write basic Rego policies
- Enforce rules on Kubernetes with Gatekeeper or Kyverno
- Test the same policies in CI with conftest
Lessons
-
1Policy as code: the idea and the architecture
- Why policy as code
- Decoupling decisions from enforcement
- Inputs, data and deployment options
-
2The Rego language
- Mental model
- A first policy
- Rule types
- Undefined vs false
- Iteration, quantifiers and comprehensions
- Useful built-ins
- Testing Rego
-
3Gatekeeper: OPA for Kubernetes admission
- Architecture
- ConstraintTemplate and Constraint
- Enforcement actions
- The Gatekeeper policy library
- Referential policies: syncing cluster data
- Mutation
- Testing Gatekeeper policies
-
4Kyverno and Kubernetes' built-in policy options
- Kyverno
- Gatekeeper vs Kyverno
- Built-in options
-
5Rolling out policies safely and operating them
- A rollout plan that doesn't break teams
- Availability and failure modes
- Performance
- Managing policies across many clusters
- 6Shift-left: the same rules in CI with conftest
- 7A starter policy set for EKS
- 8OPA beyond Kubernetes admission
-
9Interview questions and model answers
- "What is OPA and how does it work with Kubernetes?"
- "How would you introduce policies without breaking teams?"
- "What happens if Gatekeeper is down?"
- "OPA vs RBAC?"
- "Gatekeeper or Kyverno?"
- "Write a Rego rule that blocks images not from our ECR."
- "How do you test policies?"