<p><strong>What happened:<br></strong>
I am trying to create a service endpoint using the <code>externalName</code> spec to allow my microservices running inside the pods to access a local MySQL server on my local host.</p>
<p>This is the relevant section for the yaml file:<br></p>
<pre><code>apiVersion: v1 
kind: Service 
metadata: 
  name: mysql 
  namespace: default 
spec: 
  type: ExternalName 
  externalName: host.minikube.internal
</code></pre>
<p><strong>What you expected to happen:</strong><br>
I expect to be able to connect but my SpringBoot containers are showing that the mysql connection is not working. I have tested the microservices and it is working in Docker with the same MySQL database.</p>
<p><strong>How to reproduce it (as minimally and precisely as possible):<br></strong>
Normal installation of minikube and kubernetes, running the <code>dnsutils</code> image from <a href="https://k8s.io/examples/admin/dns/dnsutils.yaml" rel="noreferrer">https://k8s.io/examples/admin/dns/dnsutils.yaml</a> with the mysql service given above.</p>
<p><strong>Anything else we need to know?:<br></strong>
I have tested out the troubleshooting detailed here (<a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/" rel="noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/</a>) but it did not resolve the problem. When running:<br></p>
<pre><code>kubectl exec -i -t dnsutils -- nslookup mysql.default
</code></pre>
<p>I get the following message:<br></p>
<pre><code>Server: 10.96.0.10
Address: 10.96.0.10#53

mysql.default.svc.cluster.local canonical name = host.minikube.internal.
** server can't find host.minikube.internal: SERVFAIL

command terminated with exit code 1
</code></pre>
<p>I have verified that <code>CoreDNS</code> is installed and running:<br></p>
<pre><code>NAME READY STATUS RESTARTS AGE
coredns-f9fd979d6-z58cr 1/1 Running 0 31m
</code></pre>
<p>Endpoints are exposed:<br></p>
<pre><code>NAME ENDPOINTS AGE
kube-dns 172.17.0.2:53,172.17.0.2:53,172.17.0.2:9153 32m
</code></pre>
<p>My <code>/etc/resolv.conf</code> only has one entry:<br></p>
<pre><code>nameserver 192.168.53.145
</code></pre>
<p><strong>Environment:</strong></p>
<p>Kubernetes version (use kubectl version):</p>
<pre><code>Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20&quot;, GitVersion:&quot;v1.20.0&quot;, GitCommit:&quot;af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-12-08T17:59:43Z&quot;, GoVersion:&quot;go1.15.5&quot;, Compiler:&quot;gc&quot;, Platform:&quot;windows/amd64&quot;}

Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;19&quot;, GitVersion:&quot;v1.19.4&quot;, GitCommit:&quot;d360454c9bcd1634cf4cc52d1867af5491dc9c5f&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-11-11T13:09:17Z&quot;, GoVersion:&quot;go1.15.2&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
</code></pre>
<p>Cloud provider or hardware configuration:<br>
Local Windows 10 Pro x64 running Kubernetes with Minikube
OS (e.g: cat /etc/os-release):<br>
<code>NAME=Buildroot VERSION=2020.02.7 ID=buildroot VERSION_ID=2020.02.7 PRETTY_NAME=&quot;Buildroot 2020.02.7</code>&quot;</p>
<p>Kernel (e.g. uname -a): Linux minikube <code>4.19.150 #1 SMP Fri Nov 6 15:58:07 PST 2020 x86_64 GNU/Linux</code></p>
<p>Install tools: Installed using the relevant kubectl and minikube .exe files
Network plugin and version (if this is a network-related bug):</p>
<p>Others:</p>

Juin
<p>This problem seems to be close related to <code>Minikube</code> <a href="https://github.com/kubernetes/minikube/issues/8439" rel="nofollow noreferrer">issue</a> described on github.</p>
<p>You can see, that in your <code>Pod</code> in the <code>/etc/hosts</code> file - there isn't any <code>host.minikube.internal</code> entry:<br></p>
<pre><code>$ kubectl exec -it dnsutils -- cat /etc/hosts | grep &quot;host.minikube.internal&quot;
$
</code></pre>
<p>On the <code>Minikube</code> host you are able to reach <code>host.minikube.internal</code> because <code>Minikube</code> (version <strong>v1.10+</strong>) adds this <code>hostname</code> entry to <code>/etc/hosts</code> file. You can find more information in <a href="https://minikube.sigs.k8s.io/docs/handbook/host-access/" rel="nofollow noreferrer">Host access | minikube</a>.</p>
<p>This is example from my <code>Minikube</code> (I'm using docker driver):<br></p>
<pre><code>user@minikube:~$ kubectl exec -it dnsutils -- cat /etc/hosts | grep &quot;host.minikube.internal&quot;
user@minikube:~$
user@minikube:~$ minikube ssh
docker@minikube:~$ cat /etc/hosts | grep host.minikube.internal 
192.168.49.1    host.minikube.internal
docker@minikube:~$ ping host.minikube.internal
PING host.minikube.internal (192.168.49.1) 56(84) bytes of data.
64 bytes from host.minikube.internal (192.168.49.1): icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from host.minikube.internal (192.168.49.1): icmp_seq=2 ttl=64 time=0.067 ms
</code></pre>
<p><code>host.minikube.internal</code> is only the entry in the <code>/etc/hosts</code> file, therefore <code>nslookup</code> can't correctly resolve it (<code>nslookup</code> queries name servers <strong>ONLY</strong>.).</p>
<pre><code>docker@minikube:~$ nslookup host.minikube.internal
Server:         192.168.49.1
Address:        192.168.49.1#53

** server can't find host.minikube.internal: NXDOMAIN
</code></pre>
<p>The only workaround I think may help in some cases is adding <code>hostAliases</code> to <code>Deployment</code>/<code>Pod</code> manifest files:</p>
<pre><code>...
spec:
  hostAliases:
  - ip: &quot;192.168.49.1&quot; # minikube IP
    hostnames:
    - &quot;host.minikube.internal&quot; # one or more hostnames that should resolve to the above address
  containers:
  - name: dnsutils
    image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3
...
</code></pre>
