Skip to content

Instantly share code, notes, and snippets.

@geekzter
Last active April 27, 2021 15:56
Show Gist options
  • Select an option

  • Save geekzter/8034f5437ef7eaf4220b836c777362a0 to your computer and use it in GitHub Desktop.

Select an option

Save geekzter/8034f5437ef7eaf4220b836c777362a0 to your computer and use it in GitHub Desktop.
Application Gateway Ingress Controller script (PowerShell)
#!/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