AKS & Application Gateway: Expose more than one service in an ingress resource

If you install the Azure Application Gateway Ingress Controller for your AKS clusters you may want to expose more than one service through the same Public IP just changing the url path. In order to make this work you must use the backend-path-prefix annotation.

In the following sample I create an ingress with the following behavior:

  1. Calls to http://[Waf Pulic IP or DNS]/inventory are sent to the inventory service
  2. Calls to http://[Waf Pulic IP or DNS]/orders are sent to the orders service
 2apiVersion: extensions/v1beta1
 3kind: Ingress
 5  name: backend-ingress
 6  annotations:
 7    # Service are serving content in this path.
 8    appgw.ingress.kubernetes.io/backend-path-prefix: "/"
 9    kubernetes.io/ingress.class: azure/application-gateway
11  rules:
12  - http:
13      paths:
14      - path: /inventory/*
15        backend:
16          serviceName: inventory
17          servicePort: 80
18      - path: /orders/*
19        backend:
20          serviceName: orders
21          servicePort: 80

Note that the appgw.ingress.kubernetes.io/backend-path-prefix value is set to: / which means that the paths specified in the rules are rewritten to this value when sent to your services.

Hope it helps.

AKS: Persistent Volume with existing Storage Account
Running the Global Azure Bootcamp Science Lab in Kubernetes
comments powered by Disqus