Tuesday, August 27, 2019

Tip: Clean evicted pods and dangling docker images

Clean evicted pods

kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c

Clean dangling docker images. 

A dangling image is one that is not tagged and is not referenced by any container.
docker image prune -a -f --filter "until=24h"

No comments:

Post a Comment