Last active
December 23, 2020 17:42
-
-
Save nathan815/0fd6496d09848ac558f422debdd7f19c to your computer and use it in GitHub Desktop.
AKS DNS Fix: Custom Subnet Route Table Association
This file contains 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
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