Kubernetes autoscaler: change min replica on specific day

8/8/2018

I'm running a Kubernetes cluster (GCP) with 10 deployments. Each deployment is configured to auto scale on stress.

From my website statistics, I found that Monday is the day with the most load. I want to define Kubernetes deployment to have more min-replicas on this day.

Is this possible?

I read somewhere that I can run a cronjob script before and after this day and change the minimum number of machines. Is that the current way to do it? Is this safe? what if the cronjob wasn't fired? If this is the current way, please link me for some instruction how to do it.

Thanks!

-- No1Lives4Ever
google-kubernetes-engine
kubernetes

1 Answer

8/8/2018

You seem to be talking of two things here.

  1. Pod autoscaling (Add more pods when load on existing pods increases) : HPA will help with this. If your workloads show a spike in CPU or memory and can handle horizontal scaling, then HPA would work fine. Example : https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/

  2. Now HPA can increase pods only if the cluster has enough nodes to schedule them. If it is desired to have more nodes with more traffic and reduce them when traffic is low, a cluster autoscaler could be a good option. https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler

Ofcourse, the scaling of nodes is not instantaneous as the autoscaler watches for pods which are in Pending state due to resource level constraints. After this, it requests additional nodes from the cloud provider and once these nodes join the cluster, workloads get scheduled.

-- Harshal Shah
Source: StackOverflow