<p>I'm trying to access a MySQL database hosted inside a docker container on localhost from inside a minikube pod with little success. I tried the solution described <a href="https://stackoverflow.com/questions/43354167/minikube-expose-mysql-running-on-localhost-as-service">Minikube expose MySQL running on localhost as service</a> but to no effect. I have modelled my solution on the service we use on AWS but it does not appear to work with minikube. My service reads as follows</p>

<pre><code>apiVersion: v1

kind: Service

metadata: 

  name: mysql-db-svc

  namespace: external

spec: 
  type: ExternalName
  ExternalName: 172.17.0.2
</code></pre>

<p>...where I try to connect to my database from inside a pod using "mysql-db-svc" on port 3306 but to no avail. If I try and CURL the address "mysql-db-svc" from inside a pod it cannot resolve the host name.</p>

<p>Can anybody please advise a frustrated novice?</p>

<p>I'm using ubuntu with Minikube and my database runs outside of minikube inside a docker container and can be accessed from localhost @ 172.17.0.2. My Kubernetes service for my external mysql container reads as follows:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: mysql-db-svc
  namespace: external
spec: 
  type: ExternalName
  externalName: 10.0.2.2
</code></pre>

<p>Then inside my .env for a project my DB_HOST is defined as</p>

<pre><code>mysql-db-svc.external.svc
</code></pre>

<p>... the name of the service "mysql-db-svc" followed by its namespace "external" with "svc"</p>

<p>Hope that makes sense.</p>
