无法通过Helm发送单行命令



我正在尝试使用helm设置CronJob。我的工作模板部分如下

jobTemplate:
metadata:
creationTimestamp: null
spec:
backoffLimit: 3
template:
metadata:
creationTimestamp: null
spec:
containers:
- args:
- >
POD_LIST=($(kubectl get pod
--field-selector=status.phase=Succeeded -n ex-namespace -l
tekton.dev/pipeline |  awk '$5 ~
/(^[6-9][0-9]*|^[1-5][0-9]+)d.*/ {print $1}')); for podname in
$POD_LIST; do;
echo "deleting pod $podname";
kubectl delete pod -n ex-namespace $podname;
done;
command:
- /bin/sh
- '-c'
image: > kubctlImage
imagePullPolicy: IfNotPresent
name: cleanup-completed-pods
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
serviceAccount: ral-tekton
serviceAccountName: ral-tekton
terminationGracePeriodSeconds: 30
schedule: 0 0 * * *
startingDeadlineSeconds: 200
successfulJobsHistoryLimit: 3

当这个作业触发时,我在pod日志中得到以下错误。

"bin/sh:1:语法错误:"("出乎意料"的

很明显,这是一个shell脚本错误,但不确定我在这里缺少了什么?

有人能帮我在这里找到shell错误吗?

p.s:我复制了命令,将其转换为单行,并尝试了我的mac的/bin/sh shell,似乎正在工作。

可能工作,假设您的kubectl图像具有gawk

- args:
- >
for podname in $(kubectl get pod
--field-selector=status.phase=Succeeded -n ex-namespace -l
tekton.dev/pipeline | awk '$5 ~
/(^[6-9][0-9]*|^[1-5][0-9]+)d.*/ {print $1}'); do
echo "deleting pod $podname";
kubectl delete pod -n ex-namespace $podname;
done;

最新更新