Ingressresource conflicting and overriding other ( EXACT vs IMPLEMENTATION SPECIFIC )

Viewed 29

I have two ingress resources both are mapped to use nginx-ingress-controller

Ingress 1 -

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: github-eventsource
  namespace: argo-events
  annotations:
    ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  ingressClassName: nginx
  rules:
  - host: ad27b4b64cf6e4882a21b2500424b4de-65f846a64d3d542c.elb.eu-west-1.amazonaws.com
    # host: dryrun.tk
    http:
      paths:
      - path: /argocd-webhook
        pathType: Exact
        backend:
          service:
            name: github-eventsource-svc
            port:
              number: 12000

Ingress 2 -

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1
  namespace: services
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - path: /app1
            pathType: ImplementationSpecific
            backend:
              service:
                name: app1
                port:
                  number: 80

However when I both ingress resources are deployed and I try to curl Ingress-2 I get the below response as 404 -

curl ad27b4b64cf6e4882a21b2500424b4de-65f846a64d3d542c.elb.eu-west-1.amazonaws.com/app1

It always gives me error -

<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

However if I remove/delete the Ingress-1 completely then Ingress-2 starts working and I get proper 200 response and data back as expected -

curl ad27b4b64cf6e4882a21b2500424b4de-65f846a64d3d542c.elb.eu-west-1.amazonaws.com/app1

This is an example app%

I want to understand here why is the Ingress-1 is conflicting with Ingress-2 when one is mapped to be exact match by Pathsegment + port 12000( should be targeting a very specific url ) and the other one being Implementation specific.

1 Answers

Found the issue -

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1
  namespace: services
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - path: /app1
            pathType: ImplementationSpecific
            backend:
              service:
                name: app1
                port:
                  number: 80

The above must have a host. The host in Ingress-2 was missing and based on precedence the Ingress-1 has a host defined. So it takes precedence over the wildcard first. I added the host to fix it on Ingress-2 and I am getting the proper response now . The issue was not with pathType

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1
  namespace: services
spec:
  ingressClassName: nginx
  rules:
    - host: ad27b4b64cf6e4882a21b2500424b4de-65f846a64d3d542c.elb.eu-west-1.amazonaws.com
      http:
        paths:
          - path: /app1
            pathType: ImplementationSpecific
            backend:
              service:
                name: app1
                port:
                  number: 80
Related