Search code examples
kuberneteswindows-subsystem-for-linuxkubernetes-ingressminikubedocker-desktop

Creating Services. curl timed out when doing curl http://$(minikube ip):32000


(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: {}

Solution

  • 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!