Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 505
John Allard Avatar asked Jun 08 '20 10:06

John Allard


People also ask

How do you get external IP address in minikube?

minikube tunnel runs as a process, creating a network route on the host to the service CIDR of the cluster using the cluster's IP address as a gateway. The tunnel command exposes the external IP directly to any program running on the host operating system. Password: Status: machine: minikube pid: 39087 route: 10.96.

How does minikube work with Docker?

The kubecluster running inside the minikube vm actually uses Docker to run all the containerscontainersIn computer science, a container is a class or a data structure whose instances are collections of other objects. In other words, they store objects in an organized way that follows specific access rules. The size of the container depends on the number of objects (elements) it contains.https://en.wikipedia.org ā€ŗ wiki ā€ŗ Container_(abstract_data_type)Container (abstract data type) - Wikipedia. So when you create kubernetes objects, e.g. pods, then you can use the docker cli to view the underlying containers that have been created.


2 Answers

$ 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

like image 102
Onyia Okey Avatar answered Sep 20 '22 23:09

Onyia Okey


To open exposed service run following

$ minikube service <service-name>

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

like image 23
hoque Avatar answered Sep 19 '22 23:09

hoque