Skip to content

Instantly share code, notes, and snippets.

@jessebarocio
Created August 1, 2022 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessebarocio/8da74b9e5daed56a2a945b46805ca99b to your computer and use it in GitHub Desktop.
Save jessebarocio/8da74b9e5daed56a2a945b46805ca99b to your computer and use it in GitHub Desktop.
Scripts to delete evicted pods across all namespaces
kubectl get pod --all-namespaces `
| Select-String Evicted `
| % {$_ -Replace '\s{2,}', ' '} `
| ConvertFrom-Csv -Delimiter ' ' -Header "namespace", "pod" `
| foreach { kubectl delete pod $_.pod -n $_.namespace }
kubectl get pod --all-namespaces | \
grep 'Evicted' | \
while read line; \
do
namespace=$(echo $line | awk '{print $1}');
pod=$(echo $line | awk '{print $2}');
kubectl delete pod $pod -n $namespace;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment