Skip to content

Instantly share code, notes, and snippets.

@nathan815
Last active December 23, 2020 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathan815/0fd6496d09848ac558f422debdd7f19c to your computer and use it in GitHub Desktop.
Save nathan815/0fd6496d09848ac558f422debdd7f19c to your computer and use it in GitHub Desktop.
AKS DNS Fix: Custom Subnet Route Table Association
AKS_RG="$1"
CLUSTER_NAME="$2"
VNET_NAME="$3"
SUBNET_NAME="$4"
LOCATION="$5"
LOCATION=${LOCATION:-"eastus"} # default to eastus
echo "AKS_RG=$AKS_RG, VNET_NAME=$VNET_NAME, SUBNET_NAME=$SUBNET_NAME"
AKS_MC_RG="MC_${AKS_RG}_${CLUSTER_NAME}_${LOCATION}"
echo "AKS_MC_RG=$AKS_MC_RG"
ROUTE_TABLE=$(az network route-table list -g ${AKS_MC_RG} --query "[].id | [0]" -o tsv)
echo "ROUTE_TABLE=$ROUTE_TABLE"
AKS_NODE_SUBNET_ID=$(az network vnet subnet show -g ${AKS_RG} --name ${SUBNET_NAME} --vnet-name ${VNET_NAME} --query id -o tsv)
echo "AKS_NODE_SUBNET_ID=$AKS_NODE_SUBNET_ID"
AKS_NODE_NSG=$(az network nsg list -g ${AKS_MC_RG} --query "[].id | [0]" -o tsv)
echo "AKS_NODE_NSG=$AKS_NODE_NSG"
echo "Associating route table and subnet..."
az network vnet subnet update \
--route-table $ROUTE_TABLE \
--network-security-group $AKS_NODE_NSG \
--ids $AKS_NODE_SUBNET_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment