File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ if [ " $# " -ne 4 ]; then
5+ echo " Usage: $0 <subscription-id> <resource-group> <cluster-name> <nodepool-name>"
6+ echo " This script adds a nodepool with 'machines' mode to an existing AKS cluster using Azure REST API."
7+ echo " Example:"
8+ echo " $0 00000000-0000-0000-0000-000000000000 some-rg some-cluster somepool"
9+ exit 1
10+ fi
11+
12+ AZURE_SUBSCRIPTION_ID=$1
13+ RESOURCE_GROUP=$2
14+ CLUSTER_NAME=$3
15+ NODEPOOL_NAME=$4
16+
17+ echo " Adding nodepool '$NODEPOOL_NAME ' with machines mode to cluster '$CLUSTER_NAME ' in resource group '$RESOURCE_GROUP '..."
18+
19+ # REST API endpoint
20+ # TODO: switch to Azure CLI when it supports AgentPool creation with machines mode
21+ API_VERSION=" 2025-07-01"
22+ URL=" https://management.azure.com/subscriptions/${AZURE_SUBSCRIPTION_ID} /resourceGroups/${RESOURCE_GROUP} /providers/Microsoft.ContainerService/managedClusters/${CLUSTER_NAME} /agentPools/${NODEPOOL_NAME} ?api-version=${API_VERSION} "
23+
24+ # Request body with machines mode
25+ REQUEST_BODY=$( cat << EOF
26+ {
27+ "properties": {
28+ "mode": "Machines",
29+ }
30+ }
31+ EOF
32+ )
33+
34+ echo " Making REST API call..."
35+ echo " URL: $URL "
36+ echo " Request Body:"
37+ echo " $REQUEST_BODY "
38+
39+ if az rest --method PUT --url " $URL " --body " $REQUEST_BODY " ; then
40+ echo " ✅ Successfully added nodepool '$NODEPOOL_NAME ' with machines mode"
41+ else
42+ echo " ❌ Failed to add nodepool"
43+ exit 1
44+ fi
You can’t perform that action at this time.
0 commit comments