如何通过Linux Cron作业/Kubernetes Cron作业从k8s中删除驱逐的pod



我试图删除Linux cron脚本驱逐的pod,但出现错误

脚本为root@k8> cat evicted.sh

#!/bin/bash
date
echo "Deleting Evcited Pod"
/usr/local/bin/kubectl get po -A | grep Evicted | awk '{system ("kubectl -n " $1 " delete po " $2)}'

输出:

sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found
sh: kubectl: command not found

那么,我怎么能通过linux cron作业或运行容器来删除它呢

检查kubectl(或/usr/local/bin(是否在PATH和/或尝试... | awk '{system ("/usr/local/bin/kubectl -n " $1 " delete po " $2)}'还要考虑引用参数。

最新更新