Lion Cipher Lab

Build a Kubernetes validating admission webhook from scratch (and fail closed)

Why it matters

Every object that enters a Kubernetes cluster -- every Pod, every Deployment -- passes through ADMISSION CONTROL, a checkpoint inside the API server that can accept, reject, or mutate the request before it is ever written to storage. It is the single best place to enforce a security guardrail, because it stops a dangerous workload at creation time instead of hunting it down after it is running. Most teams rightly ADOPT a policy engine for this -- Kyverno, OPA Gatekeeper, or the built-in Pod Security Admission -- and you should know those cold. But if you have never written the thing…

What you'll learn

Steps in this lab

  1. What admission control is, and where your webhook plugs in
  2. Stand up a free, local cluster with kind
  3. Read the contract: the AdmissionReview request and response
  4. Decide the policy: what counts as a dangerous Pod
  5. Write the webhook server from scratch (Flask, ~50 lines)
  6. Mint a self-signed CA and a serving certificate with openssl
  7. Deploy the webhook into the cluster with its cert
  8. Register the webhook -- and fail CLOSED without bricking the cluster
  9. Prove it: deny the privileged pod, admit the compliant one
  10. The judgment: build vs buy, fail-open vs fail-closed, and the modern answer

Open the full interactive lab →