I launched minikube with the docker driver on a remote machine and I have used a nodePort service for a particular pod. I believe nodePort exposes the port on the minikube docker container. On doing minikube IP it gave me the IP of the docker container in which minikube runs. How can I port map the port from the minnikube container to the host port so that I can access it remotely. A different approach would other than using driver=none or restarting minikube is appreciated as I do not want to restart my spinnaker cluster.
Asked
Active
Viewed 5,311 times
1 Answers
9
There is a minikube service <SERVICE_NAME> --url
command which will give you a url where you can access the service. In order to open the exposed service, the minikube service <SERVICE_NAME>
command can be used:
$ minikube service example-minikube
Opening kubernetes service default/hello-minikube in default browser...
This command will open the specified service in your default browser.
There is also a --url
option for printing the url of the service which is what gets opened in the browser:
$ minikube service example-minikube --url
http://192.168.99.100:31167
You can run minikube service list
to get list of all available services with their corresponding URL's. Also make sure the service points to correct pod by using correct selector
.
Try also to execute command:
ssh -i ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L *:30000:0.0.0.0:30000
Take a look: minikube-service-port-forward, expose-port-minikube, minikube-service-documentation.

Malgorzata
- 6,409
- 1
- 10
- 27
-
1Hey, Thank you for replying. I tried doing this, As I said, the IP I get is of the docker container of MiniKube running on Bridge network. Hence, I cannot access it remotely. – aayush.ag21 Jun 24 '20 at 19:34
-
By using the expose port method, it is possible for me to access the service on the machine on which minikube is running in docker container. However, the host machine is a headless CentOS server, which I am using remotely. – aayush.ag21 Jun 24 '20 at 19:39
-
Have you tried to port forward a service https://github.com/kubernetes/minikube/issues/877 ? Try to execute command ssh -i ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L \*:30000:0.0.0.0:30000 – Malgorzata Jun 25 '20 at 12:21
-
Hey yes, this was the exact issue I was facing. This link was for when the driver is VM which has NAT support to port-forward at runtime. However, docker doesn't have anything as such. The other port forwarding methods worked. – aayush.ag21 Jun 26 '20 at 13:00
-
Why would I want to execute that last command/What is the purpose of the the last command (the ssh command)? – Govind Rai Dec 22 '22 at 13:08