0

(WSL2, minikube, Windows 11, Calico plugin, Docker-Desktop)

I simply don't understand why curl timed out when doing curl http://$(minikube ip):32000. I saw SO questions but they are not applicable.

$ k create deploy nginxsvc --image=nginx --replicas=3
$ k expose deploy nginxsvc --port=80

Then I edited the service to change Service Type to NodePort.

$ k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d
nginxsvc NodePort 10.103.11.225 <none> 80:32000/TCP 19m
regular-encourager NodePort 10.102.236.129 <none> 8080:32058/TCP 15d

$ curl http://$(minikube ip):32000
curl: (28) Failed to connect to 192.168.49.2 port 32000: Connection timed out

$ k describe svc nginxsvc

Name: nginxsvc

Namespace: default

Labels: app=nginxsvc

Annotations: <none>

Selector: app=nginxsvc

Type: NodePort

IP Family Policy: SingleStack

IP Families: IPv4

IP: 10.103.11.225

IPs: 10.103.11.225

Port: <unset> 80/TCP

TargetPort: 80/TCP

NodePort: <unset> 32000/TCP

Endpoints: 10.244.1.233:80,10.244.1.234:80,10.244.1.235:80

Session Affinity: None

External Traffic Policy: Cluster

Events: <none>

$ k get svc nginxsvc -o yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2023-03-28T23:18:04Z"
  labels:
    app: nginxsvc
  name: nginxsvc
  namespace: default
  resourceVersion: "531373"
  uid: fcd7960e-8610-4099-a014-9b4ce94cdec2
spec:
  clusterIP: 10.103.11.225
  clusterIPs:
  - 10.103.11.225
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - nodePort: 32000
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginxsvc
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
likejudo
  • 3,396
  • 6
  • 52
  • 107
  • 1
    *The network is limited if using the Docker driver on Darwin, Windows, or WSL, and the Node IP is not reachable directly.* Take a look here: https://minikube.sigs.k8s.io/docs/handbook/accessing/#using-minikube-service-with-tunnel – glv Mar 29 '23 at 15:33
  • @glv from your link, it says, "If you are using Docker driver on Windows, there is a chance that you have an old version of SSH client". That issue refers to ssh v7.7. I have v8.6 ssh. – likejudo Mar 29 '23 at 16:00
  • @glv your link is for "Using minikube service with tunnel". I am not using a tunnel here, AFAIK. – likejudo Mar 29 '23 at 16:27
  • Can you check this link below that might have the same scenario that you have. https://forums.docker.com/t/curl-or-telnet-timed-out-when-access-a-docker-network-interface/134174 – Yvan G. Mar 30 '23 at 21:28

2 Answers2

1

As @glv pointed out,

The network is limited if using the Docker driver on Darwin, Windows, or WSL, and the Node IP is not reachable directly.

The solution was to

  1. remove minikube from WSL

    minikube delete --purge

  2. Then installed VirtualBox on Windows

  3. Install Ubuntu

  4. Install docker then minikube, kubectl on Ubuntu

  5. Start minikube

    minikube start --memory=6g --cpus=4 --driver=docker --cni=calico

Now all the networking that earlier failed, is now working!

likejudo
  • 3,396
  • 6
  • 52
  • 107
0

Run service tunnel

minikube service nginxsvc --url

minikube service nginxsvc --url runs as a process, creating a tunnel to the cluster. The command exposes the service directly to any program running on the host operating system.

Because you are using a Docker driver on linux, the terminal needs to be open to run the exposed service url (e.g., http://127.0.0.1:32897) in a browser

or

Open a new terminal and run

curl 127.0.0.1:32897

You should get the output of the service