Your CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.
IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer
Situation read → Build caches and old images accumulate on long-lived runners.
What I'd do →
- Script with the Docker SDK:
containers.prune(),images.prune(filters={"dangling": True}), then remove images older than N days not in an allow-list, andapi.prune_builds()for BuildKit cache. - Run it as a scheduled job and log space reclaimed.
- Alert on disk above 80% (node exporter).
- Better: ephemeral runners that start clean each job.
Why → Pruning treats the symptom; ephemeral runners remove the cause.
Interview tip → Mention build cache, which docker image prune does not touch.
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?AdvancedYou 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