Admission Control: Kyverno & policy-controller
Everything so far produces evidence: SBOMs, scan reports, signatures, provenance. Admission control is where the evidence is required. In Kubernetes, an admission webhook sees every Pod before it's created and can reject it, or rewrite it, if its images don't meet policy. The Admission Controllers lesson in the Kubernetes course covers the mechanism; this lesson covers the supply-chain policies people run there.
Note: Admission controllers run inside a Kubernetes cluster, so the policies below are non-run samples. The
cosign verifyandverify-attestationsessions earlier in the course are the same checks these controllers perform.
What a deploy-time policy checks
- The image is referenced by digest (or the controller resolves the tag and rewrites the Pod to the digest, so what was verified is what runs).
- The digest has a signature from a trusted identity or key.
- Required attestations exist and satisfy conditions: provenance from the release workflow of the right repository, an SBOM, a scan result without critical findings, VEX for accepted exceptions.
- Images from registries outside an allow-list are rejected outright.
Two open-source controllers dominate: Kyverno (a general policy engine with image verification built in) and Sigstore's policy-controller (only image verification, from the cosign authors). OPA Gatekeeper with external data providers, Ratify, and cloud features (GKE Binary Authorization, AKS image integrity) cover the same ground.
Kyverno
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: verify-acme-images
spec:
webhookConfiguration:
failurePolicy: Fail # if Kyverno is down, don't admit unverified Pods
rules:
- name: signed-release-images
match:
any:
- resources:
kinds: [Pod]
verifyImages:
- imageReferences:
- "ghcr.io/acme/*"
mutateDigest: true # rewrite image: ghcr.io/acme/shop:1.4.2 -> @sha256:…
verifyDigest: true # and require digests
required: true
attestors:
- entries:
- keyless:
issuer: "https://token.actions.githubusercontent.com"
subject: "https://github.com/acme/shop/.github/workflows/release.yml@refs/tags/*"
rekor:
url: https://rekor.sigstore.dev
attestations:
- type: https://slsa.dev/provenance/v1
attestors:
- entries:
- keyless:
issuer: "https://token.actions.githubusercontent.com"
subject: "https://github.com/acme/shop/.github/workflows/release.yml@refs/tags/*"
conditions:
- all:
- key: "{{ buildDefinition.externalParameters.workflow.repository }}"
operator: Equals
value: "https://github.com/acme/shop"For key-based signatures, replace the keyless entry with keys: { publicKeys: "-----BEGIN PUBLIC KEY----- …" }, or a KMS reference. Newer Kyverno releases also offer a CEL-based ImageValidatingPolicy type; the concepts are the same, so check the documentation of the version you run.
Sigstore policy-controller
policy-controller applies to namespaces labelled policy.sigstore.dev/include=true and evaluates every matching ClusterImagePolicy:
apiVersion: policy.sigstore.dev/v1beta1
kind: ClusterImagePolicy
metadata:
name: acme-release-images
spec:
images:
- glob: "ghcr.io/acme/**"
authorities:
- keyless:
url: https://fulcio.sigstore.dev
identities:
- issuer: https://token.actions.githubusercontent.com
subjectRegExp: '^https://github\.com/acme/shop/\.github/workflows/release\.yml@refs/tags/v[0-9.]+