Home > other >  ERR_CONNECTION_TIMED_OUT kubernetes minikube service
ERR_CONNECTION_TIMED_OUT kubernetes minikube service

Time:03-24

I am getting ERR_CONNECTION_TIMED_OUT when trying to access minikube service in localhost.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: identityserver
spec:
  selector:
    matchLabels:
      app: identityserver
  template:
    metadata:
      labels:
        app: identityserver
    spec:
      containers:
      - name: identityserver
        image: identityserver:0
        ports:
        - containerPort: 5001 
        imagePullPolicy: "Never"

I have created service as following.

apiVersion: v1
kind: Service
metadata:
  name: identityserver
spec:
  type: NodePort
  selector:
    app: identityserver
  ports:
  - port: 5001
    nodePort: 30002

I am trying to load in my local browser using following command. But it is not getting accessible in localhost. Internal kubernetes apps are able to communicate with service but not externally.

minikube service identityserver

I tried making type as clusterip and then it worked with port forwarding and only nodeport is having issue accessing.

kubectl port-forward service/identityserver 18080:5001 --address 0.0.0.0

CodePudding user response:

This seems to be an issue with the Docker driver. I was able to run this with VirtualBox driver.

So I just had to start using VirtualBox driver (Even though virtualization was enabled in my machine it was giving an error. so had to append the --no-vtx-check flag, you can skip that if not facing an error without that flag)

minikube start --driver=virtualbox --no-vtx-check

CodePudding user response:

There are several ways of trying minikube on Windows docker:

  • Docker Desktop app (with Enable Kubernetes option)
  • Docker Desktop app (without enabling Kubernetes option) and installing minikube to wsl2
  • No Docker Desktop at all, installing docker and minikube in wsl2

Let's test it with the link you gave in comments - Set up Ingress on Minikube with the NGINX Ingress Controller.

Docker Desktop v.20.10.12 (with Enable Kubernetes option v.1.22.5), Win10, wsl2 backend.

  1. Enable Kubernetes in Docker Desktop.
  2. Check if ingress-controller is installed:
$ kubectl get pods -n ingress-nginx

The output should be similar to:

NAME                                        READY   STATUS      RESTARTS    AGE
ingress-nginx-admission-create-g9g49        0/1     Completed   0          11m
ingress-nginx-admission-patch-rqp78         0/1     Completed   1          11m
ingress-nginx-controller-59b45fb494-26npt   1/1     Running     0          11m
  1. Create a Deployment using the following command:
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
  1. Expose the Deployment:
kubectl expose deployment web --type=NodePort --port=8080
  1. Create example-ingress.yaml from the following file:
$ kubectl apply -f example-ingress.yaml
$ cat example-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1    
spec:
  ingressClassName: nginx   # this line is essential!
  rules:
    - host: hello-world.info
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 8080
  1. Verify the IP address is set:
NAME              CLASS    HOSTS              ADDRESS        PORTS   AGE
example-ingress   <none>   hello-world.info   localhost    80      38s
  1. Add the following line to the bottom of the C:\Windows\System32\drivers\etc\hosts file on your computer (you will need administrator access):
127.0.0.1 hello-world.info
  1. DONE. Open hello-world.info in a browser.
  2. How to access the NodePort service? In C:\Windows\System32\drivers\etc\hosts find these lines:
# Added by Docker Desktop
192.168.1.179 host.docker.internal
192.168.1.179 gateway.docker.internal

Use this IP and node port: curl 192.168.1.179:portNumber

  • Related