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 →
config.load_kube_config(), thenCoreV1Api().list_pod_for_all_namespaces(limit=500), paginating with_continue.- For each container (including init containers), check
container.resources.limitsforcpuandmemory;resources.limitscan beNone. - Output namespace, pod, owner (from
metadata.owner_references), container and missing limits as CSV. - 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.
More on Kubernetes, Docker, SSH & fleet automation
You 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?IntermediateYou want to validate all Kubernetes manifests in a repo in CI with Python. What would the script check?Intermediate