I have deployed the standard aspnet app from Microsoft, from the following YAML:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: microservicesapp
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: aspnetapp
servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
name: aspnetapp
spec:
selector:
app: aspnetapp
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: v1
kind: Pod
metadata:
name: aspnetapp
labels:
app: aspnetapp
spec:
containers:
- image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp"
name: aspnetapp-image
ports:
- containerPort: 80
protocol: TCP
Everything works fine when I call the public IP associated with my AGW resourced. However, I want to configure the path of the ingress, so that it is /test
. Like so:
- http:
paths:
- path: /test
backend:
serviceName: aspnetapp
servicePort: 80
When I attempt to call the endpoint from outside the cluster, this results in 502 Bad Gateway. The Controller logs after deployment of the resources in the above YAML:
I0918 17:25:16.798265 1 health_probes.go:55] Created default HTTP probe defaultprobe-Http
I0918 17:25:16.798272 1 health_probes.go:56] Created default HTTPS probe defaultprobe-Http
I0918 17:25:16.798279 1 ingress_rules.go:148] Found backend:default/aspnetapp
I0918 17:25:16.798405 1 health_probes.go:70] Created probe pb-default-aspnetapp-80-microservicesapp for ingress default/microservicesapp at service default/aspnetapp
I0918 17:25:16.798613 1 backendhttpsettings.go:190] Created backend http settings bp-default-aspnetapp-80-80-microservicesapp for ingress default/microservicesapp and service default/aspnetapp
I0918 17:25:16.798671 1 backendaddresspools.go:37] Created default backend pool defaultaddresspool
I0918 17:25:16.798698 1 backendaddresspools.go:48] Created backend pool pool-default-aspnetapp-80-bp-80 for service default/aspnetapp
I0918 17:25:16.798709 1 frontend_listeners.go:121] Processing Rules for Ingress: default/microservicesapp
I0918 17:25:16.798828 1 requestroutingrules.go:349] Attached pool pool-default-aspnetapp-80-bp-80 and http setting bp-default-aspnetapp-80-80-microservicesapp to path rule: pr-default-microservicesapp-0
I0918 17:25:16.798861 1 requestroutingrules.go:107] Bound path-based rule: rr-e1903c8aa3446b7b3207aec6d6ecba8a to listener: fl-e1903c8aa3446b7b3207aec6d6ecba8a ([ ], 80) and url path map url-e1903c8aa3446b7b3207aec6d6ecba8a
I0918 17:25:16.808144 1 mutate_app_gateway.go:174] Generated config:
...
What is the correct way to set a path, like /test
, so that all traffic to that path, is directed to the aspnetapp service?
/test
in the application. Have you confirmed from somewhere that the application will respond successfully when sent a request with path/test
. If yes can you post that link here./test
to a said backendpool in the appgw. Now appgw will forward request to the correct backend but if your application doesn't have any response for such a path, then it wont send back any response which will result in 502. As I already told below, build your own simple nginx image with a html page for/test
and try the same case, you will understand what is happening here.