Question 39
Domain 5: Observability, Troubleshooting, and MaintenanceWhich kubectl command best cleans up all local containers and images created on a node?
Correct answer: C
Explanation
"crictl rmi --prune" removes unused local images, and "crictl rm -a" removes all containers. Together, they clean up both containers and images created on the node, which is the full local runtime cleanup the question asks for.
Why each option is right or wrong
A. kubectl delete pods --all --force
B. kubectl get all --all-namespaces
C. crictl rmi --prune && crictl rm -a
The Container Runtime Interface (CRI) tool `crictl` is the correct utility here, not `kubectl`, because image and container cleanup is performed against the node’s runtime, not the Kubernetes API. Per the `crictl` command set, `rmi --prune` deletes all unused local images, and `rm -a` removes every container in the runtime, so the pair exhausts both categories the question asks about on that node.
D. kubectl rollout restart deployment --all