Skip to content

Commit

Permalink
Remove all Vnet Peerings on delete all clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Nov 12, 2024
1 parent 8876ae4 commit 7f45e81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,14 @@ def peer_vnets():
return peering_cmd

def clear_aks_vnet_peerings():
delete_peering_cmd = "; echo \"--------Clearing AKS VNETs Peerings--------\""
delete_peering_cmd = "; echo \"--------Clearing AKS MGMT VNETs Peerings--------\""
delete_peering_cmd += "; az network vnet wait --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --created --timeout 180"
delete_peering_cmd += "; echo \" 1/2 ${AKS_MGMT_VNET_NAME} found \""
delete_peering_cmd += "; echo \" ${AKS_MGMT_VNET_NAME} found \""

# TODO: xargs: command line cannot be assembled, too long
delete_peering_cmd += "; az network vnet peering list --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --output tsv | xargs -I {} az network vnet peering delete --name {} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --only-show-errors --output none"
delete_peering_cmd += "; echo \" 2/2 All peerings deleted in mgmt cluster's vnet ${AKS_MGMT_VNET_NAME}\""
# List all peering names and store them in an array
delete_peering_cmd += "; PEERING_NAMES=$(az network vnet peering list --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --query \"[].name\" --output tsv)"
delete_peering_cmd += "; for PEERING_NAME in ${PEERING_NAMES[@]}; do echo \"Deleting peering: ${PEERING_NAME}\"; az network vnet peering delete --name ${PEERING_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME}; done"
delete_peering_cmd += "; echo \"All VNETs Peerings deleted in ${AKS_MGMT_VNET_NAME}\""

return delete_peering_cmd

Expand Down

0 comments on commit 7f45e81

Please sign in to comment.