简体   繁体   中英

Helm chart nginx-ingress not working in minikube?

I've setup a "hello world" ingress on Minikube as explained in the tutorial . The only difference - I removed the specific hostname to use '*' instead. However, it only seems to work with the ingress controller provided by minikube ( minikube addons enable ingress ). When I try to disable it and use helm install nginx-ingress stable/nginx-ingress instead, I can no longer access the Hello World sample website. I'm getting a "connection refused" error instead:

$ kubectl get ingress
NAME              HOSTS   ADDRESS        PORTS   AGE
example-ingress   *       192.168.64.6   80      6m23s

$ minikube ip
192.168.64.6

$ curl -iv "192.168.64.6"
* Rebuilt URL to: 192.168.64.6/
* Hostname was NOT found in DNS cache
*   Trying 192.168.64.6...
* connect to 192.168.64.6 port 80 failed: Connection refused
* Failed to connect to 192.168.64.6 port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 192.168.64.6 port 80: Connection refused

If I switch back to the built-in addon, it works again:

$ helm uninstall nginx-ingress
release "nginx-ingress" uninstalled

$ minikube addons enable ingress
✅  ingress was successfully enabled

$ curl -iv "192.168.64.6"
* Rebuilt URL to: 192.168.64.6/
* Hostname was NOT found in DNS cache
*   Trying 192.168.64.6...
* Connected to 192.168.64.6 (192.168.64.6) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 192.168.64.6
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
* Server openresty/1.15.8.2 is not blacklisted
< Server: openresty/1.15.8.2
Server: openresty/1.15.8.2
< Date: Sun, 09 Feb 2020 07:06:58 GMT
Date: Sun, 09 Feb 2020 07:06:58 GMT
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< Content-Length: 59
Content-Length: 59
< Connection: keep-alive
Connection: keep-alive

< 
Hello, world!
Version: 1.0.0
Hostname: web-9bbd7b488-wsvsw
* Connection #0 to host 192.168.64.6 left intact

Is it possible to install to use this helm chart on minikube correctly?

I disabled ingress addon and installed nginx ingress with a helm chart you mentioned. I tested it and have a solution for you.

When you run:

$ kubectl get services nginx-ingress-controller

you should see this output:

NAME                       TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
nginx-ingress-controller   LoadBalancer   10.96.245.213   <pending>     80:30240/TCP,443:31224/TCP   50s

Notice that EXTERNAL-IP is in pending state.

minikube won't assign this IP by itself, you need to do it manually.

Run kubectl edit svc nginx-ingress-controller and add externalIPs field under spec: like following:

spec:
  externalIPs:
  - 192.168.39.241 # minikube ip

Now let's see why this works. Normally when running kubernetes in cloud environemnt when creating service of type LoadBalancer, cloud controller would create a load balancer and update the IP of the service, but because you are running it on minikube where no cloud specific features are working you need to add the address manually.

This can by any IP of any interface associated with your cluster so it should also work when having more nodes. You can add IP of any interface of your nodes and kuberentes will bind port on this interface and from now on you can send traffic to it and it will get forwarded to appropriate service/pod.

Let me know it it was helpful.

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