Rustam Miftakhutdinov
Rustam Miftakhutdinov

Reputation: 170

Azure scale set ARM template redeployment resets node count

I'm trying to set up a continuous delivery pipeline for my ARM templates in Azure. The template contains resource definition for a scale set with some initial number of instances configured and also autoscale rules.

An example of a similar configuration: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-autoscale

The problem I am facing is that every time the template deployment occurs the number of nodes in the scale set is reset to a value specified in the template.

Example: In scale set resource definition there are following values:

"sku": {
         "name": "[parameters('vmSku')]",
         "tier": "Standard",
         "capacity": "3"
       }

And in autoscale settings there are following values:

"capacity": {
              "minimum": "2",
              "maximum": "5",
              "default": "4"
            }

Plus some basic CPU bound rules to scale in and out.

Now let's say under heavy load the autoscale mechanism increases the node count to 5 which is the maximum value. If at that moment I redeploy the same ARM template I used to create the cluster the node count instantly resets back to 3, two nodes go to deleting state and the system needs to scale back again which doesn't make sense to me.

Is there a way to disable this behavior or do I need to maintain two ARM templates, one for initialization and another for update to use in my CD pipeline? What is the best practice?

Upvotes: 3

Views: 256

Answers (2)

Mubi Ali
Mubi Ali

Reputation: 83

If you pass null value in capacity, it will not mess with existing node count. You can set a parameter or variable flag to allow/restrict scaling.

"autoScale": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "Must be set to true to change node SKU ."
      }

In the SKU:

Put if condition, if you don't want change nodes count then pass null otherwise pass the value of nodes.

Example:

"capacity":  "[if(parameters('autoScale'), parameters('defaultCapacity'), json('null'))]",

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72201

no, there is no way to disable this behaviour. it is by design. i dont think there is any viable workaround without using scripts to fetch existing node count and put it into the arm template as a resource, perhaps using reference() function to pull the same value might work, but you'd need a nested template for that

Upvotes: 2

Related Questions