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
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.
You can edit your ConfigMap. Kubectl has commands to edit your file. It will show in YML format by default.
ConfigMaps consumed as environment variables are not updated automatically and require a pod restart.
Now you can. Just throw: kubectl edit configmap <name of the configmap>
on your command line. Then you can edit your configuration.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With