<p>Currently dealing with an CoreDNS-related issue which occurs on a fresh Kubernetes setup on a Raspberry PI.</p>
<p><strong>Issue: CoreDNS forwards ALL DNS queries to the local gateway/router, which has no clue how to resolve any in-cluster service names, regardless of specificity.</strong></p>
<p><em>How I diagnosed the issue:</em></p>
<p>Performing any <code>nslookup</code> queries results in a <code>NXDOMAIN</code> response, which means non-existent domain. This response always comes from the local router.</p>
<p><strong>NOTE</strong>: in the following outputs <code>10.32.0.2</code> is the IP of one of the CoreDNS pods, <code>soc.local</code> is the domain name of the cluster, <code>wpad.fritz.box</code> is the hostname of the local router.</p>
<pre><code>$ kubectl run -ti --rm alpine --image=alpine --restart=Never -- ash

/ # nslookup kubernetes 10.32.0.2
Server:     10.32.0.2
Address:    10.32.0.2:53

** server can't find kubernetes: NXDOMAIN

** server can't find kubernetes: NXDOMAIN

/ # nslookup kubernetes.default 10.32.0.2
Server:     10.32.0.2
Address:    10.32.0.2:53

** server can't find kubernetes.default: NXDOMAIN

** server can't find kubernetes.default: NXDOMAIN

/ # nslookup kubernetes.default.soc 10.32.0.2
Server:     10.32.0.2
Address:    10.32.0.2:53

** server can't find kubernetes.default.soc: NXDOMAIN

** server can't find kubernetes.default.soc: NXDOMAIN

/ # nslookup kubernetes.default.soc.local 10.32.0.2
Server:     10.32.0.2
Address:    10.32.0.2:53

** server can't find kubernetes.default.soc.local: NXDOMAIN

** server can't find kubernetes.default.soc.local: NXDOMAIN
</code></pre>
<p>The following is the output of tcpdump and the network traffic associated with the <code>nslookup</code> query for <code>kubernetes</code>:</p>
<pre><code>/ # tcpdump -i weave host 10.32.0.2 and port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on weave, link-type EN10MB (Ethernet), capture size 262144 bytes

16:57:48.047794 IP 10.32.0.5.54782 &gt; 10.32.0.2.53: 42507+ A? kubernetes. (28)
16:57:48.048136 IP 10.32.0.5.54782 &gt; 10.32.0.2.53: 43025+ AAAA? kubernetes. (28)
16:57:48.048576 IP 10.32.0.2.35867 &gt; wpad.fritz.box.53: 42507+ A? kubernetes. (28)
16:57:48.048576 IP 10.32.0.2.37755 &gt; wpad.fritz.box.53: 43025+ AAAA? kubernetes. (28)
16:57:48.050611 IP wpad.fritz.box.53 &gt; 10.32.0.2.35867: 42507 NXDomain 0/1/0 (103)
16:57:48.050916 IP wpad.fritz.box.53 &gt; 10.32.0.2.37755: 43025 NXDomain 0/1/0 (103)
16:57:48.051109 IP 10.32.0.2.53 &gt; 10.32.0.5.54782: 42507 NXDomain 0/1/0 (103)
16:57:48.051503 IP 10.32.0.2.53 &gt; 10.32.0.5.54782: 43025 NXDomain 0/1/0 (103)
</code></pre>
<p>The following are the CoreDNS logs corresponding to the <code>nslookup</code> queries:</p>
<pre><code>[INFO] 10.32.0.5:53591 - 23327 &quot;AAAA IN kubernetes. udp 28 false 512&quot; NXDOMAIN qr,aa,rd,ra 103 0.000318349s
[INFO] 10.32.0.5:53591 - 22735 &quot;A IN kubernetes. udp 28 false 512&quot; NXDOMAIN qr,aa,rd,ra 103 0.000447718s
[INFO] 10.32.0.5:58545 - 49038 &quot;AAAA IN kubernetes.default. udp 36 false 512&quot; NXDOMAIN qr,rd,ra 111 0.0314311s
[INFO] 10.32.0.5:58545 - 48445 &quot;A IN kubernetes.default. udp 36 false 512&quot; NXDOMAIN qr,rd,ra 111 0.033794968s
[INFO] 10.32.0.5:53665 - 62210 &quot;A IN kubernetes.default.soc. udp 40 false 512&quot; NXDOMAIN qr,rd,ra 115 0.047918913s
[INFO] 10.32.0.5:53665 - 62802 &quot;AAAA IN kubernetes.default.soc. udp 40 false 512&quot; NXDOMAIN qr,rd,ra 115 0.067865341s
[INFO] 10.32.0.5:56021 - 47416 &quot;A IN kubernetes.default.soc.local. udp 46 false 512&quot; NXDOMAIN qr,aa,rd 127 0.000430478s
[INFO] 10.32.0.5:56021 - 48046 &quot;AAAA IN kubernetes.default.soc.local. udp 46 false 512&quot; NXDOMAIN qr,aa,rd 127 0.000551032s
</code></pre>
<p>The following is the configmap of the CoreDNS Corefile:</p>
<pre><code>$ k get cm coredns -n kube-system -o yaml
apiVersion: v1
data:
  Corefile: |
    .:53 {
        log
        errors
        health {
           lameduck 5s
        }
        ready
        kubernetes soc.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
           ttl 30
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
kind: ConfigMap
metadata:
  creationTimestamp: &quot;2020-07-07T20:58:06Z&quot;
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data: {}
    manager: kubeadm
    operation: Update
    time: &quot;2020-07-07T20:58:06Z&quot;
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        f:Corefile: {}
    manager: kubectl
    operation: Update
    time: &quot;2020-07-28T17:21:46Z&quot;
  name: coredns
  namespace: kube-system
  resourceVersion: &quot;2464367&quot;
  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
  uid: c6a603c3-30b6-4156-b62e-a98d53761541
</code></pre>
<p>My question is: Why is CoreDNS not handling these DNS queries for in-cluster service names?</p>
<p>Not sure what else to debug. It's also a shame that the CoreDNS images don't have a shell so I can take a look at the <code>/etc/resolv.conf</code> file.
Any suggestions?</p>

Gabriel Ruiu
<p>Shortly after posting the question I re-read the Kubernetes documentation regarding <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/#known-issues" rel="nofollow noreferrer">debugging DNS name resolution</a> and in the very last paragraph of the Known Issues section there is a mention of some Alpine versions which have DNS problems. While the github ticket linked doesn't explicitly describe my problem in the same way, it does seem that the Alpine version is the issue:</p>
<pre><code>$ kubectl run -ti --rm alpine --image=alpine:3.9.6 --restart=Never -- ash
If you don't see a command prompt, try pressing enter.
/ # nslookup kubernetes 10.32.0.2
Server:    10.32.0.2
Address 1: 10.32.0.2 10-32-0-2.kube-dns.kube-system.svc.soc.local

Name:      kubernetes
Address 1: 10.96.0.1 kubernetes.default.svc.soc.local
/ # pod &quot;alpine&quot; deleted

$ kubectl run -ti --rm alpine --image=alpine --restart=Never -- ash
If you don't see a command prompt, try pressing enter.
/ # nslookup kubernetes 10.32.0.2
Server:     10.32.0.2
Address:    10.32.0.2:53

** server can't find kubernetes: NXDOMAIN

** server can't find kubernetes: NXDOMAIN
</code></pre>
