@@ -48,6 +48,26 @@ for i in $(seq 1 "$CLUSTER_COUNT"); do
4848 echo " - waiting for AKS provisioning state..."
4949 wait_for_provisioning " $RG " " $CLUSTER_NAME "
5050
51+ echo " Retrieving VNET ID from AKS cluster..."
52+
53+ node_subnet=$( az aks show \
54+ --resource-group " $RG " \
55+ --name " $CLUSTER_NAME " \
56+ --query " agentPoolProfiles[0].vnetSubnetID" \
57+ -o tsv)
58+
59+ if [[ -z " $node_subnet " ]]; then
60+ echo " ERROR: Could not retrieve AKS node subnet ID"
61+ exit 1
62+ fi
63+
64+ vnet_id=" ${node_subnet%/ subnets/* } "
65+
66+ echo " Found VNET: $vnet_id "
67+
68+ # Call your stamp function
69+ stamp_vnet " $vnet_id "
70+
5171 echo " Adding multi-tenant nodepool ' to '$CLUSTER_NAME '"
5272 make -C ./hack/aks linux-swiftv2-nodepool-up \
5373 AZCLI=az REGION=$LOCATION \
@@ -67,5 +87,37 @@ for i in $(seq 1 "$CLUSTER_COUNT"); do
6787 --file " $KUBECONFIG_PATH "
6888 echo " Kubeconfig saved: ${KUBECONFIG_PATH} "
6989
90+ # Stamp infra vnet.
91+ function stamp_vnet() {
92+ local vnet_id
93+ vnet_id=" ${1} "
94+
95+ responseFile=" response.txt"
96+ modified_vnet=" ${vnet_id// \/ /% 2F} "
97+ cmd_stamp_curl=" 'curl -v -X PUT http://localhost:8080/VirtualNetwork/$modified_vnet /stampcreatorservicename'"
98+ cmd_containerapp_exec=" az containerapp exec -n subnetdelegator-westus-u3h4j -g subnetdelegator-westus --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f --command $cmd_stamp_curl "
99+
100+ max_retries=6
101+ sleep_seconds=15
102+ retry_count=0
103+ while [[ $retry_count -lt $max_retries ]]; do
104+ script --quiet -c " $cmd_containerapp_exec " " $responseFile "
105+ if grep -qF " 200 OK" " $responseFile " ; then
106+ echo " Subnet Delegator successfully stamped the vnet"
107+ return 0
108+ else
109+ echo " Subnet Delegator failed to stamp the vnet, attempt $(( retry_count+ 1 )) "
110+ cat " $responseFile "
111+ retry_count=$(( retry_count+ 1 ))
112+ sleep " $sleep_seconds "
113+ fi
114+ done
115+ if [[ $retry_count -eq $max_retries ]]; then
116+ echo " Failed to stamp the vnet even after $max_retries attempts"
117+ exit 1
118+ fi
119+ }
120+
121+
70122done
71123echo " All done. Created $CLUSTER_COUNT cluster set(s)."
0 commit comments