Last active
April 27, 2021 15:56
-
-
Save geekzter/8034f5437ef7eaf4220b836c777362a0 to your computer and use it in GitHub Desktop.
Application Gateway Ingress Controller script (PowerShell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env pwsh | |
| param ( | |
| [parameter(Mandatory=$true)][string]$AksName, | |
| [parameter(Mandatory=$false)][string]$ApplicationGatewayName="${ResourceGroupName}-waf", | |
| [parameter(Mandatory=$true)][string]$ApplicationGatewaySubnetID, | |
| [parameter(Mandatory=$true)][string]$ResourceGroupName | |
| ) | |
| function Get-AGICState() { | |
| return $(az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/AKS-IngressApplicationGatewayAddon')].properties.state" -o tsv) | |
| } | |
| az extension add --name aks-preview 2>$null | |
| if ($ApplicationGatewayName -ieq $(az aks show -n $AksName -g $ResourceGroupName --query "addonProfiles.ingressApplicationGateway.config.applicationGatewayName" -o tsv)) { | |
| Write-Host "$ApplicationGatewayName is already configured as add on for $AksName" | |
| exit | |
| } | |
| $agicState = Get-AGICState | |
| while ($agicState -ine "Registered") { | |
| az feature register --name AKS-IngressApplicationGatewayAddon --namespace Microsoft.ContainerService | |
| Write-Host "Registering feature Microsoft.ContainerService/AKS-IngressApplicationGatewayAddon, waiting 10 seconds..." | |
| Start-Sleep -Seconds 10 | |
| $agicState = Get-AGICState | |
| } | |
| az provider register --namespace Microsoft.ContainerService | |
| Write-Host "Adding Application Gateway Ingress Controller Add On to '$AksName'..." | |
| az aks enable-addons -n $AksName -g $ResourceGroupName -a ingress-appgw --appgw-name $ApplicationGatewayName --appgw-subnet-id $ApplicationGatewaySubnetID --query addonProfiles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment