06. How to configure HI GIO Kunernetes cluster autoscale
Last updated
Last updated
Step-by-step guide on how to configure HI GIO Kubernetes cluster autoscale
Install tanzu-cli
Create cluster-autoscaler deployment from tanzu package using tanzu-cli
Enable cluster autoscale for your cluster
Test cluster autoscale
Delete cluster-autoscaler deployment and clean up test resource
Pre-requisites:
Ubuntu bastion can connect to your Kubernetes cluster
Permission for access to your Kubernetes cluster
Step 1: Install tanzu-cli
To install tanzu-cli in other environments, please refer to the documentation below:
(Optional) If you want to configure tanzu completion, please run the command below and follow the instructions output
tanzu completion --help
Step 2: Create cluster-autoscaler deployment from tanzu package using tanzu-cli
Switched to your Kubernetes context
List available cluster-autoscaler in tanzu package and note the version name
Create kubeconfig secret name cluster-autoscaler-mgmt-config-secret
in cluster kube-system
namespace
Please do not change the secret name (cluster-autoscaler-mgmt-config-secret) and namespace (kube-system)
Create cluster-autoscaler-values.yaml
file
Required values:
clusterName
: your cluster name
clusterNamespace
: your cluster namespace
Install cluster-autoscaler
The cluster-autoscaler will deploy into the kube-system
namespace.
Run the command below to verify cluster-autoscaler deployment:
kubectl get deployments.apps -n kube-system cluster-autoscaler
Configure the minimum and maximum number of nodes in your cluster
Get machinedeployments
name and namespace
Set cluster-api-autoscaler-node-group-min-size
and cluster-api-autoscaler-node-group-max-size
Enable cluster autoscale for your cluster
Because this step requires provider permission to perform, please notify the cloud provider to perform this step.
Get the current number of nodes
kubectl get nodes
There is currently only one worker node.
Create test-autoscale.yaml
file
Apply test-autoscale.yaml
file to deploy 2 replicas of nginx pod in the default namespace (it will trigger to create a new worker node)
Get nginx deployment
You can see there is a new nginx pod with a status of Pending and the events shown FailedScheduling
and TriggeredScaleUp
:
Waiting for a new node to be provisioned, then you can see a new worker node has been provisioned and new nginx pod status is running
Clean up test resource
After deleting the nginx deployment test. The cluster waits a few minutes to delete the unneeded node (please see scaleDownUnneededTime
value in cluster-autoscaler-values.yaml
file)
Delete cluster-autoscaler deployment (Optional)
In case you don't want your cluster to auto-scale anymore. You can delete cluster-autoscaler deployment using tanzu-cli: