<p>I have a Kubernetes pod that is already running on a Minikube (v0.23.0) node. </p>

<p>Some context: it's the coredns pod that is created from enabling the plugin. I'm working through this blog post, in an attempt to set up custom DNS entries for my Kubernetes cluster: <a href="https://coredns.io/2017/05/08/custom-dns-entries-for-kubernetes/" rel="nofollow noreferrer">https://coredns.io/2017/05/08/custom-dns-entries-for-kubernetes/</a></p>

<p>I'm able to replace the config map without a problem; I altered the template spec from the blog post to suit my needs and ran: </p>

<pre><code>kubectl create -f configmap.yml -o yaml --dry-run | kubectl replace -f -
</code></pre>

<p>That seemed to work; I inspected the configmap using kubectl and everything looked fine.</p>

<p>However I'm not sure how to update the volumes. I tried putting something like this in a file:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    k8s-app: coredns
  namespace: kube-system
spec:
  containers:
  - name: coredns
  volumes:
  - configMap:
      items:
      - key: Corefile
        path: Corefile
      - key: cluster.db
        path: cluster.db
      name: coredns
    name: config-volume
</code></pre>

<p>Then I tried applying it with:</p>

<pre><code>kubectl create -f k8s_config/coredns/volumes.yml -o yaml --dry-run | kubectl apply -f -
</code></pre>

<p>But that gave this error message:</p>

<pre><code>error: error when retrieving current configuration of:
&amp;{0xc4218be840 0xc420213500 kube-system  STDIN 0xc421a9e5e0 0xc421a9e5e0  false}
from server for: "STDIN": resource name may not be empty
</code></pre>

<p>I also tried dumping the contents of the coredns pod into a file, altering the volume section accordingly, then replacing the pod, but got this message:</p>

<pre><code>The Pod "coredns-6b4fd7784-xhb5s" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)
</code></pre>

<p>Short of deleting the pod and bringing it back up, how should I go about updating the volumes in a Pod? Is it even possible?  </p>

<p>I suppose another overarching question would be: what's the correct way to update/configure the <code>coredns</code> pod/plugin? I can't seem to find a guide anywhere. In the blog post it says the following: </p>

<blockquote>
  <p>To create the new zone, we need to modify the <code>coredns.yaml</code> we have
  been using to create an additional file in the pod.</p>
</blockquote>

<p>However this must have come from when coredns was manually set up in Kubernetes, and now that it "just works" as a plugin I'm not sure how to go about configuring it. </p>

<p>Looking at the Pod name <code>coredns-6b4fd7784-xhb5s</code>, it looks like your CoreDNS Pod is actually being managed by a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Deployment controller</a>.</p>

<p>Do not modify Pods managed by a deployment controller directly. To edit Pods managed by a deployment, edit the deployment object itself (<code>kubectl -n kube-system edit deployment coredns</code>) and modify the <code>spec.template</code> property. After editing the deployment, the controller will delete the old pod and create a new one with the updated specification.</p>

<p>If you simply updated a ConfigMap object and want the CoreDNS Pod to receive the new contents, its also sufficient to simply delete the old Pod; the deployment controller will create a new one with the most recent version of the ConfigMap.</p>

<p>If you're worried about a potential service interruption by deleting your CoreDNS Pod, consider increasing the deployment's <code>spec.replica</code> value to a value higher than 1.</p>
