Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve host ingress on minikube with ngnix WSL2 #19144

Open
andrybicio opened this issue Jun 26, 2024 · 3 comments
Open

Cannot resolve host ingress on minikube with ngnix WSL2 #19144

andrybicio opened this issue Jun 26, 2024 · 3 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@andrybicio
Copy link

andrybicio commented Jun 26, 2024

What Happened?

Some specs about my OS:

OS Name:                             Microsoft Windows 11 Pro
OS version:                          10.0.22635 N/D build 22635
wsl cat /proc/version
> Linux version 5.15.153.1-microsoft-standard-WSL2 (root@941d701f84f1) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Fri Mar 29 23:14:13 UTC 2024

Some additional info about my environment:

docker -v  
> Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1

kubectl version  
> Client Version: v1.30.2
> Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
> Server Version: v1.30.0

minikube version
> version: v1.33.1

What I want to achieve is to set up an Ingress node following this guide.

Starting from a fresh environment without any minikube, I begin with:

minikube start --driver=docker       
😄  minikube v1.33.1 on Ubuntu 20.04 (amd64)
✨  Using the docker driver based on user configuration
📌  Using Docker driver with root privileges
❗  For an improved experience it's recommended to use Docker Engine instead of Docker Desktop.
Docker Engine installation instructions: https://docs.docker.com/engine/install/#server
👍  Starting "minikube" primary control-plane node in "minikube" cluster
🚜  Pulling base image v0.0.44 ...
🔥  Creating docker container (CPUs=2, Memory=6000MB) ...-

🐳  Preparing Kubernetes v1.30.0 on Docker 26.1.1 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

and follow the instructions later on (I omit all the steps since I do not see any weird errors, but these can be added if needed).

Without any issue I can curl bot web and web2 after that I create the tunnel, i.e.:

Terminal 1 (which will remain active in background)

minikube service web --url
> http://127.0.0.1:46129
> ❗  Because you are using a Docker driver on linux, the terminal needs to be open to run it.

Terminal2 (accessible even via browser)

curl http://127.0.0.1:46129
> Hello, world!
> Version: 1.0.0
> Hostname: web-56bb54ff6d-96zmr

The same applies for web2, except that obviously the port and the output change. This is coherent with the guide.

However, when it comes to the part where I should create an Ingress to redirect the traffic after web2 is created, it does not work. I correctly start the service:

kubectl get ingress
> NAME              CLASS   HOSTS                 ADDRESS        PORTS   AGE
> example-ingress   nginx   hello-world.example   192.168.49.2   80      11s

Then, I created in one terminal the minikube tunnel and prompt the password like the note suggests:

✅  Tunnel successfully started

📌  NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

❗  The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
🔑  sudo permission will be asked for it.
🏃  Starting tunnel for service example-ingress.

However, when I try to be redirected to either web/web2, I do not see the expected output:

curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example

But obtain the Apache ubuntu default page.
Moreover, following the Ubuntu guide and typing:

curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example     
> curl: (28) Failed to connect to hello-world.example port 80: Connection timed out

it fails due to a timeout. Any hint on how to fix and how to correctly access the service?

Note that:

echo $( minikube ip )
> 192.168.49.2

EDIT:
Some more outputs

kubectl get ingress
> NAME              CLASS   HOSTS                 ADDRESS        PORTS   AGE
> example-ingress   nginx   hello-world.example   192.168.49.2   80      18m

ping hello-world.example
> PING hello-world.example.homenet.myprovider.it (127.0.0.1) 56(84) bytes of data.
> 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.021 ms
> 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.020 ms

Note that I have not modified /etc/hosts/ in ubuntu.

Moreover,

minikube ssh
> docker@minikube:~$ curl hello-world.example
> > curl: (6) Could not resolve host: hello-world.example

LOGS FOR EVERY COMMAND


~ ❯ minikube addons enable ingress --alsologtostderr                                                                        23:33:22
I0626 23:33:43.001768    5009 out.go:291] Setting OutFile to fd 1 ...
I0626 23:33:43.001916    5009 out.go:343] isatty.IsTerminal(1) = true
I0626 23:33:43.001941    5009 out.go:304] Setting ErrFile to fd 2...
I0626 23:33:43.001996    5009 out.go:343] isatty.IsTerminal(2) = true
I0626 23:33:43.002227    5009 root.go:338] Updating PATH: /home/andrea/.minikube/bin
I0626 23:33:43.002489    5009 mustload.go:65] Loading cluster: minikube
I0626 23:33:43.002786    5009 config.go:182] Loaded profile config "minikube": Driver=docker, ContainerRuntime=docker, KubernetesVersion=v1.30.0
I0626 23:33:43.002829    5009 addons.go:597] checking whether the cluster is paused
I0626 23:33:43.002928    5009 config.go:182] Loaded profile config "minikube": Driver=docker, ContainerRuntime=docker, KubernetesVersion=v1.30.0
I0626 23:33:43.003005    5009 host.go:66] Checking if "minikube" exists ...
I0626 23:33:43.003331    5009 cli_runner.go:164] Run: docker container inspect minikube --format={{.State.Status}}
I0626 23:33:43.027958    5009 ssh_runner.go:195] Run: systemctl --version
I0626 23:33:43.028036    5009 cli_runner.go:164] Run: docker container inspect -f "'{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}'" minikube
I0626 23:33:43.050416    5009 sshutil.go:53] new ssh client: &{IP:127.0.0.1 Port:56178 SSHKeyPath:/home/andrea/.minikube/machines/minikube/id_rsa Username:docker}
I0626 23:33:43.139592    5009 ssh_runner.go:195] Run: docker ps --filter status=paused --filter=name=k8s_.*_(kube-system)_ --format={{.ID}}
I0626 23:33:43.156830    5009 out.go:177] 💡  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
💡  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
I0626 23:33:43.159797    5009 config.go:182] Loaded profile config "minikube": Driver=docker, ContainerRuntime=docker, KubernetesVersion=v1.30.0
I0626 23:33:43.159842    5009 addons.go:69] Setting ingress=true in profile "minikube"
I0626 23:33:43.159874    5009 addons.go:234] Setting addon ingress=true in "minikube"
I0626 23:33:43.159933    5009 host.go:66] Checking if "minikube" exists ...
I0626 23:33:43.160260    5009 cli_runner.go:164] Run: docker container inspect minikube --format={{.State.Status}}
I0626 23:33:43.185316    5009 out.go:177]     ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
I0626 23:33:43.188120    5009 out.go:177]     ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.10.1
    ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.10.1
I0626 23:33:43.191399    5009 out.go:177]     ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
I0626 23:33:43.198674    5009 addons.go:426] installing /etc/kubernetes/addons/ingress-deploy.yaml
I0626 23:33:43.198708    5009 ssh_runner.go:362] scp memory --> /etc/kubernetes/addons/ingress-deploy.yaml (16078 bytes)
I0626 23:33:43.198789    5009 cli_runner.go:164] Run: docker container inspect -f "'{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}'" minikube
I0626 23:33:43.219380    5009 sshutil.go:53] new ssh client: &{IP:127.0.0.1 Port:56178 SSHKeyPath:/home/andrea/.minikube/machines/minikube/id_rsa Username:docker}
I0626 23:33:43.320039    5009 ssh_runner.go:195] Run: sudo KUBECONFIG=/var/lib/minikube/kubeconfig /var/lib/minikube/binaries/v1.30.0/kubectl apply -f /etc/kubernetes/addons/ingress-deploy.yaml
I0626 23:33:43.944103    5009 addons.go:470] Verifying addon ingress=true in "minikube"
I0626 23:33:43.953987    5009 out.go:177] 🔎  Verifying ingress addon...
🔎  Verifying ingress addon...
I0626 23:33:43.965197    5009 kapi.go:75] Waiting for pod with label "app.kubernetes.io/name=ingress-nginx" in ns "ingress-nginx" ...
I0626 23:33:43.978266    5009 kapi.go:86] Found 3 Pods for label selector app.kubernetes.io/name=ingress-nginx
I0626 23:33:43.978314    5009 kapi.go:96] waiting for pod "app.kubernetes.io/name=ingress-nginx", current state: Pending: [<nil>]
I0626 23:33:44.470241    5009 kapi.go:96] waiting for pod "app.kubernetes.io/name=ingress-nginx", current state: Pending: [<nil>]
...
I0626 23:34:30.471315    5009 kapi.go:107] duration metric: took 46.507212209s to wait for app.kubernetes.io/name=ingress-nginx ...
I0626 23:34:30.471368    5009 addons.go:197] Writing out "minikube" config to set ingress=true...
I0626 23:34:30.478959    5009 out.go:177] 🌟  The 'ingress' addon is enabled
🌟  The 'ingress' addon is enabled

Attach the log file

Here's the log file attached log.txt

Operating System

Ubuntu/WSL2 on top of Windows11 PRO

Driver

Docker

@sundakai
Copy link

sundakai commented Aug 8, 2024

same problem,It still hasn't been solved yet.Ingress related functions cannot be debugged,Look forward to a solution.

@sundakai
Copy link

sundakai commented Aug 8, 2024

Problem solved. Run the command minikube tunnel
result
then, you can Use localhost or kubernetes.docker.internalaccess the service,also you can use customize host,need set host file.
my service and ingress yaml

apiVersion: v1
kind: Service
metadata:
  name: freshrss-service
  labels:
    app: freshrss-service
spec:
  type: ClusterIP
  selector:
    app: freshrss
  ports:
    - name: tcp
      port: 37811
      targetPort: tcp
      protocol: TCP
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: freshrss-ingress
spec:
  ingressClassName: nginx
  rules:
  - host: minikube.sundakai.sdk
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: freshrss-service
            port:
              number: 37811

host set, kubernetes.docker.internal is auto set, 'minikube.sundakai.sdk' is I set it.
host set
then visit the website
if set rules.host: minikube.sundakai.sdk
only use 'minikube.sundakai.sdk' visit
image
not set can use
image
image

host set and visit website is in the windows system
my english is not good, With best wishes.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

4 participants