Kubernetes admission
A validating admission webhook. The API server sends an AdmissionReview of a pod. The policy refuses a pod with an image from an untrusted registry, a privileged container, or a container with no memory limit.
Bundle kubernetes, revision 2026-12-03, decision data.kubernetes.admission.review
Examples
Input: compliant-pod
{ "apiVersion": "admission.k8s.io/v1", "kind": "AdmissionReview", "request": { "kind": { "group": "", "kind": "Pod", "version": "v1" }, "namespace": "shop", "object": { "metadata": { "name": "checkout", "namespace": "shop" }, "spec": { "containers": [ { "image": "registry.example.com/shop/checkout:1.4.2", "name": "checkout", "resources": { "limits": { "cpu": "500m", "memory": "256Mi" } } } ] } }, "operation": "CREATE", "uid": "705ab4f5-6393-11e8-b7cc-42010a800002" } }
Files
Show tree shaking for the decision
1# A validating admission webhook for pods. The API server of Kubernetes sends an AdmissionReview as the input,
2# and the webhook answers with the AdmissionReview in `review`.
3package kubernetes.admission
4
5deny contains message if {
6 some container in containers
7 not trusted(container.image)
8 message := sprintf("container %q has the image %q from an untrusted registry", [container.name, container.image])
9}
10
11deny contains message if {
12 some container in containers
13 container.securityContext.privileged
14 message := sprintf("container %q is privileged", [container.name])
15}
16
17deny contains message if {
18 some container in containers
19 not container.resources.limits.memory
20 message := sprintf("container %q has no memory limit", [container.name])
21}
22
23# The containers and the init containers of the pod.
24containers contains container if some container in input.request.object.spec.containers
25
26containers contains container if some container in input.request.object.spec.initContainers
27
28trusted(image) if {
29 some registry in data.kubernetes.registries
30 startswith(image, registry)
31}
32
33# The AdmissionReview response that the API server expects.
34review := {
35 "apiVersion": "admission.k8s.io/v1",
36 "kind": "AdmissionReview",
37 "response": {
38 "uid": input.request.uid,
39 "allowed": count(deny) == 0,
40 "status": {"message": concat("; ", deny)},
41 },
42}
43