Unable to connect to minikube when using WSL

1/10/2021

I am testing out a kubernetes cluster on my Windows machine using minikube. I installed minikube on Windows via chocolate and I have a script to access it from wsl2. I also have installed kubectl on wsl2.

#!/bin/sh
/mnt/c/ProgramData/chocolatey/bin/minikube.exe $@

I was able to create deployments for my client and server and I can view my pods using kubectl get pods

$kubectl get pods

NAME                      READY   STATUS    RESTARTS   AGE
client-chart-deployment   1/1     Running   0          35m
server-chart-deployment   1/1     Running   0          35m

Since I am using a LoadBalancer service for my client and server I used minikube tunnel to connect to them.

$minikube tunnel

�🏃  Starting tunnel for service server-chart-service
�🏃  Starting tunnel for service client-chart-service

I was also able to create services for both deployments and I can view those with kubectl get serviecs

$kubectl get services

NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
client-chart-service   LoadBalancer   10.99.57.135    127.0.0.1     3000:30741/TCP   37m
server-chart-service   LoadBalancer   10.109.66.209   127.0.0.1     4000:31539/TCP   36m
kubernetes             ClusterIP      10.96.0.1       <none>        443/TCP          4d21h

I can also view everything from minikube dashboard and minikube service list gives me the following

NAMESPACENAMETARGET PORTURL
defaultserver-chart-service4000http://192.168.49.2:30963
defaultclient-chart-service3000http://192.168.49.2:31381
defaultkubernetesNo node port
kube-systemkube-dnsNo node port
kubernetes-dashboarddashboard-metrics-scraperNo node port
kubernetes-dashboardkubernetes-dashboardNo node port

However, after everything is set up and running, I am still unable to connect to my client or server services at http://127.0.0.1:3000 and http://127.0.0.1:4000 through my browser and through curl.

I also tried the http://192.168.49.2:30963 and http://192.168.49.2:31381 and those do not work as well.

Does anyone have an idea about what is going on here?

-- Riley Conrardy
kubectl
kubernetes
minikube
windows
wsl-2

1 Answer

1/11/2021
-- Rafał Leszko
Source: StackOverflow