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

You want to expose a small Python service that reports deployment versions of all services in the cluster. How do you build it?

IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Read-only internal API backed by the Kubernetes API.

What I'd do →

  1. FastAPI app with /versions that lists Deployments and returns image tags per container.
  2. Cache results for 30 seconds (or use a watch to keep an in-memory cache) to avoid hammering the API server.
  3. In-cluster config with a service account allowed list on deployments only.
  4. /healthz, /readyz, /metrics; run under uvicorn with 2 workers behind a ClusterIP Service.

Why → Caching protects the API server; scoped RBAC limits exposure.

Interview tip → Mention caching; naive per-request list calls on large clusters hurt the control plane.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation