title: Use kubectl patch to add DNS Rewrite Rule to CoreDNS Configmap
body: <p>I want to use the <code>kubectl patch</code> command to add a DNS rewrite rule to the coredns configmap, as described at <a href="https://coredns.io/2017/05/08/custom-dns-entries-for-kubernetes/" rel="nofollow noreferrer">Custom DNS Entries For Kubernetes</a>.  The default config map looks like this:</p>
  <pre><code>apiVersion: v1
  data:
    Corefile: |
      .:53 {
          log
          errors
          health
          kubernetes cluster.local in-addr.arpa ip6.arpa {
             pods insecure
             upstream
             fallthrough in-addr.arpa ip6.arpa
             ttl 30
          }
          prometheus :9153
          forward . /etc/resolv.conf
          cache 30
          loop
          reload
          loadbalance
      }
  kind: ConfigMap
  ....
  </code></pre>
  <p>and I want to add the line</p>
  <pre><code>rewrite name old.name new.name
  </code></pre>
  <p>but how to specify adding a line within the &quot;.:53&quot; element is confounding me.</p>
  <p>I know that I can get a similar result using <code>kubectl get ... | sed ... | kubectl replace -f -</code> but that would look kind of ugly, plus I want to expand my knowledge of <code>kubctl patch</code> using JSON.  Thanks!</p>