CKS: Supply Chain Security
20% of the CKS exam, 4 competencies. Back to the CKS overview.
Each competency lists what to know and the official documentation to read, then a demo you can run. Demos run on the demo lab, a throwaway kind cluster on your own machine; set it up once before you start.
Minimize base image footprint
Section titled “Minimize base image footprint”Know
- Use distroless or minimal base images and multi-stage builds; fewer packages means fewer vulnerabilities.
Read
Demo: Fewer packages, fewer findings
-
Compare the size and content of two images from the same project.
Terminal window docker pull registry.k8s.io/e2e-test-images/agnhost:2.66.1 && docker pull registry.k8s.io/pause:3.10.2docker images --format '{{.Repository}}:{{.Tag}} {{.Size}}' | grep -E 'agnhost|pause' -
Scan both with Trivy v0.76.2.
Terminal window trivy image --severity HIGH,CRITICAL --quiet registry.k8s.io/e2e-test-images/agnhost:2.66.1 | tail -5trivy image --severity HIGH,CRITICAL --quiet registry.k8s.io/pause:3.10.2 | tail -5 -
Build a minimal image yourself: compile in one stage, ship only the binary.
Terminal window mkdir -p mini && cat > mini/main.go <<'EOF'package mainimport ("fmt"; "net/http")func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "hi") }); http.ListenAndServe(":8080", nil) }EOFcat > mini/Dockerfile <<'EOF'FROM golang:1.26 AS buildWORKDIR /srcCOPY main.go .RUN go mod init mini && CGO_ENABLED=0 go build -o /app .FROM scratchCOPY --from=build /app /appUSER 65534ENTRYPOINT ["/app"]EOFdocker build -t demo/mini:1.0 mini/ && docker images demo/mini:1.0
What you should see: agnhost is an Alpine-based test image with a shell and tools; pause is a single static binary of under a megabyte, and its scan has nothing to report. The scratch image contains only your binary: no shell for an attacker, and no OS packages to patch.
Note: The build stage pulls golang:1.26 from Docker Hub. Pin it by digest in real pipelines.
Clean up:
rm -rf miniUnderstand your supply chain (e.g. SBOM, CI/CD, artifact repositories)
Section titled “Understand your supply chain (e.g. SBOM, CI/CD, artifact repositories)”Know
- Know every step from source to running pod, and generate an SBOM for each image.
Read
Demo: Generate an SBOM and scan it later
-
Generate a CycloneDX SBOM for an image.
Terminal window trivy image --format cyclonedx --output agnhost.cdx.json registry.k8s.io/e2e-test-images/agnhost:2.66.1jq '.components | length' agnhost.cdx.jsonjq -r '.components[] | select(.type=="library" or .type=="operating-system") | "\(.name) \(.version)"' agnhost.cdx.json | head -
Scan the SBOM instead of the image: the same check, without pulling anything.
Terminal window trivy sbom --severity HIGH,CRITICAL --quiet agnhost.cdx.json | tail -5 -
Do the same for Kubernetes itself: the project publishes SBOMs for every release.
Terminal window curl -Ls https://sbom.k8s.io/v1.37.2/release | grep -c '^PackageName:'
What you should see: The SBOM lists the OS packages and libraries inside the image. Keep it next to the image in your registry: when a new CVE is announced you can search SBOMs for the affected component across every image you ship, without rescanning them all.
Note: Trivy itself was hit by a supply chain attack in March 2026 (malicious v0.69.4 binaries and v0.69.5 and v0.69.6 images were published briefly). Install it from the official release, verify the checksum, and pin the version.
Clean up:
rm -f agnhost.cdx.jsonSecure your supply chain (permitted registries, sign and validate artifacts, etc.)
Section titled “Secure your supply chain (permitted registries, sign and validate artifacts, etc.)”Know
- Allow only approved registries with admission policy, and verify image signatures before admission.
Read
Demo: Allow only one registry, and verify signatures
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cks-supplykubectl config set-context --current --namespace=cks-supply -
A ValidatingAdmissionPolicy that only admits images from registry.k8s.io in labelled namespaces.
Terminal window kubectl label namespace cks-supply supply-chain=strictkubectl apply -f - <<'EOF'apiVersion: admissionregistration.k8s.io/v1kind: ValidatingAdmissionPolicymetadata:name: allowed-registriesspec:failurePolicy: FailmatchConstraints:resourceRules:- apiGroups: [""]apiVersions: ["v1"]operations: ["CREATE", "UPDATE"]resources: ["pods"]validations:- expression: "object.spec.containers.all(c, c.image.startsWith('registry.k8s.io/')) && (!has(object.spec.initContainers) || object.spec.initContainers.all(c, c.image.startsWith('registry.k8s.io/')))"message: "images must come from registry.k8s.io"---apiVersion: admissionregistration.k8s.io/v1kind: ValidatingAdmissionPolicyBindingmetadata:name: allowed-registriesspec:policyName: allowed-registriesvalidationActions: ["Deny"]matchResources:namespaceSelector:matchLabels:supply-chain: strictEOFsleep 3kubectl run ok --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- pausekubectl run nope --image=docker.io/library/busybox:1.37 -- sleep 3600 -
Verify the signature on an official Kubernetes image with cosign v3.1.4.
Terminal window cosign verify registry.k8s.io/kube-apiserver-amd64:v1.37.2 \--certificate-identity krel-trust@k8s-releng-prod.iam.gserviceaccount.com \--certificate-oidc-issuer https://accounts.google.com | jq '.[0].critical.image'
What you should see: ok is admitted and nope is rejected with your message. Note startsWith on a string prefix: registry.k8s.io.evil.example/ would also pass, which is why the check includes the trailing slash. cosign prints the verified image digest; to enforce signatures at admission time use a policy controller such as Kyverno or the Sigstore policy-controller.
Clean up:
kubectl delete validatingadmissionpolicybinding allowed-registrieskubectl delete validatingadmissionpolicy allowed-registrieskubectl config set-context --current --namespace=defaultkubectl delete namespace cks-supplyPractise
- Write a ValidatingAdmissionPolicy that rejects images not from your registry.
Perform static analysis of user workloads and container images (e.g. Kubesec, KubeLinter)
Section titled “Perform static analysis of user workloads and container images (e.g. Kubesec, KubeLinter)”Know
- Scan manifests for risky settings and images for known CVEs before they reach the cluster.
Read
Demo: Lint manifests before they reach the cluster
-
A manifest with typical problems.
Terminal window mkdir -p manifests && cat > manifests/risky.yaml <<'EOF'apiVersion: apps/v1kind: Deploymentmetadata:name: riskyspec:replicas: 1selector:matchLabels:app: riskytemplate:metadata:labels:app: riskyspec:hostNetwork: truecontainers:- name: appimage: docker.io/library/nginx:latestsecurityContext:privileged: trueEOF -
Scan it with Trivy’s misconfiguration checks and with KubeLinter v0.8.3.
Terminal window trivy config --severity HIGH,CRITICAL manifests/kube-linter lint manifests/risky.yaml
What you should see: Both tools flag the privileged container, host networking, the latest tag, and the missing resource limits and read-only root filesystem. Run them in CI and fail the merge request; kubesec and Checkov do the same job with different rule sets.
Note: Install kube-linter (and kubesec, if you want to compare) from their GitHub release pages at a pinned version.
Clean up:
rm -rf manifestsDomain and competency names are from the CNCF CKS curriculum (v1.37), cncf/curriculum, licensed CC BY 4.0. Summaries, demos, and exercises are original to this site.