How to configure Azure Application Gateway Ingress Controller (AGIC) yaml

9/17/2021

I need help in AGIC configuration. I am using Loadbalancer service for my existing AKS cluster and below is the sample yaml file that works and I can access application using LB public IP :

apiVersion: apps/v1
kind: Deployment
metadata:
  name: aspnetapp
  namespace: asp-test
  labels:
    app: asp-frontend
spec:
  selector:
    matchLabels:
      app: asp-frontend
  template:
    metadata:
      labels:
        app: asp-frontend
    spec:
      containers:
      - name: aspnetapp
        image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp" 
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: aspnetapp-load
  namespace: asp-test
  labels:
    app: asp-frontend
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: mc_asp-onef-dev_rg_asp_aks_eastus2
spec:
  loadBalancerIP: 10.10.10.10
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 80
  selector:
    app: asp-frontend

==================

Now I would like to use AGIC instead of LB and I am just adding below section in the file but I get "502 bad gateway" error. My AKS and AG vnets are peered. I don't have NSG to block connection. Deployment is successful and pods are running. I can access it using LB IP but not using AGIC.

I have tried editing this file and use normal AKS service instead of LB but I still get same error.

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: aspnetapp
  namespace: asp-test
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: aspnetapp-load
          servicePort: 80
-- Susheel Bhatt
azure
azure-aks
azure-application-gateway
kubernetes
kubernetes-ingress

0 Answers