Interview Prep/Python for DevOps/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?

BeginnerScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Read-only audit with the Kubernetes client.

What I'd do →

  1. config.load_kube_config(), then CoreV1Api().list_pod_for_all_namespaces(limit=500), paginating with _continue.
  2. For each container (including init containers), check container.resources.limits for cpu and memory; resources.limits can be None.
  3. Output namespace, pod, owner (from metadata.owner_references), container and missing limits as CSV.
  4. Long term: enforce with a LimitRange or an admission policy (Kyverno, Gatekeeper, or ValidatingAdmissionPolicy).

Why → Reports find existing gaps; admission policies stop new ones.

Interview tip → Report by owner (Deployment), not pod, so teams can fix the source.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation