<p>Trying to patch my custom resource to add extra element into an Array.</p>

<p>Works fine using kubectl:</p>

<pre><code>kubectl patch my-resource default --type=json -p '[ { "op":"add", "path": "/spec/data/-", "value": "3342, 43243.343, 434343" } ]' -v 9
</code></pre>

<p>but can't make it work using Python:</p>

<pre><code>body = '[ { "op":"add", "path":"/spec/data/-", "value": "3342, 43243.343, 434343" } ]'

api_response = api_instance.patch_namespaced_custom_object(group, version, namespace, plural, name, json.loads(body) )
</code></pre>

<p>getting Response</p>

<pre><code>"status":"Failure","message":"json: cannot unmarshal array into Go value of type map[string]interface {}","code":500
</code></pre>

<p>weirdly when I drop [ ] and just pass a {}</p>

<pre><code>api_response = api_instance.patch_namespaced_custom_object(group, version, namespace, plural, name, json.loads('{ "spec": { "data": [ "3342, 43243.343, 434343" ] } } ') )
</code></pre>

<p>it works, but the effect is not what I want - it overwrites the "data" Array completely, whilst I want to append.</p>

<p>What am I missing?</p>

<p>Might be too late for this, but here it goes anyway...</p>
<p>Kubernetes Python API supports JSON-merge patching strategy only: <a href="https://github.com/kubernetes-client/python/blob/96dade6021dc2e9ee1430172e1b65d9e9e232b10/kubernetes/client/api/custom_objects_api.py#L2943" rel="nofollow noreferrer">https://github.com/kubernetes-client/python/blob/96dade6021dc2e9ee1430172e1b65d9e9e232b10/kubernetes/client/api/custom_objects_api.py#L2943</a></p>
<p>That strategy implies you can't extend arrays: <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment</a></p>
