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
255 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 35,800 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,360 points
51 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,500 points
137 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,040 points
169 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
487 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,149 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,233 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.