Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuism committed Sep 8, 2024
1 parent 7fe65c2 commit 98f26ca
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions scripts/cleanup
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/bin/sh

#!/bin/bash

kubectl get pod -A --field-selector status.phase=Failed
CONTEXT=ceph-k8s



kubectl --context $CONTEXT get pod -A --field-selector status.phase=Failed

kubectl delete pods -A --field-selector status.phase=Failed
kubectl --context $CONTEXT delete pods -A --field-selector status.phase=Failed

for ns in $(kubectl get po -A --no-headers | grep -v Running | awk {'print $1'}); do
delpods=$(kubectl get pods --no-headers -n $ns | grep -E 'Evicted|Completed|ErrImagePull|Failed' | awk '{print $1 }')
for ns in $(kubectl --context $CONTEXT get po -A --no-headers | grep -v Running | awk {'print $1'}); do
delpods=$(kubectl --context $CONTEXT get pods --no-headers -n $ns | grep -E 'Evicted|Completed|ErrImagePull|Failed' | awk '{print $1 }')
echo delpods=$delpods
for i in $delpods; do
echo deleting $ns/$i
# kubectl delete pod $i --force=true --wait=false --grace-period=0 -n $ns
kubectl delete pod $i -n $ns
# kubectl --context $CONTEXT delete pod $i --force=true --wait=false --grace-period=0 -n $ns
kubectl --context $CONTEXT delete pod $i -n $ns
done
done

0 comments on commit 98f26ca

Please sign in to comment.