Created
March 27, 2024 20:35
-
-
Save sub314xxl/3b576492c28a35f1c2b4d85a8247ed69 to your computer and use it in GitHub Desktop.
clean up k8s 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
for ns in $(kubectl get ns -o name | cut -d'/' -f2); do | |
for pod in $(kubectl get pods -n $ns --field-selector=status.phase!=Running -o name | cut -d'/' -f2); do | |
kubectl delete pod -n $ns $pod | |
done | |
for rs in $(kubectl get rs -n "$ns" -o name | cut -d'/' -f2); do | |
kubectl delete rs -n $ns $rs | |
done | |
done | |
kubectl get pods -A && kubectl top pods -A && kubectl top node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment