<p>im Running Kubernetes (minikube) on Windows via Virtualbox. I've got a Services running on my Host-Service i dont want to put inside my Kubernetes  Cluster, how can i access that Services from Inside my Pods?</p>

<p>Im  new to to Kubernetes i hope this Questions isnt to stupid to ask.</p>

<p>I tried to create a Service + Endpoint but it didnt work:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>kind: Endpoints
apiVersion: v1
metadata:
  name: vetdb
subsets:
- addresses:
  - ip: 192.168.99.100
  ports:
  - port: 3307</code></pre>
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>kind: Service
apiVersion: v1
metadata:
  name: vetdb
spec:
  selector:
    app: vetdb
  type: ClusterIP
  ports:
  - port: 3306
    targetPort: 3307</code></pre>
</div>
</div>
</p>

<p>i started a ubuntu image inside the same cluster the pod should be running on later and tested the connection:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>$ root@my-shell-7766cd89c6-rtxt2:/# curl vetdb:3307 --output test
Host '192.168.99.102' is not allowed to connect to this MariaDB serverroot@my-shell</code></pre>
</div>
</div>
</p>

<p>This is the same Output i get running (except other Host-IP)</p>

<pre><code>curl 192.168.99.100:3307
</code></pre>

<p>on my Host PC ==> Itworks.</p>

<p>But i cant access the Host from inside my Microservices where i really need to access the URL.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>$ kubectl get pods
NAME                        READY     STATUS             RESTARTS   AGE
eureka-77f949499-g2l82      1/1       Running            0          2h
my-shell-7766cd89c6-rtxt2   1/1       Running            0          2h
vet-ms-54b89f9c86-29psf     1/1       Running            10         18m
vet-ms-67c774fd9b-2fnjc     0/1       CrashLoopBackOff   7          18m</code></pre>
</div>
</div>
</p>

<p>The Curl Response i posted above was from Pod: <code>my-shell-7766cd89c6-rtxt2</code>
But i need to access vetdb from <code>vet-ms-*</code></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>$ kubectl logs -f vet-ms-67c774fd9b-2fnjc
...
Caused by: java.net.UnknownHostException: vetdb
...</code></pre>
</div>
</div>
</p>

<p>Spring URL Settings i tried</p>

<pre><code>spring.profiles.datasource.url: jdbc:mysql://vetdb:3307/vetdb?useSSL=false&amp;allowPublicKeyRetrieval=true
</code></pre>

<blockquote>
<pre><code>spring.profiles.datasource.url: jdbc:mysql://vetdb:3306/vetdb?useSSL=false&amp;allowPublicKeyRetrieval=true
</code></pre>
</blockquote>

<pre><code>spring.profiles.datasource.url: jdbc:mysql://vetdb/vetdb?useSSL=false&amp;allowPublicKeyRetrieval=true
</code></pre>

<p>Ty guys</p>

<hr>

<hr>

<p>Edit://
i allowed every Host to Connect to the DB to remove this error</p>

<pre><code>Host '192.168.99.102' is not allowed to connect to this MariaDB
</code></pre>

<p>but i still get the Same Unknown Host Exception inside of my Microservices.</p>

pro sp
<p>I think the Ubuntu image test is most informative here.</p>

<p>From the error message I think the problem is in the MySQL config. You must configure server to listen on port of your host IP address (i.e. not localhost or socketfile).</p>

<p>In addition, you must also ensure that IP address from pod subnets are allowed to connect also.</p>
