Scheduled scaling for PODs in Kubernetes

12/27/2019

I have a scaled deployment with predictable load change depends on time. How can I make my deployment prepared to the load (for example, I want to double pods number every evening from 16:00 to 23:00). Does Kubernetes provides such tool?

I know Kubernetes pods are scaling with Horizontal Pod Autoscaler, which scales the number of pods based on CPU utilisation or custom metric. But it is reactive approach, I'm looking for proactive.

-- Dmytro Patserkovskyi
autoscaling
kubernetes

2 Answers

12/27/2019

A quick google search would direct you here: https://github.com/kubernetes/kubernetes/issues/49931

In essence the best solution as of now, is to either run a sidecar container for your pod's main container, which could use the kubernetes api to scale itself up based on a time period with a simple bash script, or write a CRD yourself that reacts to time based events (it is 6pm), something like this one:

https://github.com/amelbakry/kube-schedule-scaler

which watches annotations with cron-like specs on deployments and reacts accordingly.

-- iomv
Source: StackOverflow

1/24/2020

Horizontal Pod Autoscaler of Kubernetes is not a re-active approach, but in fact it is a proactive scaling approach. Let I explain its algorithm using its default setting:

  • The cool time is 5 minutes
  • Resource utilization tracing for every 15 seconds

It means that the system traces resource utilization (depend on what metrics the end-users set, e.g., CPU, storage...etc.) for every 15 seconds. Until every 5 minutes of cooling down (no scaling actions), the controller will calculate the resource utilization in the past 5 minutes (which uses the historical data traces in every 15 seconds above). Then it estimates number of resource (i.e., number of replicas) requires for the next 5-min time window by the equation:

desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]

Other pro-active auto-scaler also works in the similar manner. Different points is that they may apply different techniques (queue theory, machine learning, or time series model) to estimate desiredReplicas as what done in the above equation.

-- Erik Ng
Source: StackOverflow