<p>I'm using minikube with <code>hyperkit</code> driver, and I need to access a port opened on the host machine FROM a pod inside the minikube cluster.</p>

<p>There are 2 ways I can accomplish this:</p>

<h2>Port forwarding</h2>

<p>Port forward of my local port to the <code>minikube ip</code>:</p>

<pre><code>ssh -i $(minikube ssh-key) docker@$(minikube ip) -R 8080:localhost:8080
</code></pre>

<p>And then from the pod I can <code>curl 172.17.0.1:8080</code></p>

<blockquote>
  <p>source: <a href="https://medium.com/tarkalabs/proxying-services-into-minikube-8355db0065fd" rel="nofollow noreferrer">https://medium.com/tarkalabs/proxying-services-into-minikube-8355db0065fd</a></p>
</blockquote>

<h2>Local machine's IP</h2>

<p>From my host machine, I get the minikube's bridge IP: <code>ifconfig bridge100</code> </p>

<pre><code>bridge100: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
    options=3&lt;RXCSUM,TXCSUM&gt;
    ether 8e:85:90:2d:d5:64
    inet 192.168.64.1 netmask 0xffffff00 broadcast 192.168.64.255
</code></pre>

<p>And then from the pod I can <code>curl 192.168.64.1:8080</code></p>

<p>However, I'm not sure both methods are the right way.
Is there a way to statically reference the host machine to be able to access open ports.
What's the solution here?</p>

Moshe
<p>There are too many layers of indirection involved here and you’ll have to inject the physical host’s IP address into the container as an environment variable or ConfigMap setting.  An ExternalName type Service could also work here.</p>

<p>The essential problem here is that each layer can find out about the layer immediately beyond it, but no further.  You have a host running a VM running a Kubernetes Pod.  The Pod can use the <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">downward API</a> to find its Node’s IP address, but in your case that will be the VM and not the host around it.</p>

<p>(As a parallel question: you have an ordinary home router that’s 192.168.1.1, and your local system is 192.168.1.2.  You’re running some server on the router.  Meanwhile, you have a VM running on your local system, which sees the host as 172.17.0.1 and believes it is 172.17.0.2.  How does the VM reach the service on the router, if it doesn’t know about the 192.168.1.0/24 network in its local network environment?)</p>
