Kubernetes Ansible 操作员:修补现有部署失败
Kubernetes Ansible operators: Patch an existing deployment fails
最近开始学习kubernetes和ansible
我有以下 kubernetes 命令来回滚
kubectl patch deployment -n my-namespace mydeployment --type='json' -p='[
{"op": "replace", "path": "/spec/template/spec/containers/0/image",
"value":"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
由于容器是一个数组,补丁命令失败。
我收到以下错误
NewReplicaSetAvailable\\\",\\\"message\\\":\\\"ReplicaSet
\\\\\\\"my-operator-66ff64c9f4\\\\\\\"
has successfully progressed.\\\"}]}}\":
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|..., bigger context
...|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 服务器的命令吗?
错误表明“容器:”是一个数组。
尝试在“my-operaror:”前面添加“-”以表明它是数组中的第一项
最近开始学习kubernetes和ansible
我有以下 kubernetes 命令来回滚
kubectl patch deployment -n my-namespace mydeployment --type='json' -p='[ {"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"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
由于容器是一个数组,补丁命令失败。 我收到以下错误
NewReplicaSetAvailable\\\",\\\"message\\\":\\\"ReplicaSet \\\\\\\"my-operator-66ff64c9f4\\\\\\\" has successfully progressed.\\\"}]}}\": 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|..., bigger context ...|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 服务器的命令吗?
错误表明“容器:”是一个数组。
尝试在“my-operaror:”前面添加“-”以表明它是数组中的第一项