Kubernetes Cluster-autoscaler

gridscale Managed Kubernetes (GSK) is a secure and fully-managed Kubernetes solution. All you need to do is to configure how powerful you wish your cluster to be. We take care of upgrades and OS maintenance.

gridscale managed Kubernetes cluster-autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when the load changes. When the load is high, the cluster-autoscaler increases the size of the cluster, and when the load is low, it decreases the size of the cluster.

Note: The cluster-autoscaler currently supports gridscale managed Kubernetes clusters with version ~> 1.25.

Note 2: When down-scaling, gridscale managed k8s will always remove nodes from the end of the node list. (i.e., scaling down from 8 to 6 nodes, nodes 7 and 8 will be removed, no matter how nodes are utilized at the time. workloads are be rescheduled accordingly.) This is different from default autoscaler behaviour. As such, GSK is implemented in a forked version of autoscaler. This behaviour will change with a future implementation of node pools, which will allow us to integrate into upstream autoscaler.

Note 3: If you deploy your k8s cluster via Terraform, please ignore the change of node_pool.0.node_count in your tf files by adding the following code:

lifecycle {
  ignore_changes = [ node_pool.0.node_count]
}

so that terraform will not overwrite the node count set by the cluster-autoscaler.

cluster-autoscaler deployment

Prerequisites

  1. A gridscale managed Kubernetes cluster.
  2. Create an gridscale API token via panel.
  3. kubectl is installed on your local machine.
  4. kubectl is configured to access your gridscale managed Kubernetes cluster.

Deploy cluster-autoscaler

  1. Download the cluster-autoscaler manifest file from here and save it as cluster-autoscaler-autodiscover.yaml. NOTE: Please note that the flag --daemonset-eviction-for-occupied-nodes=false is added to the command in the manifest file to evict the PVC-attached pods properly. Otherwise, the CSI related pods will be evicted and the PVC-attached pods will be stuck in Terminating state. If you want to use the default behavior, please remove the flag.
  2. If you use namespace gsk-autoscaler in your cluster-autoscaler-autodiscover.yaml, create a new namespace called gsk-autoscaler by running the following command:
$ kubectl create namespace gsk-autoscaler
  1. Insert your base64 encoded gridscale API user and token in the manifest file.
  2. Insert your gridscale kubernetes cluster UUID in environment variable CLUSTER_UUID in the manifest file.
  3. Change environment variable CLUSTER_MAX_NODE_COUNT in the manifest file to the maximum number of nodes you want to scale up to. (Optional) you can also change the minimum number of nodes by changing environment variable CLUSTER_MIN_NODE_COUNT (Default: 1) in the manifest file.
  4. To configure parameters of the cluster-autoscaler, you can add flags to the command in the manifest file. All available flags and their default values can be found here.
  5. Deploy the cluster-autoscaler by running the following command:
$ kubectl apply -f cluster-autoscaler-autodiscover.yaml
  1. You can check the autoscaling activity by reading the configmap cluster-autoscaler-status in namespace kube-system, i.e.:
$ kubectl get configmap cluster-autoscaler-status -n gsk-autoscaler -o yaml

Note: the cluster-autoscaler will be deployed in namespace called gsk-autoscaler.

FAQ

After upgrading my gridscale managed Kubernetes cluster, the cluster-autoscaler is not working anymore. What should I do?

Please make sure that the minor version of the cluster-autoscaler matches the minor version of your gridscale managed Kubernetes cluster. If not, please redeploy the cluster-autoscaler with the correct version.