Search code examples
kubernetesautoscaling

Scheduled scaling for PODs in Kubernetes


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.


Solution

  • 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.