Cluster Autoscaler is a component that automatically adjusts the size of a Kubernetes Cluster so that all pods have a place to run and there are no unneeded nodes.
This is the multi-page printable view of this section. Click here to print.
Cluster Autoscaler Configuration
- 1: Cluster Autoscaler
- 2: v9.21.0
- 3: v9.37.0
- 4: v9.43.0
1 - Cluster Autoscaler
If you have not already done so, make sure your EKS Anywhere cluster meets the package prerequisites.
Refer to the troubleshooting guide in the event of a problem.
Enable Cluster Autoscaling
-
Ensure you have configured at least one worker node group in your cluster specification to enable autoscaling as outlined in Autoscaling configuration. Cluster Autoscaler only works on node groups with an
autoscalingConfiguration
set:apiVersion: anywhere.eks.amazonaws.com/v1alpha1 kind: Cluster metadata: name: <cluster-name> spec: ... workerNodeGroupConfigurations: - autoscalingConfiguration: minCount: 1 maxCount: 5 machineGroupRef: kind: VSphereMachineConfig name: <worker-machine-config-name> count: 1 name: md-0
-
Generate the package configuration.
eksctl anywhere generate package cluster-autoscaler --cluster <cluster-name> > cluster-autoscaler.yaml
-
Add the desired configuration to
cluster-autoscaler.yaml
. See configuration options for all configuration options and their default values. See below for an example package file configuring a Cluster Autoscaler package.apiVersion: packages.eks.amazonaws.com/v1alpha1 kind: Package metadata: name: cluster-autoscaler-<cluster-name> namespace: eksa-packages-<cluster-name> spec: packageName: cluster-autoscaler targetNamespace: default config: |- cloudProvider: "clusterapi" autoDiscovery: clusterName: "<cluster-name>"
-
Install Cluster Autoscaler
eksctl anywhere create packages -f cluster-autoscaler.yaml
-
Validate the installation
eksctl anywhere get packages --cluster <cluster-name>
NAMESPACE NAME PACKAGE AGE STATE CURRENTVERSION TARGETVERSION DETAIL eksa-packages-mgmt-v-vmc cluster-autoscaler cluster-autoscaler 18h installed 9.21.0-1.21-147e2a701f6ab625452fe311d5c94a167270f365 9.21.0-1.21-147e2a701f6ab625452fe311d5c94a167270f365 (latest)
To verify that autoscaling works, apply the deployment below. You must continue scaling pods until the deployment has pods in a pending state. This is when Cluster Autoscaler will begin to autoscale your machine deployment. This process may take a few minutes.
kubectl apply -f https://raw.githubusercontent.com/aws/eks-anywhere/d8575bbd2a85a6c6bbcb1a54868cf7790df56a63/test/framework/testdata/hpa_busybox.yaml kubectl scale deployment hpa-busybox-test --replicas 100
Update
To update package configuration, update the cluster-autoscaler.yaml
file and run the following command:
eksctl anywhere apply package -f cluster-autoscaler.yaml
Update Worker Node Group Autoscaling Configuration
It is possible to change the autoscaling configuration of a worker node group by updating the autoscalingConfiguration
in your cluster specification and running a cluster upgrade.
Upgrade
The Cluster Autoscaler can be upgraded by PackageController’s activeBundle
field to a newer version.
The curated packages bundle contains the SHAs of the images and helm charts associated with a particular package. When a new version is activated, the Package Controller will reconcile all active packages to their newest versions as defined in the bundle.
The Curated Packages Controller automatically polls the bundle repository for new bundle resources.
The curated packages controller automatically polls for the latest bundle, but requires the activeBundle field on the PackageController resource to be updated before a new bundle will take effect and upgrade the resources.
Uninstall
To uninstall Cluster Autoscaler, delete the package
eksctl anywhere delete package --cluster <cluster-name> cluster-autoscaler
2 - v9.21.0
Configuring Cluster Autoscaler in EKS Anywhere package spec
Parameter | Description | Default |
---|---|---|
General | ||
cloudProvider | Cluster Autoscaler cloud provider. This should always be clusterapi. Example: cloudProvider: “clusterapi” |
“clusterapi” |
autoDiscovery.clusterName | Name of the kubernetes cluster this autoscaler package should autoscale. Example: autoDiscovery.clusterName: “mgmt-cluster” |
false |
clusterAPIMode | Where Cluster Autoscaler should look for a kubeconfig to communicate with the cluster it will manage. See https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters Example: clusterAPIMode: “incluster-kubeconfig” |
“incluster-incluster” |
clusterAPICloudConfigPath | Path to kubeconfig for connecting to Cluster API Management Cluster, only used if clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig Example: clusterAPICloudConfigPath: “/etc/kubernetes/value” |
“/etc/kubernetes/mgmt-kubeconfig” |
extraVolumeSecrets | Additional volumes to mount from Secrets. Example: extraVolumeSecrets: {} |
{} |
3 - v9.37.0
Configuring Cluster Autoscaler in EKS Anywhere package spec
Parameter | Description | Default |
---|---|---|
General | ||
cloudProvider | Cluster Autoscaler cloud provider. This should always be clusterapi. Example: cloudProvider: “clusterapi” |
“clusterapi” |
autoDiscovery.clusterName | Name of the kubernetes cluster this autoscaler package should autoscale. Example: autoDiscovery.clusterName: “mgmt-cluster” |
false |
clusterAPIMode | Where Cluster Autoscaler should look for a kubeconfig to communicate with the cluster it will manage. See https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters Example: clusterAPIMode: “incluster-kubeconfig” |
“incluster-incluster” |
clusterAPICloudConfigPath | Path to kubeconfig for connecting to Cluster API Management Cluster, only used if clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig Example: clusterAPICloudConfigPath: “/etc/kubernetes/value” |
“/etc/kubernetes/mgmt-kubeconfig” |
extraVolumeSecrets | Additional volumes to mount from Secrets. Example: extraVolumeSecrets: {} |
{} |
4 - v9.43.0
Configuring Cluster Autoscaler in EKS Anywhere package spec
Parameter | Description | Default |
---|---|---|
General | ||
cloudProvider | Cluster Autoscaler cloud provider. This should always be clusterapi. Example: cloudProvider: “clusterapi” |
“clusterapi” |
autoDiscovery.clusterName | Name of the kubernetes cluster this autoscaler package should autoscale. Example: autoDiscovery.clusterName: “mgmt-cluster” |
false |
clusterAPIMode | Where Cluster Autoscaler should look for a kubeconfig to communicate with the cluster it will manage. See https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters Example: clusterAPIMode: “incluster-kubeconfig” |
“incluster-incluster” |
clusterAPICloudConfigPath | Path to kubeconfig for connecting to Cluster API Management Cluster, only used if clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig Example: clusterAPICloudConfigPath: “/etc/kubernetes/value” |
“/etc/kubernetes/mgmt-kubeconfig” |
extraVolumeSecrets | Additional volumes to mount from Secrets. Example: extraVolumeSecrets: {} |
{} |