DNS error with MySQL integration with kubernetes cluster
This problem seems to be close related to Minikube
issue described on github.
You can see, that in your Pod
in the /etc/hosts
file - there isn't any host.minikube.internal
entry:
$ kubectl exec -it dnsutils -- cat /etc/hosts | grep "host.minikube.internal"$
On the Minikube
host you are able to reach host.minikube.internal
because Minikube
(version v1.10+) adds this hostname
entry to /etc/hosts
file. You can find more information in Host access | minikube.
This is example from my Minikube
(I'm using docker driver):
user@minikube:~$ kubectl exec -it dnsutils -- cat /etc/hosts | grep "host.minikube.internal"user@minikube:~$user@minikube:~$ minikube sshdocker@minikube:~$ cat /etc/hosts | grep host.minikube.internal 192.168.49.1 host.minikube.internaldocker@minikube:~$ ping host.minikube.internalPING 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 ms64 bytes from host.minikube.internal (192.168.49.1): icmp_seq=2 ttl=64 time=0.067 ms
host.minikube.internal
is only the entry in the /etc/hosts
file, therefore nslookup
can't correctly resolve it (nslookup
queries name servers ONLY.).
docker@minikube:~$ nslookup host.minikube.internalServer: 192.168.49.1Address: 192.168.49.1#53** server can't find host.minikube.internal: NXDOMAIN
The only workaround I think may help in some cases is adding hostAliases
to Deployment
/Pod
manifest files:
...spec: hostAliases: - ip: "192.168.49.1" # minikube IP hostnames: - "host.minikube.internal" # one or more hostnames that should resolve to the above address containers: - name: dnsutils image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3...