|
| 1 | +# Cluster Autoscaler on Cluster API |
| 2 | + |
| 3 | +The cluster autoscaler on [Cluster API](https://cluster-api.sigs.k8s.io/) uses |
| 4 | +the [cluster-api project](https://github.com/kubernetes-sigs/cluster-api) to |
| 5 | +manage the provisioning and de-provisioning of nodes within a Kubernetes |
| 6 | +cluster. |
| 7 | + |
| 8 | +## Kubernetes Version |
| 9 | + |
| 10 | +The cluster-api provider requires Kubernetes v1.16 or greater to run the |
| 11 | +v1alpha3 version of the API. |
| 12 | + |
| 13 | +## Starting the Autoscaler |
| 14 | + |
| 15 | +To enable the Cluster API provider, you must first specify it in the command |
| 16 | +line arguments to the cluster autoscaler binary. For example: |
| 17 | + |
| 18 | +``` |
| 19 | +cluster-autoscaler --cloud-provider=clusterapi |
| 20 | +``` |
| 21 | + |
| 22 | +Please note, this example only shows the cloud provider options, you will |
| 23 | +most likely need other command line flags. For more information you can invoke |
| 24 | +`cluster-autoscaler --help` to see a full list of options. |
| 25 | + |
| 26 | +## Enabling Autoscaling |
| 27 | + |
| 28 | +To enable the automatic scaling of components in your cluster-api managed |
| 29 | +cloud there are a few annotations you need to provide. These annotations |
| 30 | +must be applied to either [MachineSet](https://cluster-api.sigs.k8s.io/developer/architecture/controllers/machine-set.html) |
| 31 | +or [MachineDeployment](https://cluster-api.sigs.k8s.io/developer/architecture/controllers/machine-deployment.html) |
| 32 | +resources depending on the type of cluster-api mechanism that you are using. |
| 33 | + |
| 34 | +There are two annotations that control how a cluster resource should be scaled: |
| 35 | + |
| 36 | +* `cluster.k8s.io/cluster-api-autoscaler-node-group-min-size` - This specifies |
| 37 | + the minimum number of nodes for the associated resource group. The autoscaler |
| 38 | + will not scale the group below this number. Please note that currently the |
| 39 | + cluster-api provider will not scale down to zero nodes. |
| 40 | + |
| 41 | +* `cluster.k8s.io/cluster-api-autoscaler-node-group-max-size` - This specifies |
| 42 | + the maximum number of nodes for the associated resource group. The autoscaler |
| 43 | + will not scale the group above this number. |
| 44 | + |
| 45 | +The autoscaler will monitor any `MachineSet` or `MachineDeployment` containing |
| 46 | +both of these annotations. |
| 47 | + |
| 48 | +## Specifying a Custom Resource Group |
| 49 | + |
| 50 | +By default all Kubernetes resources consumed by the Cluster API provider will |
| 51 | +use the group `cluster.x-k8s.io`, with a dynamically acquired version. In |
| 52 | +some situations, such as testing or prototyping, you may wish to change this |
| 53 | +group variable. For these situations you may use the environment variable |
| 54 | +`CAPI_GROUP` to change the group that the provider will use. |
0 commit comments