Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

How would you use Python to check that every Docker image running in your cluster comes from your approved registry?

IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Supply-chain audit.

What I'd do →

  1. List all pods; collect spec.containers[].image, initContainers and ephemeralContainers.
  2. Normalize references (no registry means docker.io/library/); compare against an allowed prefix list (123456789012.dkr.ecr.ap-south-1.amazonaws.com/).
  3. Also check status.containerStatuses[].imageID for the actual digest running.
  4. Enforce with an admission policy (Kyverno verifyImages or a registry restriction policy).

Why → Normalization catches images that look private but are pulled from Docker Hub.

Interview tip → Mention implicit docker.io and digest vs tag.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation