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.
This will apply the same patch to that single field:
kubectl patch configmap/coredns \
-n kube-system \
--type merge \
-p '{"data":{"upstreamNameservers":"[\"1.1.1.1\", \"1.0.0.1\"]"}}'