Cluster Autoscaler

Last updated on: November 30, 2026

Cluster Autoscaler (CA) for UpCloud automatically adds or removes cluster worker nodes depending on current workload. UpCloud's CA cloud provider implementation does this by increasing or decreasing node group(s) size when needed.

Cluster Autoscaler works particularly well along with Kubernetes built-in horizontal pod autoscaler (HPA). In short, HPA scales the number of pods depending on the current workload and when CA notices that cluster resource requirements has changed, it will try to adjust worker node count to meet new needs.

Additional info about the Cluster Autoscaler can be found from the project's README file and from the FAQ .

Deploy Cluster Autoscaler for UpCloud

Currently it is only possible to run CA in the worker nodes, which is not ideal as Cluster Autoscaler is designed to run on Kubernetes control plane node, but our current setup tries to ensure that CA stays always running.

Prerequisites

  • kubectl installed
  • cluster config (kubeconfig) and UUID of the cluster
  • an UpCloud API token whose user has permission to manage Kubernetes clusters through the UpCloud API. To create one, see How to create and use UpCloud API Tokens

Import the API token as a Kubernetes secret:
Replace $UPCLOUD_TOKEN with your API token if it isn't set as an environment variable.

$ kubectl -n kube-system create secret generic upcloud-autoscaler --from-literal=token=$UPCLOUD_TOKEN

Apply RBAC rules, required by the CA

$ kubectl apply -f https://raw.githubusercontent.com/UpCloudLtd/autoscaler/feat/cluster-autoscaler-cloudprovider-upcloud/cluster-autoscaler/cloudprovider/upcloud/examples/rbac.yaml

Download CA setup manifest

$ curl -o cluster-autoscaler.yaml https://raw.githubusercontent.com/UpCloudLtd/autoscaler/feat/cluster-autoscaler-cloudprovider-upcloud/cluster-autoscaler/cloudprovider/upcloud/examples/cluster-autoscaler.yaml

Edit downloaded cluster-autoscaler.yaml file and replace ${UPCLOUD_CLUSTER_ID} with your cluster's UUID.

Apply the CA setup manifest

$ kubectl apply -f cluster-autoscaler.yaml

Check that CA is running

$ kubectl -n kube-system get pods -l app=cluster-autoscaler
NAME                                 READY   STATUS    RESTARTS   AGE
cluster-autoscaler-946f6b9cf-jzjvr   1/1     Running   0          46s

Test autoscaling

There is Nginx deployment example in the UpCloud's Cluster Autoscaler repository, that can be used to test cluster autoscaling.

Before starting check the number of the current worker nodes

$ kubectl get nodes
NAME                 STATUS   ROLES    AGE     VERSION
medium-kdsq9-n957g   Ready    <none>   5m54s   v1.36.4
medium-kdsq9-v4jfr   Ready    <none>   6m10s   v1.36.4

Deploy Nginx test service:

$ kubectl apply -f https://raw.githubusercontent.com/UpCloudLtd/autoscaler/feat/cluster-autoscaler-cloudprovider-upcloud/cluster-autoscaler/cloudprovider/upcloud/examples/testing/deployment.yaml

and check that deployment started normally

$ kubectl -n cluster-autoscale-test get deployments/nginx
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   10/10   10           10          8s

Depending on your worker node plan, start scaling up the service, for example set replicas to 50

$ kubectl -n cluster-autoscale-test scale deployment/nginx --replicas=50
deployment.apps/nginx scaled

Goal here is to exhaust Kubernetes resources so that it cannot start anymore pods to fill deployment requirements. CA should detect this state and start creating new worker nodes as soon as possible.

Watch node list for changes

$ kubectl get nodes -w
NAME                 STATUS   ROLES    AGE     VERSION
medium-kdsq9-n957g   Ready    <none>   16m     v1.36.4
medium-kdsq9-ptznb   Ready    <none>   7m17s   v1.36.4
medium-kdsq9-v4jfr   Ready    <none>   16m     v1.36.4

New nodes appear in the list and change to Ready once they have joined the cluster.

Clean up test service by deleting the namespace

$ kubectl delete namespaces cluster-autoscale-test 
namespace "cluster-autoscale-test" deleted

With the default settings, CA removes a node once it has been unneeded for 10 minutes. After that, the cluster is back to its original nodes:

$ kubectl get nodes
NAME                 STATUS   ROLES    AGE   VERSION
medium-kdsq9-n957g   Ready    <none>   27m   v1.36.4
medium-kdsq9-v4jfr   Ready    <none>   27m   v1.36.4

What's next

Contributed by: Pekka Nurmi

Can't find what you're looking for?

For more help you can contact our awesome 24/7 support team

Contact Support