Kubernetes - update ConfigMap programmatically

Viewed 7789

I have a Kubernetes deployment which uses a ConfigMap with some configuration which is frequently updated. Currently I have to update this configuration manually, by running a script on my local machine that updates the ConfigMap via kubectl.

Is there a way to do this in a more automated fashion using the Kubernetes API (from inside or outside Kubernetes)?

2 Answers
def updateConfigMap(token):
   print(token)
   token = "Bearer {}".format(token)
   headers = {"Content-Type": "application/merge-patch+json", "authorization":token}

r = requests.patch("{}/api/v1/namespaces/default/configmaps/CONFIMAPNAME".format(KUBERNETES_MASTER), verify=False, headers=headers, json=configData)
return r.content

I've a some problem at before but when changed the header of PATCH request . I can update my configmaps . But attention to the token permission (Service Account)

Related