I have the following kubernetes command
kubectl patch deployment -n my-namespace mydeployment --type='json' -p='[ {"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"192.168.1.1:5000/mydeployment:image_version"} ]
Is any way to introduce a json array in kubernetes ansible command and patch my deployment?
I defined the following role in my playbook
- 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
- 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
Due to the fact that containers is an array , the patch command fails . I get the following error
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\\\
Is any way to do debug or to print the command that actually is sent to kubernetes server?
I will appreciate your help
The question has been posted in stack overflow as well
--
You received this message because you are subscribed to the Google Groups "Operator Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to operator-framew...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/5332f789-91dd-4f70-8638-bc7e352ef8a8n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/operator-framework/012ff306-99d5-42f8-9a9e-cc1e84ae27a1n%40googlegroups.com.
- 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 }}"