我最近开始学习 kubernetes 和 ansible。
我有以下 kubernetes 命令来进行回滚
kubectl 补丁部署 -n my-namespace mydeployment --type='json' -p='[ {"op": "replace", "path": "/spec/template/spec/containers/0/image", "值":"127.0.0.1:5050/mydeployment:image_version"} ]
有什么方法可以在 kubernetes ansible 命令中引入 json 数组并修补我的部署?
我尝试过的是我的剧本中的以下内容
- name: Demo
k8s:
api_version: apps/v1
kind: Deployment
state: present
namespace: '{{ meta.namespace }}'
name: my-operator
definition: |
spec:
template:
spec:
containers:
my-operator:
image: {{ installed_software_image }}
register: output
由于容器是一个数组,patch 命令会失败。我收到以下错误
NewReplicaSetAvailable\\\\\\",\\\\\\"message\\\\\\":\\\\\\"ReplicaSet \\\\\\\\\\\\\\"my- operator-66ff64c9f4\\\\\\\\\\\\\\" 进展顺利。\\\\\\"}]}}\\": v1.Deployment.Spec: v1.DeploymentSpec.Template: v1 .PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: decode slice: expect [ or n, but found {, error found in #10 byte of ...|tainers\\":{\\"new -opera|...,更大的上下文 ...|t\\":\\"2021-03-24T22:26:02Z\\"}},\\"spec\\":{\\"containers\ \":{\\"my-operator\\":\\"image:\\\\\\"27.0.0.1:5050/my-ope|...","field":"patch"}] },"code":422}\n'", "reason": "Unprocessable Entity", "status": 422}
有什么方法可以进行调试或打印实际发送到 kubernetes 服务器的命令?