Last active
May 11, 2022 12:15
-
-
Save clarkmcc/874af0371fbc644a5ba80d609d25a32b to your computer and use it in GitHub Desktop.
Deletes Kubernetes pods with a status of Shutdown that are usually left over after a GKE pre-emptible node goes offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for namespace in $(kubectl get ns | awk '{print $1}' | grep -v NAME); do | |
for pod in $(kubectl get pod -n $namespace --field-selector=status.phase!=Running | grep Shutdown | awk '{print $1}' | grep -v NAME); do | |
kubectl delete pod -n "$namespace" "$pod" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment