Skip to content

Commit bb8d631

Browse files
committed
Finalize script
1 parent e87de5c commit bb8d631

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

modules/kustomize/stretch/stretch.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ RG=stretch-rg
33
CLUSTER=cni-stretch
44
VNET_NAME="aks-vnet"
55
SUBNET="aks-subnet"
6+
IDENTITY_NAME="${CLUSTER}-identity"
67

78
TENANT_ID="72f988bf-86f1-41af-91ab-2d7cd011db47"
89
AAD_ADMIN_GROUP_ID="8a5603a8-2c60-49ab-bc28-a989b91e187d"
@@ -17,7 +18,6 @@ create_cluster() {
1718
subnet_id=$(az network vnet subnet show --resource-group $RG --vnet-name $VNET_NAME --name $SUBNET --query id -o tsv)
1819

1920
# Create user-assigned managed identity
20-
IDENTITY_NAME="${CLUSTER}-identity"
2121
az identity create --name $IDENTITY_NAME --resource-group $RG --location $LOCATION
2222

2323
# Get the identity resource ID and principal ID
@@ -236,19 +236,44 @@ create_vm() {
236236
NODE_NAME="freenode"
237237
NODE_USER="azureuser"
238238
NODE_VM_SIZE="Standard_D8ds_v6"
239+
identity_id=$(az identity show --name $IDENTITY_NAME --resource-group $RG --query id -o tsv)
239240
az vm create \
240241
--resource-group $RG \
241242
--name $NODE_NAME \
242243
--image Ubuntu2404 \
243244
--admin-username $NODE_USER \
244245
--generate-ssh-keys \
245-
--assign-identity \
246+
--assign-identity $identity_id \
246247
--public-ip-sku Standard \
247248
--vnet-name $VNET_NAME \
248249
--subnet $SUBNET \
249250
--size $NODE_VM_SIZE \
250251
--nsg-rule SSH
251252
}
252253

254+
create_vmss() {
255+
az network lb create \
256+
--resource-group $RG \
257+
--name vmss-lb \
258+
--sku Standard \
259+
--frontend-ip-name lb-frontend \
260+
--backend-pool-name lb-backend-pool
261+
lb_backend_pool_id=$(az network lb address-pool show \
262+
--resource-group $RG \
263+
--lb-name vmss-lb \
264+
--name lb-backend-pool \
265+
--query id -o tsv)
266+
identity_id=$(az identity show --name $IDENTITY_NAME --resource-group $RG --query id -o tsv)
267+
az deployment group create \
268+
--resource-group $RG \
269+
--template-file vmss-dual-ipconfig.json \
270+
--parameters vmssName="test-vmss" \
271+
--parameters sshPublicKey="$(cat ~/.ssh/id_rsa.pub)" \
272+
--parameters vnetName=$VNET_NAME \
273+
--parameters subnetName=$SUBNET \
274+
--parameters loadBalancerBackendPoolId="$lb_backend_pool_id" \
275+
--parameters managedIdentityId="$identity_id"
276+
}
277+
253278
update_aks_vmss
254279
# create_vm

modules/kustomize/stretch/vmss-dual-ipconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"metadata": {
7070
"description": "Resource ID of the load balancer backend pool (optional)"
7171
}
72+
},
73+
"managedIdentityId": {
74+
"type": "string",
75+
"defaultValue": "",
76+
"metadata": {
77+
"description": "Resource ID of the user-assigned managed identity to associate with the VMSS (optional)"
78+
}
7279
}
7380
},
7481
"variables": {
@@ -94,6 +101,7 @@
94101
"tier": "Standard",
95102
"capacity": "[parameters('instanceCount')]"
96103
},
104+
"identity": "[if(empty(parameters('managedIdentityId')), json('null'), json(concat('{\"type\": \"UserAssigned\", \"userAssignedIdentities\": {\"', parameters('managedIdentityId'), '\": {}}}')))]",
97105
"properties": {
98106
"overprovision": false,
99107
"upgradePolicy": {

0 commit comments

Comments
 (0)