Skip to content

Instantly share code, notes, and snippets.

@sub314xxl
Created March 27, 2024 20:35
Show Gist options
  • Save sub314xxl/3b576492c28a35f1c2b4d85a8247ed69 to your computer and use it in GitHub Desktop.
Save sub314xxl/3b576492c28a35f1c2b4d85a8247ed69 to your computer and use it in GitHub Desktop.
clean up k8s cluster
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