⚡ ~/naveed K8s Hub
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Phase 3 — Security Module 18 of 24 Free & Open Access

Kubernetes Supply Chain Security & Admission Control

Supply chain security makes sure only trusted images run in your cluster. You scan images for known vulnerabilities, sign and verify them, avoid mutable tags such as latest, and use admission control to reject Pods that break policy before they are scheduled. This module covers each step.

Last updated: · By Naveed Ahmed, Certified Kubernetes Administrator

18 - Supply Chain Security & Admission Control

Why this matters

Hardening the cluster and the pods doesn't help if you're deploying a compromised or vulnerable image in the first place. This is "shift left" security applied to k8s.

Read this first — Definitions & Explanations

Supply chain risk

Attackers target images, dependencies, CI pipelines, and registries — not only running Pods.

Admission control for policy

Validating/mutating webhooks (OPA/Gatekeeper, Kyverno) can block bad images, force labels, deny :latest, require signatures, etc.

Image scanning

Scan for CVEs in CI and continuously in registries. Don’t ship known critical vulns blindly.

Image signing / verification

Ensure images come from trusted builders and weren’t tampered with (Sigstore/cosign-style workflows).

Avoid :latest in production

:latest moves. You lose reproducibility and auditability. Pin digests or immutable tags.

Official docs (read for detail)

Key Concepts

YouTube search terms

Hands-on lab (on prod-sim)

# Scan an image for CVEs with Trivy
brew install trivy   # or use the trivy container image
trivy image nginx:1.19   # old version, will show real CVEs
trivy image nginx:latest # compare

# Install Kyverno and write a real policy: block :latest tag cluster-wide
helm repo add kyverno https://kyverno.github.io/kyverno/
helm install kyverno kyverno/kyverno -n kyverno --create-namespace

cat <<EOF | kubectl apply -f -
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: disallow-latest-tag
spec:
  validationFailureAction: Enforce
  rules:
  - name: require-image-tag
    match:
      any:
      - resources:
          kinds: ["Pod"]
    validate:
      message: "Using ':latest' tag is not allowed"
      pattern:
        spec:
          containers:
          - image: "!*:latest"
EOF

# Prove it blocks a bad deployment
kubectl run bad --image=nginx:latest   # should be denied by Kyverno
kubectl run good --image=nginx:1.27    # should succeed

# Add a second policy: require resource limits on every container
cat <<EOF | kubectl apply -f -
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: require-resource-limits
spec:
  validationFailureAction: Enforce
  rules:
  - name: check-resources
    match:
      any:
      - resources:
          kinds: ["Pod"]
    validate:
      message: "CPU and memory limits are required"
      pattern:
        spec:
          containers:
          - resources:
              limits:
                memory: "?*"
                cpu: "?*"
EOF
kubectl run nolimit --image=nginx:1.27   # should be denied (no limits set)

Common mistakes and how to avoid them

  • Using the latest tag. It is mutable, so the same manifest can pull different images over time. Pin a version tag, or better an image digest.
  • Scanning images only at build time. New vulnerabilities are published after you ship. Rescan registry and running images on a schedule.
  • Pulling straight from public registries in production. Public images can change or disappear and may be rate limited. Mirror what you use into a private registry.
  • Setting a webhook failurePolicy of Fail without making it highly available. If the webhook is down, nothing can be created. Run several replicas and exclude system namespaces.
  • Signing images but never verifying them. A signature has no effect unless an admission policy checks it before the Pod is created.

Quick answers

Why avoid the latest tag in production?

The latest tag is mutable, so the same manifest can pull different images over time, which breaks reproducibility and rollbacks. Pin a specific version tag, or better an image digest such as image@sha256:..., so every node runs exactly the image you tested and scanned.

What does admission control do for security?

It checks every Pod and other object before it is stored, so you can enforce policy: block unsigned or untrusted images, forbid privileged Pods, require labels. Tools such as Kyverno, OPA Gatekeeper or Pod Security Admission apply those rules automatically.

How do you verify image signatures in Kubernetes?

Sign images at build time, for example with Cosign, then enforce a policy at admission that rejects images without a valid signature from your key or identity. A policy engine such as Kyverno, or a signature-verifying admission webhook, performs the check when the Pod is created.

Notes

(fill in your own words after watching + labbing)

📋 Self-Assessment Mastery Checklist (4 Competencies)
🧠 Practice Exam Questions (Module 18 MCQs)
⚡ Take Quiz & Save Progress in Tracker

Review these sample exam questions out loud, test your retrieval, and then unlock official scoring in the interactive tracker.

Question 1: Admission controllers can:
  • A. Validate/mutate requests before persistence
  • B. Schedule Pods onto nodes
  • C. Ship logs to Grafana
  • D. Replace kubelet
✓ Correct Answer: A (Validate/mutate requests before persistence)
Option A ('Validate/mutate requests before persistence') is the standard production architectural best practice.
Question 2: Image signing/verification aims to ensure:
  • A. Images come from trusted sources/integrity
  • B. Faster pulls always
  • C. Free LoadBalancers
  • D. Automatic HPA
✓ Correct Answer: A (Images come from trusted sources/integrity)
Option A ('Images come from trusted sources/integrity') is the standard production architectural best practice.
Question 3: Scanning images for CVEs should happen:
  • A. In CI and continuously, not only once
  • B. Only after production incidents
  • C. Only on worker nodes manually
  • D. Never if using latest tag
✓ Correct Answer: A (In CI and continuously, not only once)
Option A ('In CI and continuously, not only once') is the standard production architectural best practice.
Question 4: Avoid :latest in production because:
  • A. It is mutable and hard to track/reproduce
  • B. It disables RBAC
  • C. It breaks DNS
  • D. It cannot be pulled
✓ Correct Answer: A (It is mutable and hard to track/reproduce)
Option A ('It is mutable and hard to track/reproduce') is the standard production architectural best practice.
Question 5: OPA/Gatekeeper or Kyverno are used for:
  • A. Policy-as-code admission controls
  • B. Replacing etcd
  • C. CNI IPAM
  • D. metrics-server
✓ Correct Answer: A (Policy-as-code admission controls)
Option A ('Policy-as-code admission controls') is the standard production architectural best practice.
← Previous Module (17) Pod & Workload Security Next Module (19) → Runtime & Network Security