Block Workloads with a Validating Admission Webhook
Expert · 30 minutes · 5 tasks, checked automatically · 100 points
In this expert-level lab you will build a fully functional Validating Admission Webhook from scratch inside your kind cluster. You will write a Python webhook server, package it as a container image, load it into your kind node, deploy it with a self-signed TLS certificate, and register it with the Kubernetes API server so that it enforces a custom policy: blocking any Pod that lacks a required label `app.kubernetes.io/owner`. This lab covers the complete admission-control pipeline — TLS bootstrapping, webhook server logic, MutatingAdmissionWebhook vs ValidatingAdmissionWebhook, and policy enforcement — all running entirely inside your local cluster without any cloud dependencies.
What you’ll learn
- Generate a self-signed CA and TLS certificate for the webhook server and store them as a Kubernetes Secret
- Deploy a Validating Admission Webhook server that rejects Pods missing the label app.kubernetes.io/owner
- Register the ValidatingWebhookConfiguration and verify that compliant Pods are admitted while non-compliant Pods are blocked
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 5 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: admission-control, validating-webhook, security, tls, policy-enforcement, kind, kubernetes-security, rbac
Create a free account to start this lab.
Keep going
- ValidatingAdmissionPolicy with CEL Expressions
- Encrypt Secrets at Rest with an EncryptionConfiguration
- Sandbox Untrusted Workloads with RuntimeClass (gVisor)
- Harden Workloads with Pod Security Standards and SecurityContext
- Enforce Pod Security Admission at the Namespace Level
- Read-Only Root Filesystems and seccomp Profiles