<p>How do I give my pod or minikube the ability to see the 10.x network my laptop is VPN'd onto?</p>

<p>Setup:
* minikube
* php containers</p>

<p>php code accesses a private repository, 10.x address. Things are find locally, but I cannot access this same 10.x address while in a pod.</p>

<p>How can I give my pods/minikube access to my VPN route?</p>

<pre><code>my-pod-99dc9d9d4-6thdj# 
my-pod-99dc9d9d4-6thdj# wget https://private.network.host.com/
Connecting to private.network.host.com (10.x.x.x:443)
^C
my-pod-99dc9d9d4-6thdj# 
</code></pre>

<p>(sanitized, obviously)</p>

<p>PS: I did find ONE post that mentions what I'm after, but I can't seem to get it to work: <a href="https://stackoverflow.com/questions/55458997/how-to-connect-to-a-private-ip-from-kubernetes-pod">How to connect to a private IP from Kubernetes Pod</a></p>

<p>Still can't access the private ip (through my host's vpn).</p>

<p>There are a few ways you could achieve this.</p>

<p>If you only want to expose a few services into minikube from the VPN, then you could exploit SSH's reverse tunnelling, as described in this article; <a href="https://medium.com/tarkalabs/proxying-services-into-minikube-8355db0065fd" rel="nofollow noreferrer">Proxying services into minikube</a>. This would present the services as ports on the minikube VM, so acting like a nodePort essentially, and then SSH would tunnel these out and the host would route them through the VPN for you.</p>

<p>However if you genuinely need access to the entire network behind the VPN, then you will need to use a different approach. The following assumes you're VPN is configured as a split tunnel, that it's using NAT, and isn't using conflicting IP ranges.</p>

<p>The easiest option would be to run the VPN client inside minikube, thus providing first class access to the VPN and network, and not needing any routing to be set up. The other option is to set up the routing yourself in order to reach the VPN on the host computer. This would mean ensuring the following are covered:</p>

<ol>
<li>host route for the pod network; <code>sudo ip route add $REPLACE_WITH_POD_NETWORK} via $(minikube ip)</code> e.g. for my case this was <code>sudo ip route add 10.0.2.0/24 via 192.168.99.119</code></li>
<li>ping from host to pod network address (you'll have to look this up with kubectl, e.g. <code>kubectl get pod -n kube-system kube-apiserver-minikube -o yaml</code>)</li>
</ol>

<p>This should work because the networking/routing in the pod/service/kubelet is handled by the default route, which covers everything. Then when the traffic hits the host, the VPN and any networks it has exposed will have corresponding routes, the host will know to route it to the VPN, and NAT it to take care of the return path. When traffic returns it will hit your host because of the NAT'ing, it will lookup the route table, see the entry you added earlier, and forward the traffic to minikube, and then to the pod/service, voila!</p>

<p>Hope this helps.</p>
