Platform Engineering · Lesson 191

Policy as Code with OPA and Kubernetes

Stage 9 · Kubernetes Security · Advanced

Turn security and platform guardrails into reviewable, testable policy with safe exceptions and audit trails.

Reading time · ~35 minutes, interactive

Difficulty: Advanced · Know this first: the preceding lesson in this module

Production request

Use this incident as the thread: a team needs a reliable answer, but one resource or control is behaving differently under load.

What is happening?

What can fail?

How do I troubleshoot it?

Change an input

Adjust the working-set or load assumption and keep the diagnosis explicit.

50

Commands and parameters

Run the commands in a disposable lab or on a host you own. Replace placeholders such as $PID and $POD.

kubectl get constraints -A
opa test policy/
conftest test deployment.yaml
kubectl get events -A | grep -i deny

Knowledge check

Hands-on lab

Write what you observed, the command or query you ran, and the next decision you would make.

Lab is ready.

Basic to master checks

Basic

Intermediate

Advanced

Master

Production design exercise

Design the control for a multi-tenant production platform. State the boundary, signal, safe default, failure mode, rollback, and owner.

Next in this series · Lesson 192
Kubernetes Security

Lesson 93 taught you what a pod is. This lesson teaches you what a pod is allowed to do, and who is allowed to ask it to do it. A cluster is a shared machine, and every workload on it is a tenant.

Go to Lesson 192 →

Or browse the full course from the Lessons index.