Appendix: Instructor Notes — Registry Signing + Admission Verification (Kyverno)
What students will do (6 steps)
- Start/choose a registry
- Build → promote → push image
- Sign the pushed image with cosign
- Install Kyverno and apply a verifyImages policy (using your
cosign.pub) - Prove enforcement (unsigned image rejected)
- Deploy signed image, collect evidence
Two variables to set (put these on a slide)
export IMAGE_REG=localhost:5000/ # or your class registry, e.g., registry.class.tld:5000/
export VERIFY_IMAGE_PATTERN='"localhost:5000/ship-securely/*"' # pattern Kyverno must enforce
If you’re using a shared registry, replace
localhost:5000with the class registry host and keep the trailing slash.
One-time prep (everyone)
cosign generate-key-pair # creates cosign.key / cosign.pub
make kyverno-install # installs Kyverno (Helm)
6-Command student runbook (copy/paste)
1) Start a local registry (skip if you provide a class registry)
make reg-up # starts localhost:5000 via docker compose
2) Build → promote → push to the registry
IMAGE_REG=$IMAGE_REG make build promote
docker push ${IMAGE_REG}ship-securely/app:good-$(date +%Y%m%d)-$(git rev-parse --short HEAD)
3) Sign the image in the registry (OCI signature)
IMAGE_REG=$IMAGE_REG make sign_image_registry
IMAGE_REG=$IMAGE_REG make verify_image_registry # writes artifacts/cosign-image-verify.txt
4) Enforce at admission (Kyverno verifyImages with your public key)
VERIFY_IMAGE_PATTERN=$VERIFY_IMAGE_PATTERN make kyverno-apply-verify
# (this generates policies/verify-image-signatures.yaml from cosign.pub and applies all policies/)
5) Prove it blocks an unsigned image
# create/push an unsigned tag
docker tag ${IMAGE_REG}ship-securely/app:good-$(date +%Y%m%d)-$(git rev-parse --short HEAD) \
${IMAGE_REG}ship-securely/app:unsigned-$(date +%Y%m%d)-$(git rev-parse --short HEAD)
docker push ${IMAGE_REG}ship-securely/app:unsigned-$(date +%Y%m%d)-$(git rev-parse --short HEAD)
# try to deploy the unsigned tag (expect admission rejection)
kubectl -n ship set image deploy/app app=${IMAGE_REG}ship-securely/app:unsigned-$(date +%Y%m%d)-$(git rev-parse --short HEAD) || true
kubectl -n ship apply -f infra/k8s/deployment.yaml 2>&1 | tee artifacts/policy-tests.txt
6) Deploy the signed image + collect evidence
# point back to the signed GOOD tag
kubectl -n ship set image deploy/app app=${IMAGE_REG}ship-securely/app:good-$(date +%Y%m%d)-$(git rev-parse --short HEAD)
# optional: re-run ZAP and metrics, and zip the pack
make zap-k8s
make metrics
make evidence
Evidence students should see (already wired in Makefile)
artifacts/cosign-image-verify.txt— proof the registry signature verifiespolicies/verify-image-signatures.yaml— the exact Kyverno verify policy usedartifacts/policy-tests.txt— admission rejection for the unsigned imageartifacts/sbom.json,artifacts/sbom-image.json,artifacts/sbom.bundle,artifacts/cosign-verify.txtartifacts/trivy-image.json,artifacts/semgrep.sarif,artifacts/checkov.json,artifacts/hadolint.txt- (if run)
artifacts/zap/report.html,artifacts/falco-last10m.log, metrics snapshot
Troubleshooting slide (quick hitters)
Policy didn’t enforce?
- Confirm
kyverno-admission-controlleris Ready:kubectl -n kyverno get deploy/kyverno-admission-controller - Verify policy target pattern matches your registry:
grep imageReferences policies/verify-image-signatures.yaml - Re-apply policies:
make kyverno-apply
- Confirm
Verify fails (
cosign verify …):- Ensure you pushed the GOOD tag to the registry before signing.
- Make sure
cosign.pubmatches the key used to sign.
Students using Windows: run in Git Bash / WSL; ensure Docker Desktop is running.
Optional: Offline mode (no registry)
If someone can’t reach a registry, they can still produce cryptographic proof:
make cd # builds, scans, promotes, deploys locally
make sign_image # signs the image digest as a blob (offline)
make verify_image # writes artifacts/cosign-image-verify.txt (offline)
make evidence
This doesn’t enable admission enforcement (no registry signature present), but it’s valid for the evidence pack.
Instructor checklist (before class)
- Choose and announce
IMAGE_REG(e.g.,registry.class.tld:5000/orlocalhost:5000/) - Put
VERIFY_IMAGE_PATTERNon a slide (e.g.,"registry.class.tld:5000/ship-securely/*") - Validate Kyverno install on your Minikube:
make kyverno-install && make kyverno-apply - Dry run the 6 commands end-to-end; confirm
policy-tests.txtshows rejection text - Ensure students have Docker, Minikube, kubectl, helm, cosign available (your Part I installs)
Want me to generate a single “Student Handout” PDF page from this (markdown source) you can print or share?