acs-engine icon indicating copy to clipboard operation
acs-engine copied to clipboard

Clarify how to scale a cluster created with acs-engine up and down.

Open yuvipanda opened this issue 9 years ago • 12 comments

Is this a request for help?: Yes


Is this an ISSUE or FEATURE REQUEST? (choose one): ISSUE


What version of acs-engine?: Any


Orchestrator and version (e.g. Kubernetes, DC/OS, Swarm) Any

What happened: I was looking to find docs on changing the size of a cluster created with acs-engine. I found this but it's very unclear what it is trying to say or mean.

What you expected to happen: I found documentation on how to scale a cluster up and down, ideally as a User Guide!

yuvipanda avatar Jul 13 '17 04:07 yuvipanda

Have you taken a look at this project: https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler

dcieslak19973 avatar Jul 13 '17 12:07 dcieslak19973

@dcieslak19973 I recently discovered it! I could probably trawl through the code and figure it out, but since resizing a cluster feels like such a fundamental part of runing a cluster, I am hoping someone who already knows it will just write docs :)

yuvipanda avatar Jul 13 '17 17:07 yuvipanda

I'll see if I can make a PR to improve, but the doc is already pretty much complete (albeit missing some newlines :) )

In the mean time, to unblock you, here is the same thing explained a bit differently, let me know if it makes more sense:

Scaling Up:

The issue when scaling up using ARM templates, is that you may overwrite some changes made by kubernetes after the initial deployment. Namely, k8s will make changes to the network resources, and if you just redeploy the template with a different agent count this changes will get overwritten, and all your kubernetes services will stop working.

In order to avoid that, when scaling up you need to do a few things.
I will assume that the pool you want to scale up is named agentpool1 and that you want to go from 2 to 3 agents:

  • In azuredeploy.parameters.json:
    • Add a agentpool1Offset parameter and set the value for this param to 2 (the current number of agents, that we don't want to overwrite).
    • Also update agentpool1Count to be your new desired size, so 3 in this example.
  • In azuredeploy.json:
    • Delete the Microsoft.Network/networkSecurityGroups resource, again, not to overwrite modifications made by k8s.
    • The Microsoft.Network/virtualNetworks has a dependency on the network security group, so you'll need to also delete the dependency of the VNet on the NSG under dependsOn.

You should now be able to scale up correctly and without service interruption. Use incremental mode to deploy the template.

Scaling Down:

You'll need to use Azure REST API. See: https://github.com/wbuchwalter/Kubernetes-acs-engine-autoscaler/blob/master/autoscaler/engine_scaler.py#L71

Or you can manually delete the VM, OS disk, and Network Card corresponding to your VM from the portal.

Note

This is obviously not a great user experience to scale a cluster, so if you plan on doing a lot of scaling you should see if you can use ACS which will allow you to use the az acs scale command, or use the autoscaler @dcieslak19973 mentionned.

wbuchwalter avatar Jul 14 '17 20:07 wbuchwalter

Thanks for that, @wbuchwalter! Let me see if I understand this correctly!

To scale up, I should:

  1. Take a copy of the JSON template that was used to create the cluster
  2. Manually remove the network security groups & virtual networks
  3. Add an offset parameter to the params.json file.
  4. Apply this.

To delete nodes:

  1. Use the azure REST API to remove the node (and associated nic + disks)

is this accurate?

If so, how do you manage:

  1. Multiple scaling up - I've already scaled up, and now want to scale up again. What do I use for offset and count?
  2. Scaling up after scaling down - If I delete some of the nodes so the count changes, what parameters do I use?

That would be most useful, thanks :)

yuvipanda avatar Jul 18 '17 03:07 yuvipanda

re: the az tool, we've generally had bad experiences with its usability & error reporting and so are trying to avoid it (we're still using it to apply ARM templates tho). acs-engine also had 1.6 way for a long time before az seemed to get it, and it's unclear to us if this lag will persist - so we'll prefer using acs-engine for now!

I'll take a look at the autoscaler - thanks for pointing to it! The reason we want to be able to manually scale is because we want something like https://github.com/kubernetes/autoscaler/pull/77 - waiting until all nodes are full before requesting we spin up a new node is too slow for our use case.

Thanks!

yuvipanda avatar Jul 18 '17 03:07 yuvipanda

  1. Manually remove the network security groups & virtual networks

Only remove the network security group. You should keep the VNet, but remove the depency it has on the network security group. For example in the original template the VNet should look like that:

    {
      "apiVersion": "[variables('apiVersionDefault')]",
      "dependsOn": [
        "[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]",
        "[concat('Microsoft.Network/routeTables/', variables('routeTableName'))]"
      ],
      "location": "[variables('location')]",
      "name": "[variables('virtualNetworkName')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[variables('vnetCidr')]"
          ]
        },
        "subnets": [
          {
            "name": "[variables('subnetName')]",
            "properties": {
              "addressPrefix": "[variables('subnet')]",
              "networkSecurityGroup": {
                "id": "[variables('nsgID')]"
              },
              "routeTable": {
                "id": "[variables('routeTableID')]"
              }
            }
          }
        ]
      },
      "type": "Microsoft.Network/virtualNetworks"
    },

And you should remove this line: "[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]",

  1. Multiple scaling up - I've already scaled up, and now want to scale up again. What do I use for offset and count?

Offset is always equal to the number of nodes you currently have in your cluster, and count is equal to the number of nodes you want. Say you had 2 nodes originally, and scaled to 3 nodes. Now you want to scale again to 5 nodes, offset would be 3 and count would be 5.

  1. Scaling up after scaling down - If I delete some of the nodes so the count changes, what parameters do I use?

One thing I forgot to mention, when you scale down, you should always kill the most recent node, aka the one with the highest id (node names are in the form k8s-pool-xxxx-<id>). If you kill a node that isn't the most recent one you will have issue when scaling up again.

But if you do that, scaling up after scaling down is no different: Offset is the current number of nodes (so after scaling down) and count is your desired agent count.


Regarding the autoscaler

waiting until all nodes are full before requesting we spin up a new node is too slow for our use case.

There is an --over-provision flag in the autoscaler which allows you to scale up preemptively. This flag basically tells the autoscaler that whenever it needs to scale up, it should not scale up just to match the current demand, but also add an extra N nodes. If after some time (by default 30 minutes) these extra nodes are not used they will get killed, but it should make scaling up faster. Could tfit your needs ?

wbuchwalter avatar Jul 18 '17 13:07 wbuchwalter

Hi, how about adding new master node?

benlam62 avatar Oct 18 '17 02:10 benlam62

Is that the same process for master-nodes ?

hmarcelodn avatar Nov 03 '17 17:11 hmarcelodn

I know this topic is closed but If anybody lands here this may be helpful ... https://github.com/Azure/acs-engine/blob/487b5688a57c38440a180b2fb239373b6e3ea076/docs/kubernetes/scale.md

ccanizares avatar Dec 07 '17 13:12 ccanizares

@wbuchwalter Hi, I tried , but always got below error. The acs-engine version is 0.13.1 Deployment failed. Correlation ID: 08d74499-6a48-4426-bee8-52a00e4c9184. { "error": { "code": "PropertyChangeNotAllowed", "target": "customData", "message": "Changing property 'customData' is not allowed." } }

birdemily avatar Mar 14 '18 05:03 birdemily

Same error. @wbuchwalter is there any specificity for cluster deployed with custom vnet ?

ralbon avatar Apr 23 '18 10:04 ralbon

Haven't tried this with custom vnet myself, maybe @jackfrancis would know?

wbuchwalter avatar Apr 23 '18 20:04 wbuchwalter