<p>Kubernetes ships with a <code>ConfigMap</code> called <code>coredns</code> that lets you specify DNS settings. I want to modify or patch a small piece of this configuration by adding:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
data:
  upstreamNameservers: |
    ["1.1.1.1", "1.0.0.1"]
</code></pre>

<p>I know I can use <code>kubectrl edit</code> to edit the <code>coredns</code> <code>ConfigMap</code> 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 <code>ConfigMap</code>?</p>

<p>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.</p>

Muhammad Rehan Saeed
<p>This will apply the same patch to that single field:</p>

<pre><code>kubectl patch configmap/coredns \
  -n kube-system \
  --type merge \
  -p '{"data":{"upstreamNameservers":"[\"1.1.1.1\", \"1.0.0.1\"]"}}'
</code></pre>
