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 example package files configuring a Cluster Autoscaler package.For Management Cluster Autoscaling:
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>"
For Workload Cluster Autoscaling (deployed from Management Cluster):
apiVersion: packages.eks.amazonaws.com/v1alpha1 kind: Package metadata: name: cluster-autoscaler-<workload-cluster-name> namespace: eksa-packages-<management-cluster-name> spec: packageName: cluster-autoscaler targetNamespace: eksa-system config: |- cloudProvider: "clusterapi" clusterAPIMode: "kubeconfig-incluster" clusterAPIKubeconfigSecret: "<workload-cluster-name>-kubeconfig" autoDiscovery: clusterName: "<workload-cluster-name>"
Configuration Fields for Workload Cluster Autoscaling:
clusterAPIMode
: Set to"kubeconfig-incluster"
to enable workload cluster autoscaling from the management clusterclusterAPIKubeconfigSecret
: Name of the Kubernetes secret containing the kubeconfig for the workload cluster. EKS Anywhere automatically creates this secret in the management cluster with the naming pattern<workload-cluster-name>-kubeconfig
targetNamespace
: Should be set toeksa-system
for workload cluster autoscalingautoDiscovery.clusterName
: Must match the name of the workload cluster to be autoscaled
Note: The kubeconfig secret for workload clusters is automatically created by EKS Anywhere in the management cluster when a workload cluster is provisioned. This secret provides the necessary credentials for the autoscaler running in the management cluster to manage the workload cluster’s nodes.
-
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