0 votes
1 view
in Devops and Agile by (28.1k points)

I've been using K8S ConfigMap and Secret to manage our properties. My design is pretty simple, that keeps properties files in a git repo and use build server such as Thoughtworks GO to automatically deploy them to be ConfigMaps or Secrets (on choice condition) to my k8s cluster.

Currently, I found it's not efficient that I have to always delete the existing ConfigMap and Secret and create the new one to update as below:

kubectl delete configmap foo

kubectl create configmap foo --from-file foo.properties

Is there a nice and simple way to make the above one step and more efficient than deleting current? potentially what I'm doing now may compromise the container that uses these configmaps if it tries to mount while the old configmap is deleted and the new one hasn't been created

1 Answer

0 votes
by (48k points)

For updating k8s ConfigMap you can get the YAML file which helps you to update or replace from 

kubectl create configmap foo --from-file foo.properties -o yaml --dry-run | kubectl replace -f -

Please mind the spaces in the command, these commands will enable you to get the yaml file that helps you in updating.

 There is one more way to replace and update(used for small changes),

kubectl edit configmap <cfg-name>

This will open a vi editor of configMap there you can make changes and save it. Thus you can update your k8s configMap without deleting the existing one

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...