Kubernetes - update existing configmap from file

Viewed 2920
  1. I created a simple text file on my local machine

  2. I created a configmap out of that test file: kubectl create configmap test-configm --from-file=test-file.txt

  3. I added the volumemounts and volume to my deployment and verified the file is in my pods.

Now I want to modify the test-file.txt on my local machine and then update the configmap I created in step 2 so that all my pods can get the new version of that file, how can I accomplish this?

Thanks!

1 Answers

Per https://kubernetes.io/docs/concepts/configuration/configmap/ mounted configMaps are updated automatically. You would simply have to update the configMap using a dry-run followed by imperative command like this.

kubectl create configmap test-configm --from-file=test-file.txt --dry-run -o yaml | kubectl apply -f -
Related