kubernetes-client icon indicating copy to clipboard operation
kubernetes-client copied to clipboard

Adding data to configMap errors

Open sonisaurabh19 opened this issue 5 years ago • 0 comments

This is the configMap I am trying to update and add data to:

kind: ConfigMap
apiVersion: v1
metadata:
  name: my-config-map
data:
  users.json: |-
  [
    {
      name: 'user-one',
      age: 10
    }
  ]

I tried the following code, but it fails:

const addToConfig = {
  data: {
    "users.json": {
      name: 'user-two',
      age: 12
    }
  }
}

await kubeclient.api.v1.namespaces('my-namespace').configmaps('my-config-map').patch({ body: addToConfig})

How can I use the API to update the configMap and append data to the users.json array?

sonisaurabh19 avatar Aug 21 '20 22:08 sonisaurabh19