<p>I am running minikube on my Mac laptop.  I am using VirtualBox to host the minikube virtual machine, following the <a href="https://github.com/kubernetes/minikube#quickstart" rel="nofollow noreferrer">official instructions</a>.</p>

<p>I would like a pod that I am going to deploy into the cluster to be able to ping a server I will be running on my laptop.  Assuming (for now) that I am not defining a Kubernetes Service of type ExternalName to represent that server, what IP or hostname should I use from within the program running in my pod?</p>

<p><strong>EDIT</strong>: From my pod I can <code>ping 10.0.2.2</code> and get answers back.  However, trying to <code>telnet</code> to <code>10.0.2.2</code> on port <code>9092</code>, where I happen to have an H2 database running, just hangs.</p>

<p>Finally, <code>minikube ssh</code>, which apparently logs me into the VirtualBox VM, maybe? running as <code>docker</code>? results in all the same behaviors above, in case this matters, which suggests this is fundamentally a question, I suppose, about VirtualBox.</p>

<p><strong>EDIT #2</strong>: A restart of VirtualBox solved the connection issue (!).  Nevertheless, <code>10.0.2.2</code> still seems like magic to me; I'd like to know where that IP comes from.</p>

<p>You should be able to use the ipv4 address listed under <code>vboxnet0</code>.  Look for the <code>vboxnet0</code> interface in the list of outputs for <code>ifconfig</code>.  Alternatively the address <code>10.0.2.2</code> will also map back to the host from the guest.</p>

<p>This IP address will be accessible from within the guest but not directly from within a pod.  To make it accessible from within a pod you will need to create a headless service that exposes this IP address.<br>
See this answer for how to create a headless service:
<a href="https://stackoverflow.com/questions/43354167/minikube-expose-mysql-running-on-localhost-as-service/43477742#43477742">Minikube expose MySQL running on localhost as service</a></p>

<p>So for example I ran a server at port :8000 on my host and did the following to access it in a pod:</p>

<pre><code>$ kubectl create -f service.yaml

----service.yaml----
apiVersion: v1 kind: Service metadata:
    name: my-service spec:
    ports:
        - protocol: TCP
          port: 1443
          targetPort: 8000

$ kubectl create -f endpoint.yaml

----endpoint.yaml----
apiVersion: v1
kind: Endpoints
metadata:
    name: my-service
subsets:
    - addresses:
        - ip: 192.168.99.1 #ipv4 address from vboxnet0
      ports:
        - port: 8000

$ kubectl get svc
NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
kubernetes   10.0.0.1     &lt;none&gt;        443/TCP    2h
my-service   10.0.0.83    &lt;none&gt;        1443/TCP   17m
</code></pre>

<p>Then you can access the host service by using 10.0.0.83:1443 within a pod.</p>
