<p>In dnsutils pod exec <code>ping stackoverflow.com</code></p>
<pre><code>/ # ping stackoverflow.com
ping: bad address 'stackoverflow.com'
</code></pre>
<p>The <code>/etc/resolve.conf</code> file looks fine from inside the pod</p>
<pre><code>/ # cat /etc/resolv.conf 
nameserver 10.96.0.10
search weika.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
</code></pre>
<p><code>10.96.0.10</code> is the kube-dns service ip:</p>
<pre><code>[root@test3 k8s]# kubectl -n kube-system get service
NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                     AGE
kube-dns                    ClusterIP   10.96.0.10      &lt;none&gt;        53/UDP,53/TCP,9153/TCP      75d
</code></pre>
<p><code>core dns</code></p>
<pre><code>[root@test3 k8s]# kubectl -n kube-system get  pod -o wide | grep core
coredns-6557d7f7d6-5nkv7                             1/1     Running   0          10d   10.244.0.14    test3.weikayuninternal.com   &lt;none&gt;           &lt;none&gt;
coredns-6557d7f7d6-gtrgc                             1/1     Running   0          10d   10.244.0.13    test3.weikayuninternal.com   &lt;none&gt;           &lt;none&gt;
</code></pre>
<p>when I change the nameserver ip to coredns ip.  resolve dns is ok.</p>
<pre><code>/ # cat /etc/resolv.conf 
nameserver 10.244.0.14
#nameserver 10.96.0.10
search weika.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
/ # ping stackoverflow.com
PING stackoverflow.com (151.101.65.69): 56 data bytes
64 bytes from 151.101.65.69: seq=0 ttl=49 time=100.497 ms
64 bytes from 151.101.65.69: seq=1 ttl=49 time=101.014 ms
64 bytes from 151.101.65.69: seq=2 ttl=49 time=100.462 ms
64 bytes from 151.101.65.69: seq=3 ttl=49 time=101.465 ms
64 bytes from 151.101.65.69: seq=4 ttl=49 time=100.318 ms
^C
--- stackoverflow.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 100.318/100.751/101.465 ms
/ # 
</code></pre>
<p>Why is it happening?</p>

Minato
<p><em>This might only apply to you if there was trouble during either your initial installation of <code>microk8s</code> or enablement of the <code>dns</code> addon</em>, but it might still be worth a shot.  I've invested so much gd time in this I couldn't live with myself if I didn't at least share to help that one person out there.</p>
<p>In my case, the server I provisioned to set up a single-node cluster was too small - only 1GB of memory.  When I was setting up microk8s for the first time and enabling all the addons I wanted (dns, ingress, hostpath-storage), I started running into problems that were remedied by just giving the server more memory.  Unfortunately though, screwing that up initially seems to have left the addons in some kind of undefined, partially initialized/configured state, such that everything appeared to be running normally as best I could tell (i.e. CoreDNS was deployed and ready, and the <code>kube-dns</code> service showed CoreDNS's ClusterIP as it's backend endpoint) but none of my pods could resolve any DNS names, internal or external to the cluster, and I would get <a href="https://stackoverflow.com/questions/59550564/kubelet-does-not-have-clusterdns-ip-configured-in-microk8s">these annoying event logs</a> when I ran <code>kubectl describe &lt;pod&gt;</code> suggesting there was a DNS issue of some kind.</p>
<p>What ended up fixing it is resetting the cluster (<code>microk8s reset --destroy-storage</code>) and then re-enabling all my addons (<code>microk8s enable dns ingress hostpath-storage</code>) now that I had enough memory to do so cleanly do so.  After that, CoreDNS and the <code>kube-dns</code> service appeared ready just like before, but DNS queries actually worked like they should from within the pods running in the cluster.</p>
<p><strong>tl;dr; - Your <code>dns</code> addon might have have been f'd up during cluster installation.  Try resetting your cluster, re-enabling the addons, and re-deploying your resources.</strong></p>
