Skip to content

Instantly share code, notes, and snippets.

@jessebarocio
Created August 1, 2022 04:17
Embed
What would you like to do?
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