|
| 1 | +parameters: |
| 2 | + depend: "" |
| 3 | + clusterName: "" # unique identifier |
| 4 | + vmSize: "" |
| 5 | + |
| 6 | +jobs: |
| 7 | +- job: windows_nodepool |
| 8 | + displayName: Add Windows Nodepool |
| 9 | + dependsOn: ${{ parameters.depend }} |
| 10 | + timeoutInMinutes: 30 |
| 11 | + steps: |
| 12 | + - task: AzureCLI@2 |
| 13 | + displayName: "Add windows node to cluster" |
| 14 | + retryCountOnTaskFailure: 5 |
| 15 | + env: |
| 16 | + AZCLI: az |
| 17 | + SUB: $(SUB_AZURE_NETWORK_AGENT_BUILD_VALIDATIONS) |
| 18 | + CLUSTER: ${{ parameters.clusterName }} |
| 19 | + VM_SIZE_WIN: ${{ parameters.vmSize }} |
| 20 | + inputs: |
| 21 | + azureSubscription: $(BUILD_VALIDATIONS_SERVICE_CONNECTION) |
| 22 | + scriptLocation: "inlineScript" |
| 23 | + scriptType: "bash" |
| 24 | + addSpnToEnvironment: true |
| 25 | + inlineScript: | |
| 26 | + set -e |
| 27 | + |
| 28 | + windows_nodepool=$(az aks nodepool list \ |
| 29 | + --resource-group "$CLUSTER" \ |
| 30 | + --cluster-name "$CLUSTER" \ |
| 31 | + --query "[?osType=='Windows']" \ |
| 32 | + --output tsv) |
| 33 | +
|
| 34 | + if [ -z "$windows_nodepool" ]; then |
| 35 | + echo "No Windows node pool found in the AKS cluster." |
| 36 | +
|
| 37 | + # wait for cluster to update |
| 38 | + while true; do |
| 39 | + cluster_state=$(az aks show \ |
| 40 | + --resource-group "$CLUSTER" \ |
| 41 | + --name "$CLUSTER" \ |
| 42 | + --query provisioningState) |
| 43 | + |
| 44 | + if echo "$cluster_state" | grep -q "Updating"; then |
| 45 | + echo "Cluster is updating. Sleeping for 30 seconds..." |
| 46 | + sleep 30 |
| 47 | + else |
| 48 | + break |
| 49 | + fi |
| 50 | + done |
| 51 | + # cluster state is always set and visible outside the loop |
| 52 | + echo "Cluster state is: $cluster_state" |
| 53 | +
|
| 54 | + make -C ./hack/aks set-kubeconf |
| 55 | + make -C ./hack/aks windows-nodepool-up |
| 56 | + echo "Windows node was successfully added" |
| 57 | + kubectl cluster-info |
| 58 | + kubectl get node -owide |
| 59 | + kubectl get po -owide -A |
| 60 | + else |
| 61 | + echo "Windows node pool already exists in the AKS cluster." |
| 62 | + fi |
0 commit comments