简体   繁体   中英

Unable to connect to minikube when using WSL

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

NAMESPACE NAME TARGET PORT URL
default server-chart-service 4000 http://192.168.49.2:30963
default client-chart-service 3000 http://192.168.49.2:31381
default kubernetes No node port
kube-system kube-dns No node port
kubernetes-dashboard dashboard-metrics-scraper No node port
kubernetes-dashboard kubernetes-dashboard No 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?

I think it's an issue in WSL2. Check these two GH Issues:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM