Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl update configMap

Tags:

kubernetes

I am using the following command to create a configMap.

kubectl create configmap test --from-file=./application.properties --from-file=./mongo.properties --from-file=./logback.xml  

Now, I have modified a value for a key from mongo.properties which i need to update in kubernetes.

Option1 :-

kubectl edit test 

Here, it opens the entire file. But, I want to just update mongo.properties and hence want to see only the mongo.properties. Is there any other way?

Note :- I dont want to have mongo.properties in a separate configMap.

Thanks

like image 711
user1578872 Avatar asked Apr 23 '18 21:04

user1578872


People also ask

How do I update Kubernetes ConfigMap?

Updating the config map in Kubernetes POD requires the restart of POD. A possible approach to auto-update configmap inside pod without restart is mounting it's content as volume. Kubernetes auto-updates the config map into POD if mounted as a volume, however, it has a limitation like it won't work if subpath used.

Can we edit ConfigMap in Kubernetes?

You can edit your ConfigMap. Kubectl has commands to edit your file. It will show in YML format by default.

Do we need to restart pod after ConfigMap change?

ConfigMaps consumed as environment variables are not updated automatically and require a pod restart.


2 Answers

Now you can. Just throw: kubectl edit configmap <name of the configmap> on your command line. Then you can edit your configuration.

like image 52
Arivaldo Avatar answered Sep 29 '22 18:09

Arivaldo


Another option is actually you can use this command:

kubectl create configmap some-config \   --from-file=some-key=some-config.yaml \   -n some-namespace \   -o yaml \   --dry-run | kubectl apply -f -  

Refer to Github issue: Support updating config map and secret with --from-file

like image 44
irvifa Avatar answered Sep 29 '22 16:09

irvifa