Skip to content

Instantly share code, notes, and snippets.

@nataz77
Last active July 14, 2020 07:59
Show Gist options
  • Save nataz77/af416d99210ec33ae5ca32af94c0eccd to your computer and use it in GitHub Desktop.
Save nataz77/af416d99210ec33ae5ca32af94c0eccd to your computer and use it in GitHub Desktop.
Script to delete failed/evicted pods in system namespaces
#!/bin/bash
#Usage: ./kubesystemcleanup.sh
namespaces=( "rook-ceph" "ingress-nginx" "cattle-system" "kube-system" "longhorn-system")
for n in "${namespaces[@]}"
do
kubectl get pods -n $n | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n $n
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment