How to run a node auto-scaler script without using a cron-job in Kubernetes ( PKS)

5/5/2020

I have a node auto-scaling shell script which takes care of auto-scaling the worker nodes based on the average CPU/memory of all the nodes in the Kubernetes cluster.

I currently run this script from a bastion where I have the pks, kubectl cli installed and have also configured a cron-job to run it every 5 minutes.

Is there any other way to do this in Kubernetes ( PKS on AWS) ?

Or may be without using a cron-job, as the auto-scaling becomes completely dependent on the cron.

Thanks

-- Dilip
amazon-web-services
bash
cron
kubernetes
linux

2 Answers

5/5/2020

If you mean EKS on AWS than there are different auto-scaling options

-- Anton Matsiuk
Source: StackOverflow

5/5/2020

TL;DR: Autoscale with k8s

To setup autoscaling on k8s use:

kubectl autoscale -f <controller>.yaml --min=3 --max=5

Note: PKS over AWS is an overkill

You mentioned PKS

Using PKS over AWS infrastructure seems as overkill. Just because AWS has EKS

To work with AWS cloud, VMware recommends VMC on AWS

PKS autoscale

If you do insist to use PKS over AWS, you may try this sample repo: pks-autoscale

Author of the repo also has great PKS quickstart guide for aws

Scaling on AWS

EKS autoscaling

AWS EKS supports three-dimensional scaling:

  • Cluster Autoscaler — The Kubernetes Cluster Autoscaler automatically adjusts the number of nodes in your cluster when pods fail to launch due to lack of resources or when nodes in the cluster are underutilized and their pods can be rescheduled on to other nodes in the cluster.
  • Horizontal Pod Autoscaler — The Kubernetes Horizontal Pod Autoscaler automatically scales the number of pods in a deployment, replication controller, or replica set based on that resource's CPU utilization.
  • Vertical Pod Autoscaler — The Kubernetes Vertical Pod Autoscaler automatically adjusts the CPU and memory reservations for your pods to help "right size" your applications. This can help you to better use your cluster resources and free up CPU and memory for other pods.

EC2 Auto Scaling

If you decided to build your own k8s cluster using PKS, you may use EC2 auto scaling - just create an Auto Scaling Group.

Using aws-cli:

aws autoscaling create-auto-scaling-group --auto-scaling-group-name <my-asg> --launch-configuration-name <my-launch-config> --min-size 3 --max-size 5 --vpc-zone-identifier "<zones>

EC2 predictive scaling

Recently, AWS introduced predictive scaling for EC2:

... predictive scaling. Using data collected from your actual EC2 usage and further informed by billions of data points drawn from our own observations, we use well-trained Machine Learning models to predict your expected traffic (and EC2 usage) including daily and weekly patterns.

-- Yasen
Source: StackOverflow