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 →
- FastAPI app with
/versionsthat lists Deployments and returns image tags per container. - Cache results for 30 seconds (or use a watch to keep an in-memory cache) to avoid hammering the API server.
- In-cluster config with a service account allowed
listondeploymentsonly. /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.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateYou need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?BeginnerA Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?Intermediate