Azure / application-gateway-kubernetes-ingress

This is an ingress controller that can be run on Azure Kubernetes Service (AKS) to allow an Azure Application Gateway to act as the ingress for an AKS cluster.
https://azure.github.io/application-gateway-kubernetes-ingress
MIT License
677 stars 420 forks source link

502 error with all but one route in path-based routing #1527

Closed PaulIsProgramming closed 1 year ago

PaulIsProgramming commented 1 year ago

Describe the bug I have the routes of type prefix defined in my ingress:

  1. '/api/users/signin'
  2. '/'

The '/' path lead to a client webapp that is successfully being loaded when I type the website address. When I try to signin via the 2nd route , I get a 502 error.

To Reproduce

  1. Kubernetes apply ingress script
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  namespace: dev
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
spec:
  tls:
    - hosts:
        - mydomain.com
      secretName: mysecret-tls
  rules:
    - host: mydomain.com
      http:
        paths:
          - pathType: Prefix
            path: /api/users/signin
            backend:
              service:
                name: auth-srv
                port:
                  number: 3000
          - pathType: Prefix
            path: /
            backend:
              service:
                name: client-srv
                port:
                  number: 3000

Ingress Controller details

When looking at the app gateway logs in Azure portal, I can see that for a requested route the correct backend setting name and backend pool name are selected for all routes (in columns backendPoolName_s and backendSettingName_s). What is strange, the serverRouted_s column lists for the successful request to path '/' the correct IP: 10.0.0.234:3000 However, for the unsuccessful request to signin, the serverRouted_s column shows the name of the backendPoolName instead of the resolved IP address. Also, the server response latency for the not working signin request is 0.

Looking at the backend settings and backend pool settings in Azure portal, there is no obvious difference between the working client and the not working signin configurations. The backend target in the rules menu also look good. If I choose the signin route as the backend target in Azure portal (=the target that the request is routed too when no path matches), the error still occurs. When I remove the '/' route entirely and only leave the signin route and try to send a request with Postman, the same 502 error persists.

Not sure whether this not resolved serverRouted_s entry in the debug log points to the true cause of the error. I am very greatful for any hint where to check because it all looks set up just fine in azure portal and there are no obvious differeneces between the working client route and the not working signin route.

Cheers

PaulIsProgramming commented 1 year ago

this is related to 502 Bad Gateway #1020, specifically