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

1/9/2020

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

-- LazerBass
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

1/9/2020

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

-- LazerBass
Source: StackOverflow