运行shell命令的kubernetes pod.yaml中出现语法错误

运行shell命令的kubernetes pod.yaml中出现语法错误,shell,docker,kubernetes-pod,Shell,Docker,Kubernetes Pod,团队,我有一个有效的命令,但无法理解从pod.yaml运行的语法。有什么提示吗 apiVersion: v1 kind: Pod metadata: name: count_mounts labels: purpose: demonstrate_command spec: containers: - name: command-demo-container image: debian command: ["/bin/bash"] args: ["-

团队,我有一个有效的命令,但无法理解从pod.yaml运行的语法。有什么提示吗

apiVersion: v1
kind: Pod
metadata:
  name: count_mounts
  labels:
    purpose: demonstrate_command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["/bin/bash"]
    args: ["-c", echo $HOSTNAME && mount | grep -Ec '/dev/sd.*\<csi' | awk '$0 <= 64  { print "Mounts are less than 64, that is found", $0 ;} $0 > 64  { print "Mounts are more than 64", $0 ;}']
  restartPolicy: OnFailure
预期产出:


node123
Mounts are less than 64, that is found 0
kubectl logs pod/command-demo
node123
Mounts are less than 64, that is found 0
关于无吊舱的本地系统

└─ $ ▶ echo $HOSTNAME && mount | grep -Ec '/dev/sd.*\<csi' | awk '$0 <= 64  { print "Mounts are less than 64, that is found", $0 ;} $0 > 64  { print "Mounts are more than 64", $0 ;}'

node123
Mounts are less than 64, that is found 0


└─ $ ▶ echo$HOSTNAME&&mount | grep-Ec'/dev/sd.\我用下面的方法解决了这个问题,但我肯定想知道如何使用嵌套引号

apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["/bin/bash", "-c"]
    args:
      - |
        echo $HOSTNAME && mount | grep -Ec '/dev/sd.*\<csi' | awk '$0 <= 64  { print "Mounts are less than 64, that is found", $0 ;} $0 > 64  { print "Mounts are more than 64", $0 ;}'
  restartPolicy: OnFailure

你需要引用你所有的参数,但你会得到嵌套
kubectl logs pod/command-demo
node123
Mounts are less than 64, that is found 0