#!/bin/bash
# This script check the passed namespace and delete pods in 'CrashLoopBackOff state
NAMESPACE="test"
delpods=$(sudo kubectl get pods -n ${NAMESPACE} |
grep -i 'CrashLoopBackOff' |
awk '{print $1 }')
for i in ${delpods[@]}; do
sudo kubectl delete pod $i --force=true --wait=false
--grace-period=0 -n ${NAMESPACE}
done