Scripts to delete evicted pods across all namespaces
This file contains 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
kubectl get pod --all-namespaces ` | |
| Select-String Evicted ` | |
| % {$_ -Replace '\s{2,}', ' '} ` | |
| ConvertFrom-Csv -Delimiter ' ' -Header "namespace", "pod" ` | |
| foreach { kubectl delete pod $_.pod -n $_.namespace } |
This file contains 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
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