application-gateway-kubernetes-ingress icon indicating copy to clipboard operation
application-gateway-kubernetes-ingress copied to clipboard

AGIC not preserving path based routing order

Open rbickel opened this issue 2 years ago • 2 comments

When using AGIC 1.5.1 with the ingress below, AGIC doesn't not preserve the path order when updating Application Gateway. This may resulting with the less granular app route above in the ARM template, breaking the routing definition as no requests will ever be routed to the api:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myapp
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /myapp/api*
        pathType: Prefix
        backend:
          service:
            name: myapp-api
            port:
              number: 80      
      - path: /myapp*
        pathType: Prefix
        backend:
          service:
            name: myapp
            port:
              number: 80

While the quickfix could be to use distinct path, we are trying to serve a legacy application that doesn't support another route. Can you confirm if there is any fix for this ? Maybe spreading routes across different files would help ensure the order in the arm template ?

rbickel avatar Apr 05 '22 12:04 rbickel

EDIT: workaround below doesn't work after several tests. Order is not guaranteed neither by the alphabetical order of the ingresses.

~~It would be good to preserve the route order according to the ingress definition. For now the workaround is to use different ingresses, and to use the alphabetical ordering of the ingresses to order the routes correctly. e.g.:~~

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-route-1-specific
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /myapp/api*
        pathType: Prefix
        backend:
          service:
            name: myapp-api
            port:
              number: 80  
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-route-2-generic
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /myapp*
        pathType: Prefix
        backend:
          service:
            name: myapp-api
            port:
              number: 80  

~~With that approach order is forced as AGIC is ordering ingresses by name before generating the ARM template to update Application Gateway.~~

~~This doesn't seem to be the right fix though as the ordering may change in the future and will break this workaround~~

rbickel avatar Apr 05 '22 15:04 rbickel

Duplicate with #884

rbickel avatar Apr 07 '22 07:04 rbickel