Container image supply chain on Kubernetes: digests, allowed registries, and signature verification at admission
The cluster side of the supply chain: pinning images by digest, imagePullPolicy, private registries, restricting registries with ValidatingAdmissionPolicy (tested on a kind cluster), and requiring cosign signatures and SBOMs with Kyverno or policy-controller.
Kubernetes$ kubectl get pod web -o jsonpath='{.status.containerStatuses[0].imageID}'▍Signing images in CI is half the job. The other half happens in the cluster: if Kubernetes accepts any image: that shows up in a manifest, the signature is just decoration. This guide covers the cluster side: how to pin what runs, where it is allowed to come from, and how to demand proof of origin at admission time. The CI side (keyless signing with cosign, SBOM generation, provenance, and SLSA) is already covered in supply chain security with Cosign, SBOM, and SLSA, and we won’t repeat it here.
Everything involving kubectl was run on a kind cluster with Kubernetes v1.37.0. Anything I couldn’t run is flagged.
A tag is not an identity: pin by digest
A tag like nginx:1.29-alpine is a moving pointer. The maintainer (or someone with improper access to the registry) can repoint it to different content. The digest (sha256:...) is the hash of the image manifest and never changes: if the content changes, the digest changes.
The easiest way to find the digest of what is already running is to ask the cluster itself:
kubectl -n f-supply run web --image=nginx:1.29-alpine
kubectl -n f-supply get pod web -o jsonpath='{.status.containerStatuses[0].imageID}'
# docker.io/library/nginx@sha256:5616878291a2eed594aee8db4dade5878cf7edcb475e59193904b198d9b830de
From then on, use the immutable reference in your manifest:
containers:
- name: web
image: nginx@sha256:5616878291a2eed594aee8db4dade5878cf7edcb475e59193904b198d9b830de
This also makes rollbacks predictable: going back to the previous digest means going back to exactly the same bytes. For readability, you can use nginx:1.29-alpine@sha256:... (the tag becomes just a label; the digest is what counts). Tools like Renovate, or your own pipeline, can update digests through pull requests.
imagePullPolicy: what the kubelet does with the reference
If you don’t set imagePullPolicy, the API server fills in a default. I tested with --dry-run=server to see the value that gets stored:
| Reference | Default applied | Behavior |
|---|---|---|
nginx (no tag) |
Always |
checks the registry every time a container starts |
nginx:latest |
Always |
same |
nginx:1.29-alpine |
IfNotPresent |
uses the local copy if there is one |
nginx@sha256:... |
IfNotPresent |
the local copy is, by definition, the same |
Always doesn’t mean downloading everything again: the kubelet resolves the digest in the registry and only pulls layers it doesn’t have. But it makes every restart depend on the registry. With a digest, IfNotPresent is safe, because there is no “new version” of the same digest. Avoid :latest in production: you lose traceability and the default becomes Always.
Private registries with imagePullSecrets
To pull from a private registry, the kubelet needs a credential. Create a Secret of type kubernetes.io/dockerconfigjson and attach it to the ServiceAccount so that all of its pods inherit the credential:
kubectl -n production create secret docker-registry ghcr-pull \
--docker-server=ghcr.io \
--docker-username=bot-your-org \
--docker-password='<read-only-token>'
kubectl -n production patch serviceaccount app \
-p '{"imagePullSecrets":[{"name":"ghcr-pull"}]}'
Use a read-only token scoped to the repository. In the cloud, prefer node or workload identity (for example, ECR with the node role on EKS) over static credentials. Also remember: anyone who can read Secrets in the namespace can read that token; see RBAC: ClusterRoles and RoleBindings.
Restricting registries with ValidatingAdmissionPolicy
ValidatingAdmissionPolicy (GA since 1.30) runs CEL expressions inside the API server itself, with no webhook or extra controller. It is the lightest way to say “I only accept images from these registries.” The policy below covers containers, initContainers, and ephemeral containers (kubectl debug):
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: f-allowed-registries
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["pods", "pods/ephemeralcontainers"]
variables:
- name: images
expression: >-
object.spec.containers.map(c, c.image)
+ (has(object.spec.initContainers) ? object.spec.initContainers.map(c, c.image) : [])
+ (has(object.spec.ephemeralContainers) ? object.spec.ephemeralContainers.map(c, c.image) : [])
validations:
- expression: >-
variables.images.all(img,
img.startsWith('registry.k8s.io/') || img.startsWith('ghcr.io/your-org/'))
messageExpression: >-
'image outside the allowed registries: ' +
variables.images.filter(img, !(img.startsWith('registry.k8s.io/') || img.startsWith('ghcr.io/your-org/'))).join(', ')
reason: Forbidden
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
name: f-allowed-registries
spec:
policyName: f-allowed-registries
validationActions: ["Deny"]
matchResources:
namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: f-supply
The binding limits the policy to the test namespace. Actual output from the lab:
$ kubectl -n f-supply run bad --image=busybox:1.37 -- sleep 3600
Error from server (Forbidden): pods "bad" is forbidden: ValidatingAdmissionPolicy 'f-allowed-registries' with binding 'f-allowed-registries' denied request: image outside the allowed registries: busybox:1.37
$ kubectl -n f-supply run ok2 --image=registry.k8s.io/pause:3.10
pod/ok2 created
The test revealed two details. First, a Deployment with a forbidden image is accepted, but the ReplicaSet can’t create pods; the error shows up in kubectl get events with reason FailedCreate. Second, kubectl debug with a forbidden image is also blocked, because the rule includes the pods/ephemeralcontainers subresource. Pods that were already running are not affected: admission only acts on create and update.
To roll this out safely, start with validationActions: ["Warn", "Audit"], watch the warnings and the audit events, and only then switch to Deny. Cleanup: kubectl delete validatingadmissionpolicybinding,validatingadmissionpolicy f-allowed-registries.
Requiring signatures at admission
Restricting the registry doesn’t prove who built the image. For that, the cluster has to verify the cosign signature (and, optionally, attestations such as the SBOM) before accepting the pod. Before automating it, check manually with cosign (the examples follow v3.1.5; I did not run cosign in this lab):
IMG=ghcr.io/your-org/api@sha256:<digest>
cosign verify "$IMG" \
--certificate-identity "https://github.com/your-org/api/.github/workflows/release.yml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com"
# SBOM attestation (CycloneDX) attached by the pipeline
cosign verify-attestation "$IMG" --type cyclonedx \
--certificate-identity "https://github.com/your-org/api/.github/workflows/release.yml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com"
The --certificate-identity / --certificate-oidc-issuer pair is the heart of keyless: it states which workflow and which OIDC issuer must appear in the certificate. A valid signature from a different repository does not pass.
Kyverno: verifyImages
Kyverno (CNCF graduated; v1.20.0 in the research notes for this article) performs verification through a webhook. The CI post already shows basic verifyImages; here the focus is on the fields that harden the policy in the cluster:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: verify-your-org-images
spec:
webhookTimeoutSeconds: 30
background: false
rules:
- name: signature-and-sbom
match:
any:
- resources:
kinds: [Pod]
namespaces: [production]
verifyImages:
- imageReferences:
- "ghcr.io/your-org/*"
failureAction: Audit # start with Audit; switch to Enforce later
mutateDigest: true # replaces the tag with the verified digest
verifyDigest: true # requires the final reference to use a digest
required: true
attestors:
- entries:
- keyless:
issuer: "https://token.actions.githubusercontent.com"
subject: "https://github.com/your-org/api/.github/workflows/release.yml@refs/heads/main"
rekor:
url: https://rekor.sigstore.dev
attestations:
- type: https://cyclonedx.org/bom # CycloneDX SBOM attestation
attestors:
- entries:
- keyless:
issuer: "https://token.actions.githubusercontent.com"
subject: "https://github.com/your-org/api/.github/workflows/release.yml@refs/heads/main"
mutateDigest solves the moving-tag problem automatically: the pod is stored with the digest that was verified. I validated this manifest against the schema of the clusterpolicies.kyverno.io/v1 CRD rendered with helm template (kyverno chart 3.10.0), but I did not install Kyverno on the shared cluster. Recent versions also offer ImageValidatingPolicy (policies.kyverno.io), which is CEL-based; ClusterPolicy verifyImages still works, but check the current docs for the recommended path.
Sigstore policy-controller: ClusterImagePolicy
If you don’t use Kyverno, the Sigstore project’s policy-controller does just this, and does it well:
apiVersion: policy.sigstore.dev/v1beta1
kind: ClusterImagePolicy
metadata:
name: your-org-images
spec:
images:
- glob: "ghcr.io/your-org/**"
authorities:
- keyless:
url: https://fulcio.sigstore.dev
identities:
- issuer: https://token.actions.githubusercontent.com
subject: https://github.com/your-org/api/.github/workflows/release.yml@refs/heads/main
ctlog:
url: https://rekor.sigstore.dev
A detail that trips up many people: according to the chart’s helm template output, the webhook only acts on namespaces with the policy.sigstore.dev/include=true label (kubectl label ns production policy.sigstore.dev/include=true). Without the label, nothing is verified. This manifest was also validated against the chart’s v1beta1 CRD schema, without installing it.
| Tool | What it solves | Operational cost |
|---|---|---|
| ValidatingAdmissionPolicy | allowed registries, simple CEL rules | no extra components |
| Pod Security Admission | pod privileges (not image origin) | no extra components |
Kyverno verifyImages |
signatures, attestations, digest rewriting | webhook + controllers |
| policy-controller | Sigstore signatures and attestations | dedicated webhook |
Combine the layers: VAP for registries, Pod Security restricted on application namespaces (see cluster hardening), and Kyverno or policy-controller for signatures.
Scanning: in the pipeline and inside the cluster
A signature proves origin, not the absence of vulnerabilities. Trivy (v0.76.2 in the notes) scans the image; the flags below were checked against trivy image --help, but I didn’t run the scan because it downloads the vulnerability database:
trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 ghcr.io/your-org/api@sha256:<digest>
trivy image --format cyclonedx --output sbom.cdx.json ghcr.io/your-org/api@sha256:<digest>
In the pipeline, --exit-code 1 fails the build. But new CVEs show up after deployment, so it is worth scanning what is already running too. The Trivy Operator does this inside the cluster and stores the results as Kubernetes resources (vulnerability reports per workload), which you can query with kubectl or export as metrics. Check the current docs for the CRD names and installation options.
The attested SBOM (the type: https://cyclonedx.org/bom in the Kyverno policy) closes the loop: the cluster only accepts images that arrived with an SBOM signed by your pipeline, and that same SBOM lets you answer “where are we using library X?” when the next serious CVE comes out.
Checklist
- Production images referenced by digest (or rewritten to a digest via
mutateDigest) - No
:latest;imagePullPolicyunderstood and explicit where it matters - Private registries with a read-only token or workload identity
- ValidatingAdmissionPolicy restricting registries, rolled out in
Warn/AuditbeforeDeny - Keyless verification with the exact identity and issuer (Kyverno or policy-controller)
- Attested SBOM and continuous scanning of what is running (Trivy Operator)
The cluster is the last checkpoint before code runs: make it demand proof, not just a tag.