A few years ago, I wrote an essay about this topic titled βHow to Access Host Resources in Minikube Pods?β. In it, I have described how to access host resources in Minikube. Something I thought should be easy but, at the time, it really wasnβt.
Back then, Iβve described an approach, based on a Github issue, relying on listing kernel routing tables, that allowed us to fetch the IP of the host machine inside Minikube. I described why this worked, going so far as sharing a few snippets of code from the Kubernetes source code.
While this has served me well for the last few years, Iβve recently discovered that this approach is a bit outdated - the documentation on that essay doesnβt even exist anymore. I wrote this when Minikube was v1.6.2 and it is now v1.23.1β¦a lot has happened. After searching a bit more, Iβve understood that Minikube now has a proper solution for this, documented in Host access.
This approach applies for Minikube bigger than v1.10 and it essentially relies on using host.minikube.internal
in order to connect to the host Minikube is running on. According to the documentation, βminikube v1.10 adds a hostname entry host.minikube.internal to /etc/hosts.β Iβve tested this and it seems to actually work, while being much easier and reliable.
As with the initial approach, the same caveat applies:
The service running on your host must either be bound to all IPβs (0.0.0.0) and interfaces, or to the IP and interface your VM is bridged against. If the service is bound only to localhost (127.0.0.1), this will not work.
Top comments (0)