A comprehensive guide to setting up Azure Kubernetes Service (AKS) with Application Gateway Ingress Controller for scalable and secure web applications.
- π Overview
- ποΈ Architecture
- π Prerequisites
- βοΈ Setup Instructions
- π Deployment
- π§ͺ Testing
- π Monitoring
- π§Ή Cleanup
- π€ Author
This project demonstrates how to integrate Azure Kubernetes Service (AKS) with Application Gateway Ingress Controller (AGIC) to provide:
- β Layer 7 load balancing with SSL termination
- β Web Application Firewall (WAF) protection
- β Auto-scaling capabilities
- β High availability and fault tolerance
- β Secure networking with VNet peering
Internet β Application Gateway (WAF) β AKS Cluster β NGINX Pods
β
Public IP + SSL
Key Components:
- Application Gateway: Entry point with WAF protection
- AKS Cluster: Container orchestration platform
- AGIC: Kubernetes ingress controller
- VNet Peering: Secure communication between networks
Before you begin, ensure you have:
- Azure CLI installed and configured
- kubectl installed
- Azure subscription with appropriate permissions
- Resource Group created
- AKS cluster already provisioned
First, configure your environment variables:
# π§ Export your variables
export rgName=dev
export aksName=dev-aks
export pipName=dev-pip
export appgwVnetName=dev-appgw-vnet
export appgwSnetName=dev-appgw-snet-01
export location=westeurope
export appgwName=dev-appgw
export wafPolicyName=dev-waf-policy
export aksVnetName=dev-vnet# π Create public IP for Application Gateway
az network public-ip create \
-n $pipName \
-g $rgName \
-l $location \
--allocation-method Static \
--sku Standard# ποΈ Create VNet for Application Gateway
az network vnet create \
-n $appgwVnetName \
-g $rgName \
-l $location \
--address-prefix 10.0.0.0/16 \
--subnet-name $appgwSnetName \
--subnet-prefix 10.0.0.0/24# π‘οΈ Create Web Application Firewall policy
az network application-gateway waf-policy create \
--name $wafPolicyName \
--resource-group $rgName# πͺ Create Application Gateway with WAF v2
az network application-gateway create \
-n $appgwName \
-l $location \
-g $rgName \
--sku WAF_v2 \
--public-ip-address $pipName \
--vnet-name $appgwVnetName \
--subnet $appgwSnetName \
--priority 100 \
--waf-policy $wafPolicyName# π Enable Application Gateway Ingress Controller on AKS
appgwId=$(az network application-gateway show -n $appgwName -g $rgName -o tsv --query "id")
az aks enable-addons \
-n $aksName \
-g $rgName \
-a ingress-appgw \
--appgw-id $appgwId# π Create VNet peerings for secure communication
aksVnetId=$(az network vnet show -n $aksVnetName -g $rgName -o tsv --query "id")
az network vnet peering create \
-n AppGWtoAKSVnetPeering \
-g $rgName \
--vnet-name $appgwVnetName \
--remote-vnet $aksVnetId \
--allow-vnet-access
appGWVnetId=$(az network vnet show -n $appgwVnetName -g $rgName -o tsv --query "id")
az network vnet peering create \
-n AKStoAppGWVnetPeering \
-g $rgName \
--vnet-name $aksVnetName \
--remote-vnet $appGWVnetId \
--allow-vnet-accessDeploy the sample NGINX application:
# π¦ Clone the repository and deploy
git clone https://github.com/soaand01/aksAGIC.git
cd aksAGIC/deployment
# π³ Deploy NGINX application
kubectl create namespace nginx
kubectl apply -f nginx-deployment.yaml -n nginx
kubectl apply -f nginx-service.yaml -n nginx
kubectl apply -f nginx-ingress.yaml -n nginxaksAGIC/
βββ π README.md
βββ π deployment/
βββ π³ nginx-deployment.yaml # NGINX deployment with 5 replicas
βββ π nginx-service.yaml # ClusterIP service on port 8080
βββ πͺ nginx-ingress.yaml # Ingress configuration for AGIC
# π Check your ingress IP
kubectl get ingress -n nginx
# π Monitor pod status
kubectl get pods -n nginx -o wide
# π Check service endpoints
kubectl get endpoints -n nginx# π Get Application Gateway public IP
az network public-ip show \
--resource-group $rgName \
--name $pipName \
--query ipAddress \
--output tsvMonitor your deployment with these commands:
# π Watch pods in real-time
kubectl get pods -n nginx -w
# π View ingress controller logs
kubectl logs -n kube-system -l app=ingress-appgw
# π Check Application Gateway backend health
az network application-gateway show-backend-health \
--name $appgwName \
--resource-group $rgNameTo clean up resources:
# ποΈ Delete Kubernetes resources
kubectl delete namespace nginx
# ποΈ Delete Azure resources
az network application-gateway delete --name $appgwName --resource-group $rgName
az network public-ip delete --name $pipName --resource-group $rgName
az network vnet delete --name $appgwVnetName --resource-group $rgNameContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Anderson Soares Lopes
β If you found this project helpful, please give it a star! β
Made with β€οΈ by Anderson Soares