Now here are the details:
- I’m running minikube on WSL2 Ubuntu app (5.10.16.3-microsoft-standard-WSL2):
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
- My minikube VM’s driver:
--driver=docker
.
Whenever I run the minikube service
command, my web app is automatically opened on my browser at the localhost URL with a random port number different from the port number specified on my service configuration file.
After starting minikube and successfully creating deployment and service with configuration files, when I run:
$ minikube service demo-app-service -n demo-app
I get the following output:
|-----------------|------------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------------|------------------|-------------|---------------------------|
| demo-app | demo-app-service | 80 | http://192.168.49.2:30021 |
|-----------------|------------------|-------------|---------------------------|
🏃 Starting tunnel for service demo-app-service.
|-----------------|------------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------------|------------------|-------------|------------------------|
| demo-app | demo-app-service | | http://127.0.0.1:38243 |
|-----------------|------------------|-------------|------------------------|
🎉 Opening service demo-app/demo-app-service in default browser...
❗ Because you are using a Docker driver on linux, the terminal needs to be open to run it.
First, my local browser opens up automatically and I am able to access my demo app on the localhost URL (http://127.0.0.1:38243), but the port number seems to be randomly assigned as it keeps changing every time I rerun the minikube service
command to deploy the same app.
Secondly, my main concern is that the demo app is never reachable at minikube_IP:nodePort
(http://192.168.49.2:30021) on my local browser. This is the same nodePort
I defined on my service configuration file, and the minikube_IP
is the same IP minikube returns when I run
$ minikube ip
However, when I execute
$ minikube service demo-app-service -n demo-app --url
the output only provides the localhost URL with a new random port number (http://127.0.0.1:<random_portNumber>).
According to minikube’s official documentation, it was stated that,
"The network is limited if using the Docker driver on Darwin, Windows, or WSL, and the Node IP is not reachable directly."
However, I was hoping this issue may have been resolved by now or maybe there is a workaround it. I have also tried installing VirtualBox as --driver
but it just doesn’t work.
Please any help will be greatly appreciated. Thank you.
2
Answers
I kept running into errors trying to install
google-chrome
on WSL2. Eventually, I had to resort to using the port-forwarding cmd:With this, I can access my app at my pre-defined node port number (http://localhost:30021) which works well for me.
Just install the Google Chrome for Linux on wsl:
Change directories into the temp folder: cd /tmp
Use wget to download it: sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Get the current stable version: sudo dpkg -i google-chrome-stable_current_amd64.deb
Fix the package: sudo apt install –fix-broken -y
Configure the package: sudo dpkg -i google-chrome-stable_current_amd64.deb
To launch, enter: google-chrome