Home/Templates/Stop risky pods before they start
Stop risky pods before they start
Admission policies refuse privileged pods, host mounts, and unsigned images, and report every refusal.
Argo CD
Why bother
Runtime detection tells you a container escaped. Admission control refuses the pod before it exists, when it asks for privileged mode, host paths, the host's process or network namespace, or an image nobody signed. Policies can run in audit mode first, so you see what would break before anything is blocked.
Try to create a privileged pod. In Audit mode it runs and a policy report lists it as failing. Once enforced, it is refused.
How it works
Set it up
Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.
Argo CD. Kyverno installed by Argo CD, with keyless image signatures from GitHub Actions
What you need first
- For the quick start, a cluster already running Kyverno 1.13 or later. Standard installs Kyverno 1.19 through Argo CD.
- For Standard, Argo CD with a project named platform, as the bootstrap template creates, and this folder committed to your repository.
- For the signature check, images built and signed with cosign in GitHub Actions.
What it creates
- Three cluster policies in Audit mode: no privileged containers, no host paths, no host namespaces
- Kyverno from a pinned chart, with three admission replicas (Standard)
- The same checks enforced everywhere except three named namespaces (Standard)
- A signature check, and a check for a signed CycloneDX SBOM, on images in prod-* namespaces, in Audit until you switch it (Standard)
See the four alerts this creates
The code
Quick startReady
kubectl config current-context
Shows which cluster kubectl is pointed at. Check it first.kubectl apply -f policies.yaml
Hands the Application to Argo CD.kubectl -n argocd get applications
Lists applications with their sync and health status.
Kubernetes schema passed
Last run 2026-10-02.
Open policies.yaml as plain text
StandardReady
repoURL: https://github.com/your-org/your-cluster-config.gitkyverno.yaml, line 54
kubectl config current-context
Shows which cluster kubectl is pointed at. Check it first.kubectl apply -k .
Applies everything the kustomization lists, in order.kubectl -n argocd get applications
Lists applications with their sync and health status.
Kubernetes schema passedBuilds passed
Last run 2026-10-02.
Open kustomization.yaml as plain text
Open kyverno.yaml as plain text
Open pod-security.yaml as plain text
Open verify-images.yaml as plain text
HardenedReady
kubectl config current-context
Shows which cluster kubectl is pointed at. Check it first.kubectl apply -k .
Applies everything the kustomization lists, in order.kubectl -n argocd get applications
Lists applications with their sync and health status.
Builds passed
Last run 2026-10-02.
Open kustomization.yaml as plain text
How to check it worked
Create a privileged test pod. In Audit mode it runs, and kubectl get policyreport -A lists it as failing. Once enforced, the create is refused with the policy's message.
Kyverno skips kube-system and its own namespace by default, and the Standard policy excludes three namespaces. Anyone who can create pods there bypasses every check, so treat that list like a firewall rule.
Admission policies apply when a pod is created. Pods already running keep running until they are replaced, so read the background policy reports for them.
Kyverno's resource definitions are too large for a normal apply, so the Standard Application uses server-side apply. Without it the sync fails on an annotation size limit.
When Kyverno cannot answer, pod creation fails across the cluster, because its policies refuse by default when they cannot check. Three replicas keep it answering.
The SBOM check looks for a CycloneDX attestation signed by the same workflow identity as the image. The CI/CD signals template's supply-chain.yml attaches one. Images built elsewhere show in the policy report until their pipeline does the same.
How to undo it
Delete the Applications, or run kubectl delete -f policies.yaml. Pods already admitted keep running.
What it costs
Kyverno runs as pods in the cluster, so the cost is their CPU and memory.
Good to know
- Start in Audit mode and read the policy reports before enforcing. Every failing pod in a report is a workload that would stop deploying.
- A signature proves where an image came from. The Standard check accepts only signatures made by your organisation's GitHub Actions workflows, so an image pushed by hand fails it.