skip to Main Content

Now here are the details:

  1. 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
  1. 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


  1. Chosen as BEST ANSWER

    I kept running into errors trying to install google-chrome on WSL2. Eventually, I had to resort to using the port-forwarding cmd:

    kubectl port-forward service/demo-app-service 30021:80 -n demo-app
    

    With this, I can access my app at my pre-defined node port number (http://localhost:30021) which works well for me.


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search