Application Gateway ingress controller - Path

Sebastian Pacheco 286 Reputation points
2023-05-19T16:18:34.57+00:00

Hello everyone... I have a question with the Application Gateway ingress controller for AKS. Currently I have an entry to a HOST and several "path" since the system has several routes, but all of them in the same pod:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nw-ingress
  namespace: hmtest
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/ssl-redirect: "true" 
    appgw.ingress.kubernetes.io/appgw-ssl-certificate: "cert-hmtest.cl"
    appgw.ingress.kubernetes.io/backend-path-prefix: "/"
spec:
  rules:
  - host: nw.hm.cl
    http:
      paths:
      - path: /
        pathType: Exact
        backend:
          service:
            name: nw-service
            port:
              number: 80
      - path: /login
        pathType: Exact
        backend:
          service:
            name: nw-service
            port:
              number: 80
      - path: /batchTray
        pathType: Exact
        backend:
          service:
            name: nw-service
            port:
              number: 80

If I do not add those paths in the ingress for each route that has the system, when I refresh the page, it returns a "Not Found: The requested URL was not found on this server."... when I add it The path already loads me well if I do a refresh.

As can be seen at the moment, all the paths end in the same service and then end in the same pod, but I must add the 22 routes manually in the ingress so that the "No Found" error does not appear. Is there a way to simplify the path into one and recognize all paths, something like "/*" ??

Thanks ;)

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,447 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Cristian Gatjens 716 Reputation points Microsoft Employee
    2023-05-19T22:03:33.7166667+00:00

    Hello Sebastian,

    Thanks for reaching out and I hope you are doing well.

    When you refresh the page and get the "Not found" message, what is the URL that gets returned?

    Reason I am asking is that you are using pathType as Exact in all of your paths, so if the URL changes when you refresh the page, it is expected to receive a 404 or Not Found message.

    You may want to change the pathType to Prefix so it will automatically add "" at the end of the path, for example /login will be interpreted as /login if using Prefix as pathType.

    You can read more about PathTypes in the following external documents:

    https://azure.github.io/application-gateway-kubernetes-ingress/ingress-v1/

    https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well. Feel free to reply with any other questions or concerns.

    Hope this helps!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.