This is how to update a config map with 1 line:
kubectl create configmap foo --from-file foo.properties -o yaml --dry-run | kubectl replace -f -
And this is how to mount a config map created from a file as file(not super intuitive but a config map can only be mounted as a volume, and the mount point has to be a directory):
containers: - volumeMounts: - name: demo-config mountPath: /app/settings.json subPath: settings.json volumes: - name: demo-config configMap: name: demo
I think this is because when creating a config map from a file, the file name becomes the key and the content becomes the value. A config map can have multiple key-value pairs just like a directory can have more than 1 file. So by using the
subPath the key will be mounted as a file.