Kubernetes ConfigMap Key Delete with Requests Python

11/22/2018

I want to delete key with data from Kubernetes Configmap , so that I want to use kubernetes Rest endpoints .

There is my code block .

          headers = {"Content-Type": "application/merge-patch+json", "Authorization": "Bearer " + self.token, "Accept": "application/json"}

    r = requests.patch("{}/api/v1/namespaces/default/configmaps/CONFIGMAP_NAME".format(self.url), verify=False,
                       headers=headers, json={"op": "remove", "path": "/data/CONFIGMAPKEYNAME"})

This code working and returning result as 200 status code but , I cannot see any changing at my kubernetes configmaps count .

How I can handle this problem .

-- ColossusMark1
curl
kubernetes
python
rest

1 Answer

11/23/2018

What are you trying to achieve? This will only delete a key from ConfigMap, not the ConfigMap itself. Configmap count will stay the same, as it can exist without any keys.

-- edbighead
Source: StackOverflow