Mutate, Validate, and Generate Resources with Kyverno
Advanced · 60 minutes · 4 tasks, checked automatically · 100 points
In this advanced lab you will install Kyverno — the Kubernetes-native policy engine — and author three categories of policies: mutation policies that automatically inject labels and resource limits into Pods, validation policies that enforce security standards and reject non-compliant workloads, and generate policies that automatically create companion resources such as ConfigMaps and NetworkPolicies whenever a new Namespace is created. By the end you will have a fully working policy-as-code pipeline running against a real kind cluster.
What you’ll learn
- Install Kyverno using Helm and verify all components are healthy
- Write and apply a ClusterPolicy that mutates Pods by injecting a required label and default resource limits
- Write and apply a ClusterPolicy that validates Pods and rejects workloads that run as root or lack resource requests
- Write and apply a ClusterPolicy that generates a default NetworkPolicy and a ConfigMap whenever a new Namespace is created
How this lab works
- Start the lab: One click starts a real Kubernetes cluster on your computer (kind), with kubectl ready in a toolbox terminal.
- Work through 4 tasks: Each task says what to build or fix. You do it yourself, in a real terminal, with hints when you get stuck.
- Check your work: Check my work reads your live cluster and says, task by task, what passed and what to fix.
- Finish and keep going: 100 points, your progress saved, and the next lab to try.
What it runs on
- Cluster: A real Kubernetes cluster on your computer (kind)
- Kubernetes: 1.34.8
What you need
- A free LearnXops account
- The LearnXops desktop app for macOS, Windows or Linux
- Docker Desktop installed and running
- A kind cluster created in the Kubernetes Playground
Topics: kyverno, policy-as-code, admission-controller, mutation, validation, generate, security, kubernetes, helm, networkpolicy
Create a free account to start this lab.