我正在尝试运行一个命令,该命令如下所述更改kubernetes cronjob图像值。但是,而不是将此命令键入CMD,而是试图通过容器注册表的构建触发器运行它。
我尝试了'和作为逃生炭。
steps:
- name: 'gcr.io/cloud-builders/kubectl'
args: [
"patch",
"cronjob",
"cron-history-orders",
"--type=json",
"-p=[{'"op'":'"replace'",'"path'":'"/spec/jobTemplate/spec/template/spec/containers/0/image'",'"value'":'"python:3.5'"}]"
]
env: ['CLOUDSDK_COMPUTE_ZONE=europe-west3-c','CLOUDSDK_CONTAINER_CLUSTER=xxx-prod']
或当我尝试
时 "-p='[{"op":"replace", "path": "/spec/jobTemplate/spec/template/spec/containers/0/image", "value":"python:3.5"}]'"
或
"-p='[{'op':'replace','path':'/spec/jobTemplate/spec/template/spec/containers/0/image','value':'python:3.5'}]'"
我得到error loading template: json: cannot unmarshal object into Go value of type []json.RawMessage
毫无疑问,这里的挑战是您正在处理逃脱的层 - 您的yaml包含将通过命令行传递的JSON。
我能够通过此YAML通过此命令:
steps:
- name: 'gcr.io/cloud-builders/kubectl'
args: [ "patch", "cronjob", "cron-history-orders", "--type=json", "-p='[{"op":"replace", "path": "/spec/jobTemplate/spec/template/spec/containers/0/image", "value":"python:3.5"}]'" ]
env: ['CLOUDSDK_COMPUTE_ZONE=europe-west3-c','CLOUDSDK_CONTAINER_CLUSTER=xxx-prod']