7

Is there a configuration in Kubernetes horizontal pod autoscaling to specify a minimum delay for a pod to be running or created before scaling up/down?

For example with something like:

# I am looking for a flag like this
--horizontal-pod-autoscale-initial-upscale-delay=5m0s

# Similar to these existing flags
--horizontal-pod-autoscaler-downscale-delay=2m0s
--horizontal-pod-autoscaler-upscale-delay=2m0s

Having as a result:

  • Wait for 5 min before any upscale occur
  • After 5 min, perform a downscale at most every 2 min

I have a situation where a Pod consumes lots of resources on start-up for bootstrapping (which is expected) but I don't want it scaled during this time, and once bootstrap is done it may be eligible for autoscaling.

Pierre B.
  • 11,612
  • 1
  • 37
  • 58

1 Answers1

7

This flag actually exists: --horizontal-pod-autoscaler-cpu-initialization-period In addition you need to consider the readiness delay: --horizontal-pod-autoscaler-initial-readiness-delay and the metric loop time, --horizontal-pod-autoscaler-sync-period to calculate the total (max/min/average) delay.

See https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/

Thomas
  • 11,272
  • 2
  • 24
  • 40
  • 1
    Thanks, I missed that one. Formulation is quite confusing though. Issue https://github.com/kubernetes/website/issues/12657 is pointing at that – Pierre B. Aug 06 '19 at 15:00
  • 11
    @Thomas How to define it in `yaml`? – RNK Oct 31 '19 at 21:50
  • 1
    In addition to the comment from @RonakPatel, do you know where the flags should be provided in CLI? `kubectl autoscale` doesn't seem to accept them. – kazarey Apr 10 '20 at 04:27
  • These flags are applied globally to the cluster and cannot be configured per HPA object. If you're using a hosted Kubernetes solution, they are most likely configured by the provider. – konryd Sep 30 '20 at 12:20
  • Sadly enough neither of those two parameters (horizontal-pod-autoscaler-cpu-initialization-period, horizontal-pod-autoscaler-initial-readiness-delay) are available in OpenShift 3.11 – pvm14 Oct 19 '20 at 16:14
  • If you are using CPA-HPA instead of standard HPA, the equivalent command as YAML for initial readiness is `initialReadinessDelay` - https://horizontal-pod-autoscaler.readthedocs.io/en/latest/user-guide/initial-readiness-delay/ But, again, this is not for standard HPA. CPA-HPA is almost a drop-in replacement for HPA. – Peter H. Boling Feb 26 '22 at 20:56