Adding some additional information. the Application Gateway reports, the backend is unhealthy. But the Backend is healthy in service level.
Azure application gateway giving BAD Gateway 502
Hi everyone,
When deploying ingress with Azure Kubernetes service with Azure Application Gateway enabled at the cluster level. The ingress controller fails to route to the back end.
Followed the documentation at https://stackoverflow.com/questions/67915527/aks-bad-gateway-502-error-when-accessing-gateway-ip to configure the annotation
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/use-private-ip: "false"
But Still the gateway give 502.
Please find the configuration below
Am i missing something?
Regards,
Aldrine
Azure Application Gateway
Azure Kubernetes Service
4 answers
Sort by: Most helpful
-
-
Aldrine Einsteen 1 Reputation point
2022-02-17T11:40:16.297+00:00 Please find my configuration below:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-world-ingress namespace: dev-api annotations: kubernetes.io/ingress.class: azure/application-gateway deployment.time: ${CI_PIPELINE_CREATED_AT} spec: rules: - http: paths: - path: /hello pathType: Exact backend: service: name: aks-helloworld-one port: number: 80
Additionally, the ing is listed down as
hello-world-ingress <none> * <Public IP of APP Gateway> 80 5m11s
-
shiva patpi 13,366 Reputation points Microsoft Employee Moderator
2022-02-17T23:12:19.677+00:00 Hello @Aldrine Einsteen ,
There can be many reasons for AppGW 502 errors , mainly if the backend health shows as 'unhealthy' in appgw:- Can you check if readiness probe or liveness probe was defined in your application ?
- If they are defined just make sure the path of those probes is correct.
From the document: https://azure.github.io/application-gateway-kubernetes-ingress/features/probes/
- readinessProbe and livenessProbe are supported when configured with httpGet.
- Probing on a port other than the one exposed on the pod is currently not supported.
- HttpHeaders, InitialDelaySeconds, SuccessThreshold are not supported.
Have a look at : https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502
Can you try out the below mentioned sample YAML files :
https://learn.microsoft.com/en-us/azure/aks/ingress-tls?tabs=azure-cliIf you are still facing the issue, please post below files:
- POD YAML
- Service YAML
-
Aldrine Einsteen 1 Reputation point
2022-02-21T10:01:33.51+00:00 Finally got the solution to work. Below are my consolidated changes.
Ingress Annotations:
- kubernetes.io/ingress.class: azure/application-gateway
- appgw.ingress.kubernetes.io/health-probe-path: "/actuator/health"
Deployment:
- livenessProbe
- readinessProbe
Then the access is available.