Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Kubernetes ships with a
ConfigMap
called
coredns
that lets you specify DNS settings. I want to modify or patch a small piece of this configuration by adding:
apiVersion: v1
kind: ConfigMap
data:
upstreamNameservers: |
["1.1.1.1", "1.0.0.1"]
I know I can use kubectrl edit
to edit the coredns
ConfigMap
is there some way I can take the above file containing only the settings I want to insert or update and have it merged on top of or patched over the existing ConfigMap
?
The reason for this is that I want my deployment to be repeatable using CI/CD. So, even if I ran my Helm chart on a brand new Kubernetes cluster, the settings above would be applied.
–
–
–
–
–
–
–
As ConfigMaps are used to mount configuration files to Pod, it seems like this is what you are looking for. ConfigMaps inside of containers will update automatically if the underlying ConfigMap or Secret is modified.
You can specify configMap location:
configMapVolume(mountPath: '/etc/mount3', configMapName: 'my-config'),
Update:
Ok, I guess this does not solve your issue.
Other thing that comes to my mind is kubectl create configmap
with a pipe to kubectl replace
So the whole command would look like this:
kubectl create configmap NAME --from-file file.name -o yaml --dry-run | kubectl replace -f -
Note that this replaces whole file, so just replace
should work too.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.