Last active
April 22, 2020 12:38
-
-
Save nataz77/52696afd38e8e0fe5f68a3e532e43153 to your computer and use it in GitHub Desktop.
Script to delete all failed/evicted pods from a Kubernetes cluster
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
#!/bin/bash | |
#Usage: ./kubecleanup {namespace} | |
if [ -z $1 ] | |
then | |
echo 'No namespace selected, proceeding on default' | |
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod | |
else | |
kubectl get pods -n $1 | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment