#!/bin/bash

while true;do
    sleep 30
    rancher_error_list=`kubectl get pod -n cattle-system | grep -v grep | grep -v Running | grep -v Completed | grep -v NAME | awk -F " " '{print $1}'`
    for error_pod in $rancher_error_list;do
        kubectl delete pod $error_pod -n cattle-system
    done
done
