Cluster Proportional Autoscaler
Cluster Proportional Autoscaler (CPA) is a controller that automatically scales a specified deployment based on the number of nodes in the cluster. It is especially useful when a service needs to be available on every node or should scale proportionally to the overall cluster resources.
Unlike traditional autoscalers, CPA does not rely on load metrics. Instead, it uses proportional formulas that are manually defined.
Modes of Operation Copy link
CPA supports two modes for calculating the number of replicas:
Linear Mode Copy link
In linear mode, the number of replicas is calculated using the following formula:
replicas = max(min, min(max, cores / coresPerReplica, nodes / nodesPerReplica))You can use both parameters (coresPerReplica and nodesPerReplica) or just one. The min and max values set the lower and upper limits for the number of replicas.
Example configuration:
config:
linear:
coresPerReplica: 2
nodesPerReplica: 1
min: 2
max: 20
preventSinglePointFailure: true
includeUnschedulableNodes: true
In this example:
- One pod is created per node
- An additional pod is created for every 2 CPU cores
- Always at least 2 pods, maximum 20
- If there's only one node, 2 pods will be created to prevent a single point of failure
- Unschedulable nodes are also taken into account
Ladder Mode Copy link
In ladder mode, the number of replicas is explicitly defined using a lookup table. This is useful when you need an exact number of pods for specific cluster sizes.
Example configuration:
config:
ladder:
coresToReplicas:
- [ 1, 1 ]
- [ 64, 3 ]
- [ 512, 5 ]
- [ 1024, 7 ]
- [ 2048, 10 ]
nodesToReplicas:
- [ 1, 1 ]
- [ 2, 2 ]
- [ 5, 3 ]
In this example:
- With 1 node → 1 pod
- With 2 nodes → 2 pods
- With 5 or more nodes → 3 pods
- CPU cores are also considered in parallel:
- 64 cores → 3 pods
- 2048 cores → 10 pods
Installation via Control Panel Copy link
To install Cluster Proportional Autoscaler:
- Go to the Kubernetes section and click on the cluster.
- In the Addons tab, click on Cluster Proportional Autoscaler.
- In the installation wizard, you can adjust the configuration by editing the manifest in the Configuration section.
By default, the autoscaler is configured to scale the metrics-server in the kube-system namespace using linear mode, creating one pod per node:
config:
linear:
coresPerReplica: 1
nodesPerReplica: 1
min: 1
max: 100
preventSinglePointFailure: true
includeUnschedulableNodes: true
options:
logToStdErr: true
logLevel: 7
namespace: kube-system
target: deployment/metrics-server
If you want to scale a different service—for example, nginx in the default namespace—change the target and namespace parameters before installing.
To switch scaling modes or parameters, edit the config section. For instance, you can uncomment the ladder parameters and use that mode instead of linear.
Manual Installation Copy link
If you need more flexibility or want to deploy multiple autoscalers for different services, use Helm for installation.
Step 1: Add the Helm chart repository:
helm repo add cluster-proportional-autoscaler https://kubernetes-sigs.github.io/cluster-proportional-autoscalerThis adds an external source from which the autoscaler can be installed.
Step 2: Update chart list:
helm repo updateStep 3: Create a values.yaml file with the following content:
config:
linear:
coresPerReplica: 1
nodesPerReplica: 1
min: 1
max: 100
preventSinglePointFailure: true
includeUnschedulableNodes: true
options:
logToStdErr: true
logLevel: 7
namespace: kube-system
target: deployment/metrics-server
serviceAccount:
create: true
This configuration:
- Uses linear mode, creating one pod per node (
nodesPerReplica: 1) - Limits replicas between 1 and 100
- Enables
preventSinglePointFailure(adds an extra pod if only one node exists) - Includes unschedulable nodes in calculations
- Specifies the target deployment and namespace
- Automatically creates a service account with the required permissions
Step 4: Install the autoscaler with Helm:
helm upgrade --install metrics-autoscaler cluster-proportional-autoscaler/cluster-proportional-autoscaler --values values.yamlStep 5: Verify the pod is running:
kubectl get pods -n kube-systemScaling Multiple Services Copy link
With manual installation, you can run multiple independent autoscaler instances for different services.
To do so:
- Create a separate
values-nginx.yamlfile - Update the
targetandnamespaceparameters for the deployment (e.g.,nginxin thedefaultnamespace) - Install using a different release name:
helm upgrade --install nginx-autoscaler cluster-proportional-autoscaler/cluster-proportional-autoscaler --values values-nginx.yamlThis method allows you to scale any number of services with individual settings.