Skip to content

Commit 4ddd3d6

Browse files
author
sivakami
committed
use make tragets to create aks clusters.
1 parent 41edd59 commit 4ddd3d6

File tree

2 files changed

+82
-36
lines changed

2 files changed

+82
-36
lines changed
Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,63 @@
11
#!/usr/bin/env bash
2-
set -e
2+
set -euo pipefail
33
trap 'echo "[ERROR] Failed during Resource group or AKS cluster creation." >&2' ERR
4-
54
SUBSCRIPTION_ID=$1
65
LOCATION=$2
76
RG=$3
87
VM_SKU_DEFAULT=$4
98
VM_SKU_HIGHNIC=$5
109

11-
echo "Subscription id: $SUBSCRIPTION_ID"
12-
echo "Resource group: $RG"
13-
echo "Location: $LOCATION"
14-
echo "VM SKU (default): $VM_SKU_DEFAULT"
15-
echo "VM SKU (high-NIC): $VM_SKU_HIGHNIC"
16-
az account set --subscription "$SUBSCRIPTION_ID"
17-
18-
# Enable parallel cluster creation
19-
create_cluster() {
20-
local CLUSTER=$1
21-
echo "==> Creating AKS cluster: $CLUSTER"
22-
23-
az aks create -g "$RG" -n "$CLUSTER" -l "$LOCATION" \
24-
--network-plugin azure --node-count 1 \
25-
--node-vm-size "$VM_SKU_DEFAULT" \
26-
--enable-managed-identity --generate-ssh-keys \
27-
--load-balancer-sku standard --yes --only-show-errors
28-
29-
echo "==> Adding high-NIC nodepool to $CLUSTER"
30-
az aks nodepool add -g "$RG" -n highnic \
31-
--cluster-name "$CLUSTER" --node-count 2 \
32-
--node-vm-size "$VM_SKU_HIGHNIC" --mode User --only-show-errors
33-
34-
echo "Finished AKS cluster: $CLUSTER"
10+
CLUSTER_COUNT=2
11+
CLUSTER_PREFIX="aks"
12+
DEFAULT_NODE_COUNT=1
13+
COMMON_TAGS="fastpathenabled=true RGOwner=LongRunningTestPipelines stampcreatorserviceinfo=true"
14+
15+
wait_for_provisioning() { # Helper for safe retry/wait for provisioning states (basic)
16+
local rg="$1" clusterName="$2"
17+
echo "Waiting for AKS '$clusterName' in RG '$rg' to reach Succeeded/Failed (polling)..."
18+
while :; do
19+
state=$(az aks show --resource-group "$rg" --name "$clusterName" --query provisioningState -o tsv 2>/dev/null || true)
20+
if [ -z "$state" ]; then
21+
sleep 3
22+
continue
23+
fi
24+
case "$state" in
25+
Succeeded|Succeeded*) echo "Provisioning state: $state"; break ;;
26+
Failed|Canceled|Rejected) echo "Provisioning finished with state: $state"; break ;;
27+
*) printf "."; sleep 6 ;;
28+
esac
29+
done
3530
}
3631

37-
# Run both clusters in parallel
38-
create_cluster "aks-cluster-a" &
39-
pid_a=$!
40-
41-
create_cluster "aks-cluster-b" &
42-
pid_b=$!
43-
44-
# Wait for both to finish
45-
wait $pid_a $pid_b
4632

47-
echo "AKS clusters created successfully!"
33+
for i in $(seq 1 "$CLUSTER_COUNT"); do
34+
echo "=============================="
35+
echo " Working on cluster set #$i"
36+
echo "=============================="
37+
38+
CLUSTER_NAME="${CLUSTER_PREFIX}-${i}"
39+
echo "Creating AKS cluster '$CLUSTER_NAME' in RG '$RG'"
40+
41+
make -C ./hack/aks azcfg AZCLI=az REGION=$LOCATION
42+
43+
make -C ./hack/aks swiftv2-podsubnet-cluster-up \
44+
AZCLI=az REGION=$LOCATION \
45+
SUB=$SUBSCRIPTION_ID \
46+
GROUP=$RG \
47+
CLUSTER=$CLUSTER_NAME \
48+
NODE_COUNT=$DEFAULT_NODE_COUNT \
49+
VM_SIZE=$VM_SKU_DEFAULT \
50+
51+
echo " - waiting for AKS provisioning state..."
52+
wait_for_provisioning "$RG" "$CLUSTER_NAME"
53+
54+
echo "Adding multi-tenant nodepool ' to '$CLUSTER_NAME'"
55+
make -C ./hack/aks linux-swiftv2-nodepool-up \
56+
AZCLI=az REGION=$LOCATION \
57+
GROUP=$RG \
58+
VM_SIZE=$VM_SKU_HIGHNIC \
59+
CLUSTER=$CLUSTER_NAME \
60+
SUB=$SUBSCRIPTION_ID \
61+
62+
done
63+
echo "All done. Created $CLUSTER_COUNT cluster set(s)."

hack/aks/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,24 @@ swiftv2-dummy-cluster-up: rg-up ipv4 swift-net-up ## Bring up a SWIFT AzCNI clus
285285
--yes
286286
@$(MAKE) set-kubeconf
287287

288+
swiftv2-podsubnet-cluster-up: ipv4 swift-net-up ## Create dummy AKS cluster to create pod and node subnets for AKS pod subnet cluster.
289+
$(AZCLI) aks create -n "$(CLUSTER)" -g $(GROUP) -l $(REGION) \
290+
--network-plugin azure \
291+
--kubernetes-version $(K8S_VER) \
292+
--nodepool-name nodepool1 \
293+
--node-vm-size $(VM_SIZE) \
294+
--node-count $(NODE_COUNT) \
295+
--load-balancer-outbound-ips $(PUBLIC_IPv4) \
296+
--no-ssh-key \
297+
--vnet-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/nodenet \
298+
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet \
299+
--service-cidr "10.0.0.0/16" \
300+
--dns-service-ip "10.0.0.10" \
301+
--tags fastpathenabled=true RGOwner=LongRunningTestPipelines stampcreatorserviceinfo=true \
302+
--http-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkingMultiTenancyPreview \
303+
--yes
304+
@$(MAKE) set-kubeconf
305+
288306
# The below Vnet Scale clusters are currently only in private preview and available with Kubernetes 1.28
289307
# These AKS clusters can only be created in a limited subscription listed here:
290308
# https://dev.azure.com/msazure/CloudNativeCompute/_git/aks-rp?path=/resourceprovider/server/microsoft.com/containerservice/flags/network_flags.go&version=GBmaster&line=134&lineEnd=135&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents
@@ -424,6 +442,18 @@ windows-swift-nodepool-up: ## Add windows node pool
424442
--subscription $(SUB) \
425443
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet
426444

445+
linux-swiftv2-nodepool-up: ## Add linux node pool to swiftv2 cluster
446+
$(AZCLI) aks nodepool add -g $(GROUP) -n nplinux \
447+
--node-count $(NODE_COUNT) \
448+
--node-vm-size $(VM_SIZE) \
449+
--cluster-name $(CLUSTER) \
450+
--os-type Linux \
451+
--max-pods 250 \
452+
--subscription $(SUB) \
453+
--tags fastpathenabled=true,aks-nic-enable-multi-tenancy=true \
454+
--http-headers AKSHTTPCustomFeatures=Microsoft.ContainerService/NetworkingMultiTenancyPreview \
455+
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet
456+
427457
down: ## Delete the cluster
428458
$(AZCLI) aks delete -g $(GROUP) -n $(CLUSTER) --yes
429459
@$(MAKE) unset-kubeconf

0 commit comments

Comments
 (0)