Unable to add multiple Ingresses with same host on nginx-ingress

纵然是瞬间 提交于 2020-06-09 04:30:50

问题


I am trying to add multiple Ingresses which should share the same host. One Ingress should handle requests to www.example.de/some and the one all other requests.

Here is a snipped with the Ingress configurations

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: some-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: "www.example.de"
    http:
      paths:
      - path: "/some"
        backend:
          serviceName: some-svc
          servicePort: 8585

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: other-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: "www.example.de"
    http:
      paths:
      - backend:
          serviceName: other-svc
          servicePort: 8080

As an ingress-controller I installed the nginx-stable/nginx-ingress via Helm

helm install my-ingress nginx-stable/nginx-ingress

When attempting to create the two Ingresses from above only one is working when trying to access www.example.de (this is mapped to 127.0.0.1 in my /etc/hosts).

In the nginx-ingress log is see the following warnings:

2020/01/08 09:33:51 [warn] 560#560: conflicting server name "www.example.de" on 0.0.0.0:80, ignored

2020/01/08 09:33:51 [warn] 560#560: conflicting server name "www.example.de" on 0.0.0.0:443, ignored


回答1:


Turns out that I was using the wrong nginx-ingress controller. The nginxinc/kubernetes-ingress controller does not support merging Ingress rules with the same host (only via Mergeable Ingresses).

Instead the kubernetes/ingress-nginx should be used. The differences between these controllers are listed here.

Deleting the old controller and installing kubernetes/ingress-nginx instead using the following command fixed the problem.

helm install my-nginx stable/nginx-ingress

See https://kubernetes.github.io/ingress-nginx/deploy/#using-helm



来源:https://stackoverflow.com/questions/59664998/unable-to-add-multiple-ingresses-with-same-host-on-nginx-ingress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!