Challenges
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Michal_Gebacki
Community Team
Community Team
Level: Intermediate

👉 This Challenge, with all of its three levels, created Katharina Sick (@ksick) from the OffOn Community!


This Challenge Level is best suited for:

 
Platform engineers and SREs who have some familiarity with Kyverno, ideally after completing the Beginner level. You should be comfortable reading Kubernetes YAML and basic kubectl commands.

Mission objective

 
Empire-wide laws enforce across every province: no privileged containers, every workload carries a valid republic.rome/gensand republic.rome/province matching its namespace, scoped by namespace label rather than hardcoded names
 
Aegyptus's scribe law applies only within Aegyptus, admitting republic.rome/role: scribe workloads exclusively
 
The legacy exception is scoped to Aegyptus's grandfathered workload and cannot be claimed by any other province
 

The Tabularium's ledger is on file: policy reports exported in OpenReports format as estate-audit.yaml

 

Key Learnings

 

How to scope policies using ValidatingPolicy (cluster-wide) and NamespacedValidatingPolicy (per-namespace), and when to use each

 
How CEL expressions in ValidatingPolicyand PolicyException express fine-grained admission conditions
 

How to write and scope a PolicyException correctly so only the intended workloads are exempt

 
How to use Policy Reporter and the OpenReports format to audit and debug a policy estate across multiple namespaces

This Challenge’s Level story:

The Republic has grown. What once was a single city is now a sprawling empire of provinces, each governed by different magistrates with different needs. The legal scholars decided to catalogue every law in a central archive (the Tabularium) so that each province's statutes could be tracked and audited in one place.

But cataloguing the laws introduced new chaos. Policies meant for one province are bleeding into another. Exceptions that were meant to be narrow have been written too broadly. And somewhere in the estate, a workload is slipping through that shouldn't be.

The Tabularium's auditors have handed you a report: Policy Reporter shows violations where there should be none, and silence where there should be enforcement. Your mission: investigate the policy estate, fix the scoping issues, and restore order before the provinces descend into chaos.

This Challenge Level’s architecture:

 

Five namespaces span the estate: four provinces (gallia, hispania, britannia, aegyptus) with republic.rome/realm: province, and castra, the infra namespace, with republic.rome/realm: infra. These labels drive policy scoping; use kubectl get ns --show-labels to inspect them.

 
Two empire-wide policies cover all provinces: no-privileged-containers and require-census (every workload must declare a valid republic.rome/gens and a matching republic.rome/province). Aegyptus adds aegyptus-require-scribe-role for its local scribe requirement, and a PolicyException covers its single legacy workload.

Walkthrough

1. Get started

Open in GitHub Codespaces. The devcontainer is pre-configured and starts automatically. When you push from Codespaces, GitHub forks the repository to your account automatically.

Prefer working locally? Clone the repo and open it in any editor that supports the Dev Containers specification (VS CodeVisual Studio Code, JetBrains, and others). The devcontainer config will be detected automatically.

2. Explore the Estate

When your Codespace is ready, the policy estate is already deployed, but something is wrong. Open Policy Reporter at port 30110 (find it in the Ports tab) to get an overview of the estate:

  • Which namespaces have violations?
  • Which policies are generating results, and which are silent when they shouldn't be?

Then dig into the cluster:

# Inspect the namespace topology — the labels here drive policy scoping
kubectl get ns --show-labels

# List all policies — note which are cluster-wide and which are namespaced
kubectl get validatingpolicies
kubectl get namespacedvalidatingpolicies -A

# Inspect any policy or exception in full
kubectl get validatingpolicy <name> -o yaml
kubectl get policyexceptions -A -o yaml

# See the raw OpenReports data behind Policy Reporter
kubectl get policyreports -A

You can also launch k9s for a terminal UI view:

k9s

3. Fix the policies

Review the objectives of this mission that are visible in the top of this page and investigate what is wrong in manifests/policies/ andmanifests/exceptions/.

Think about what each policy is supposed to cover, and compare that against what it is actuallymatching. The namespace labels you saw with kubectl get ns --show-labels are a key part of the picture.

Test locally with the Kyverno CLICommand Line Interface before applying:

kyverno apply manifests/policies/require-census.yaml --resource manifests/workloads/citizens.yaml
kyverno apply manifests/policies/aegyptus-require-scribe-role.yaml --resource manifests/workloads/aegyptus-legacy-scribe.yaml

Apply your changes to the cluster:

Once you’re happy with your changes, re-apply everything:

make apply

Policies only act at admission, so make apply redeploys the workloads to re-evaluate the estate against your changes. Then check Policy Reporter again. The picture should improve as you fix each issue.

 

4. File the Audit

Once the estate is in order, the Senate expects the Tabularium's ledger on file. Export the cluster's policy reports, the OpenReports data behind Policy Reporter, as the audit of record.

kubectl get policyreports -A -o yaml > estate-audit.yaml

How to complete your challenge?

 
When you push from Codespaces, GitHub forks the repository to your account automatically. If you are working locally, fork the repository on GitHub before pushing.
 

Verify your solution:

./verify.sh
 
If it passes, it generates a Certificate of Completion you can paste into the discussion.
 
Share your solutions in this thread in answer below and mention your achievement on your LinkedIn account!

Toolbox

kubectl - Apply and inspect cluster resources

kyverno CLI - Test and lint policies locally before applying

k9s - Explore cluster resources in a terminal UI

 

Helpful documentation

Kyverno ValidatingPolicy

Kyverno PolicyException

CEL Validation Expressions

Policy Reporter

OpenReports Format

Are you ready? Take the challenge’s mission!

Open in Codespaces

 
Free GitHub account required.
 
Launch in a preconfigured devcontainer.
 

Don’t forget about benefits!

 
For completing at least one level you get a unique badge!
 
For completing all of the three levels you get even more badges!
 
Deadline: 11 August 2026 at 23:59 CET

Other levels of this challenge

Beginner Lex Imperfecta
Expert Quis Custodiet
3 Comments
dannemca
DynaMight Guru
DynaMight Guru

--- CERTIFICATE START ---
Adventure: 05-lex-imperfecta
Level: intermediate
User: dannemca-persnonal
Repo: dannemca-persnonal/open-source-challenges
Date: Thu 23 Jul 2026 11:21:34 AM UTC
Url: https://github.com/dannemca-persnonal/open-source-challenges/commit/a56c2e2
--- CERTIFICATE END ---

p_devulapalli
DynaMight Leader
DynaMight Leader

--- CERTIFICATE START ---
Adventure: 05-lex-imperfecta
Level: intermediate
User: Phani Devulapalli
Repo: pdevulapalli/open-source-challenges
Date: Mon 27 Jul 2026 01:20:01 AM UTC
Url: https://github.com/pdevulapalli/open-source-challenges/commit/fd71126
--- CERTIFICATE END ---

tracegazer
Helper

🏆 Challenge Completed!

--- CERTIFICATE START ---
Adventure: 05-lex-imperfecta
Level: intermediate
User: Alan
Repo: dynatrace-oss/open-source-challenges
Date: Wed 29 Jul 2026 02:13:29 PM UTC
Url: https://github.com/tracegazer/open-source-challenges/commit/e8a37ce
--- CERTIFICATE END ---