-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access service running on host OS from inside minikube VM? #2735
Comments
Are there any news on this? I need something similar to be able to create a small development proxy server that we currently use with docker-compose to start some microservices locally while most of the infrastructure runs within Kubernetes. |
Docker's Kubernetes implementation has support for this. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Agreed, we should make this easy to do by default across platforms. I'm a little iffy on making it the default due to the possibility of lateral movement from a compromised container, but we should at least make it an easy option. |
https://medium.com/tarkalabs/proxying-services-into-minikube-8355db0065fd does a pretty good job of explaining one method of forwarding ports from the host OS into minikube. We should do our own, as well. |
@tstromberg we are actually working on a solution for Minishift that places a small proxy inside the VM, which is also used to overcome the issue with self-signed or custom CA signed certificates. while minishift/minishift#2788 has some of the findings and thoughts on this. |
Would a minikube addon be an idea?
This is pretty trivial ofc. but having it as addon would have the added value of being an easy to document step, instead of describing how to look up the host ip, setup the service etc. |
I tried to get this working on my mac and followed the above instructions. I was able to connect out from the minikube VM itself, but not from containers running in it. So I tried the kubernetes provided by Docker for Mac and the |
Thoughts about exposing the host machine's IP via a minikube environment var? |
@gaziqbal - That sounds like a reasonable place to start, assuming if the IP is routable (it at least is in kvm2). I'd be happy to approve any PR's which implement this. Help wanted! |
Any news on this issue? |
This is a wonderful suggestion. There is often a need to connect to a local database running on the host during development. It would make creating tutorials with minikube straightforward if we had some sort of addon like this. |
Without needing any add-ons, this is a solution that works for me:
The idea is that instead of specifying the IP, you'll need to use a DNS name, which is what
That Edit: Actually, you can use |
I found another way of accessing the service from the VM. Inside /etc/resolv.conf of the VM there is this nameserver line with the host ip. If you add this to /etc/hosts it can resolve the name:
Now you can curl a service with: curl minikube.host:9200 I also enabled GatewayPorts on /etc/ssh/sshd_config, reloaded sshd, added the ExternalName Service and my PODs still can't curl minikube-host. Help needed. |
FYI |
@mati865 I tried that.. from minikube ssh I can access the host, but not from the PODs. |
@staticdev it works for me, what driver are you using? |
@mati865 I am using kvm2.. sorry actually it works calling the IP directly. But I don't know why it doesn't work using name (/etc/hosts or ExternalName Service). |
Having a similar problem with virtualbox driver. It looks like resolving is not working as expected. My service that exposes host inside cluster is the following. apiVersion: v1
kind: Service
metadata:
name: minikube-host
spec:
type: ExternalName
externalName: 192.168.99.1 Getting the following error:
If I added it manually on pod's 192.168.99.1 minikube-host
So I wonder what am I missing here.
From minikube:
Any ideas would be appreciated. |
The problem is that you shouldn't be using apiVersion: v1
kind: Service
metadata:
name: minikube-host
namespace: default
spec:
ports:
- protocol: TCP
port: 80
---
apiVersion: v1
kind: Endpoints
metadata:
name: minikube-host
subsets:
- addresses:
- ip: ${MINIKUBE_IP}
ports:
- port: <port>
|
@teejae what's the |
@teejae Thanks, initially I tried this but I declared on service also |
Now documented: https://minikube.sigs.k8s.io/docs/tasks/accessing-host-resources/ Please feel free to improve it. |
@tstromberg in the linked documentation, it says
Is this the default setup, and if not how do we "bind the service to all IPs and interfaces"? |
@dannyharding10, the "default" setup will be dependent on the service on your host OS you are trying to connect to from inside minikube. For instance postgres will by default only bind to localhost. To make the postgres service "bound to all IP's" you have to:
Then you can use the technique ( Note: You should be careful about opening up postgres to all remote IP. A safer way would be to only allow IPs from the minikube environment. For instance inside my minikube environment my bridge ip is 192.168.64.1. I added the line hope this helps. |
Oops! This page doesn't exist |
The command mentioned in the link above doesn't explain how to retrieve the ip address when you start the minikube cluster with docker as vm driver. I get the following error message:
Please suggest. |
@codingkapoor you shouldn't call route directly but rather |
In minikube v1.10 we introduced a new host name you can use to access the host OS: https://minikube.sigs.k8s.io/docs/handbook/host-access/ has been updated appropriately. |
@tstromberg
Also, when I try
How I installed and started minikube
What am I missing here. Please suggest. |
Good to know that ping doesn't ship in the Docker driver. I'll open an issue as far as the hosts entry being nil though. |
@tstromberg Is there any work around this issue or we have to wait for this #8369 fix? |
@tstromberg A bit of context: I tried to investigate a bit what could had happen. So this is what I see here: minikube hosts file has the following address as host.minikube.internal I tried to debug a bit the situation. And then I see the following with
I see that this message is not given inside of minikube, but actually this comes from kubelet, and therefor inside of the kubernetes project. In this case this is the signature of the dockershim/docker_sandbox.go of kubernetes github project:
I guess in my case, the hosts file should have a 10.0.2.2 for the host.minikube.internal
I was able to run a But certainly we have different operating systems in the team, and having this resolved in hosts file would help a lot. Please consider this as an analysis from someone without a deep knowledge in Go or this two projects, that's the reason I am not able to give further help. But in case I can provide further logs or help with some testing to have this feature up and running let me know. |
I have been following this tutorial here: https://kubernetes.io/docs/tutorials/stateless-application/guestbook-logs-metrics-with-elk/ I adapated filebeat configuration to use the new hostname
Strangely when using
Does the hostname The only way i was able to get the above error resolved was to add a
I guess to summarise, why can the minikube VM access Current setup
EDIT: Just so we're clear. Kibana has been configured to listen on: 0.0.0.0 so it can accept remote connections. |
... I'm stuck with the same... if i look at minikube ssh -> /etc/hosts I have the entries: but I still can't connect to the postgres db. postgres.conf G |
I get 404 on the above link |
It looks like the URL moved: https://minikube.sigs.k8s.io/docs/handbook/host-access/ |
I stumbled here as well. Tried to access a Google Cloud SQL proxy (.exe) started on my Windows 10 host listening on 0.0.0.0 from a JupyterLab docker container (running on my minikube cluster of course - duh!), and I couldn't get it to work. |
Is it possible to access services running on the host from pod created by minikube with
hyperkit
/xhyve
driver? I am especially interested in minikube withhyperkit
/xhyve
driver on macOS.Something like
10.0.2.2
created by virtualbox to access any services on host.The text was updated successfully, but these errors were encountered: