Kubernetes - update ConfigMap programmatically

0 votes
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?
Sep 3, 2018 in Kubernetes by Hannah
• 14,080 points
393 views

1 answer to this question.

0 votes

If you know Python, you can do something like this

from __future__ import print_statement 
import time 
import kubernetes.client from kubernetes.client.rest 
import ApiException from pprint import pprint
# Configure API key authorization: BearerToken 
kubernetes.client.configuration.api_key['authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# kubernetes.client.configuration.api_key_prefix['authorization'] = 'Bearer'
# create an instance of the API class api_instance = 
kubernetes.client.CoreV1Api() 
name = 'name_example' # str | name of the ConfigMap 
namespace = 'namespace_example' # str | object name and auth scope, such as for teams and projects 
body = NULL # object |  
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
try: 
    api_response = api_instance.patch_namespaced_config_map(name, namespace, body, pretty=pretty)
    pprint(api_response) 
except ApiException as e:
    print("Exception when calling CoreV1Api->patch_namespaced_config_map: %s\n" % e)

answered Sep 3, 2018 by Kalgi
• 37,320 points

Related Questions In Kubernetes

+1 vote
4 answers
+5 votes
2 answers

Redirecting host to service path in kubernetes

What you are trying to do is ...READ MORE

answered Mar 27, 2018 in Kubernetes by DragonLord999
• 8,380 points
69 views
0 votes
1 answer

unable to start Kubernetes due to so many open files in system

You can try the following steps: You can ...READ MORE

answered May 1, 2018 in Kubernetes by shubham
• 6,810 points
169 views
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,240 points
243 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
1,069 views
+3 votes
1 answer
0 votes
2 answers

Restart pods when configmap updates in Kubernetes?

Use Deployments, and consider your ConfigMaps to ...READ MORE

answered Aug 31, 2018 in Kubernetes by Nilesh
• 6,900 points
2,798 views
0 votes
3 answers

Kubernetes dashboard status-CrashLoopBackOff

I had the same issue, struggled for days. ...READ MORE

answered Apr 24 in Kubernetes by Bebo
1,693 views