Lab & Completion

What You Will Produce

On your own kind cluster, the platform’s images verified the way the cluster verifies them. You compare the digest a running pod pulled with the one the registry reports for its tag. You check the backend’s signature against the identity the policy requires - and against the wrong one, where the error names the real signer - and read the SBOM from the registry. You watch an unsigned image from the platform’s own registry get refused in develop and only reported in lab, and a signed image get refused because its SBOM sits where the verifier does not look. Then you change what the policy requires on a branch and watch its test refuse the change.

Before You Start

The baseline from Chapter 00 must be clean:

flux --context kind-sre-control-plane get kustomizations -A          # every row READY=True and SUSPENDED=False
kubectl --context kind-sre-control-plane get pods -A --no-headers | grep -vE 'Running|Completed'   # prints nothing
make smoke-test                     # Fail: 0

You need cosign 3.0 or newer, the Kyverno CLI 1.19 or newer, jq, yq and Docker (make check-tools lists them all), and network access to ghcr.io and Sigstore. On macOS: brew install cosign kyverno jq yq. On Linux (amd64) - the binary renamed to cosign, the kyverno executable taken out of its archive, both made executable and put on your PATH:

curl -sSfLo cosign https://github.com/sigstore/cosign/releases/download/v3.1.3/cosign-linux-amd64
curl -sSfL https://github.com/kyverno/kyverno/releases/download/v1.19.1/kyverno-cli_v1.19.1_linux_x86_64.tar.gz | tar -xz kyverno
chmod +x cosign kyverno && sudo mv cosign kyverno /usr/local/bin/
cosign version; kyverno version     # cosign 3.x, kyverno 1.19.x

Your fork must be up to date: if kubectl --context kind-sre-control-plane get imagevalidatingpolicies lists nothing, open your fork on GitHub, click Sync fork → Update branch, then git switch main && git pull, and let Flux catch up.

The Lab in Three Parts

  • A. Verify - the baseline, the policy’s two copies, and the digest a running pod pulled.
  • B. Break & Fix - who signed the image and what is inside it; an unsigned image refused and reported; a signed image refused for evidence the verifier cannot see; an SBOM-format change to the policy caught by its test.
  • C. Rollback & Cleanup - the lab pods deleted, the baseline.

Open the lab →

Done When

  • you can say which copy of the policy acts where, and what happens when Kyverno cannot answer (A2)
  • the running backend pod’s imageID matches the digest the registry reports for its tag, and you can say what gap remains (A3)
  • your prediction was written before B2 (B1)
  • the backend image verified against its own workflow, and the wrong identity’s error named the real signer (B2)
  • you saw one SBOM per platform, and read the package count and two versions from the one for your nodes’ architecture (B3)
  • unsigned-demo was refused in develop, and in lab admitted with fail on the pod and in its PolicyReport (B4)
  • the mixed-format frontend image passed cosign verify, failed the SBOM check, and was refused - and cosign tree showed why (B5)
  • the format change failed tests/kyverno-supply-chain.test.sh, and the branch was thrown away (B6)
  • you found why the old Guardian image is refused and what fixes it, before reading the answer (B7)
  • the lab pods are gone and the baseline is clean (C1-C2)

Knowledge Check

Before finishing this chapter, complete the Quiz.