Using minikube with --driver=docker fails to forward from localhost to minikube internal address
Asked Answered
A

2

15

Edit - this is on OSX Also, I've tried running minikube service <service-name>, that's shown below and when it tries to open it in a browser I get a "connection refused" signal because the port is closed.

I have a kubernetes deployment that works fine when using --driver=virtualbox. I translated this to use --driver=docker and this almost works except when I do the following

$ minikube service websocket-nodeport
|-----------|--------------------|-------------|-------------------------|
| NAMESPACE |        NAME        | TARGET PORT |           URL           |
|-----------|--------------------|-------------|-------------------------|
| default   | websocket-nodeport |        9000 | http://172.17.0.4:30007 |
|-----------|--------------------|-------------|-------------------------|
πŸƒ  Starting tunnel for service websocket-nodeport.
|-----------|--------------------|-------------|------------------------|
| NAMESPACE |        NAME        | TARGET PORT |          URL           |
|-----------|--------------------|-------------|------------------------|
| default   | websocket-nodeport |             | http://127.0.0.1:62032 |
|-----------|--------------------|-------------|------------------------|
πŸŽ‰  Opening service default/websocket-nodeport in default browser...
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

But if I go to

$ curl http://127.0.0.1:62032
curl: (7) Failed to connect to 127.0.0.1 port 62032: Connection refused

nothing happens, it isn't a valid address. However, if I do the following

$ minikube ssh
# inside the VM now
docker@minikube:~$ curl http://172.17.0.4:30007
ok!: websocket-frontend-b7c8dc4b9-5jtg6

I get the response I want! So this means that my service is running and the URL output of the websocket-nodeport address as is internal to minikube is correct but for some reason the local address http://127.0.0.1:62032 isn't be forwarded to the minikube VM.

How do I get this forward to work?

Alabama answered 8/6, 2020 at 10:13 Comment(3)
operating system? – Eboat
Can you please run minikube service websocket-nodeport and check? – Mhd
i get the same issue on mac – Coquillage
O
4

$ minikube service <service-name> this will open up a tunnel to connect to the service, make sure the service is a NodePort service.

If it opens a browser and you get a 404 this is because the url in the address bar doesn't exist within your api. Changing the URL PATH to correct URL paths/routes you defined in your API should fix this

Olein answered 28/3, 2021 at 4:11 Comment(0)
M
3

To open exposed service run following

$ minikube service <service-name>

This command will open the specified service in your default browser.

Mhd answered 8/6, 2020 at 11:42 Comment(5)
I'm confused, that's the crux of the issue. As documented, I run minikube service websocket-nodeport and it tries to open the page but it shows 404 and that the connection is refused (i.e. http:127.0.0.1:{{port}} is closed) – Alabama
But 404 is different than connection refused. If you ctrl+c then you get nothing. I 'm also having the same issue, I'm trying to understand what's going on. I'm also on mac with docker driver. – Communicate
I am running macos 10, $minikube service fleetman-webapp I get following error:Because you are using Docker driver on darwin, the terminal needs to be open to run it. – Censer
@Mhd bro finally i found the solution to my own problem, i was exposing my webapi using service of type NodePort, service port was 31000 but i was unable to get response from 127.0.0.1:31000, but after running minikube service <service-name> i got to know about tunnel thing, and my webapi was tunneling through port=55959. Thanks <3 – Wanderoo
i guess, you can start the tunnel manually using minikube tunnel – Wanderoo

© 2022 - 2024 β€” McMap. All rights reserved.