Kubernetes: how autoscaling initial readiness is specified?

4/10/2020

My deployment in Kubernetes takes a couple of minutes to initialize, and it has an increased CPU usage during that period. I need a way to wait and disregard CPU metrics from the initialization period for the horizontal autoscaling metrics.

There is a question which asks just that, and the answer mentions some relevant flags --horizontal-pod-autoscaler-initial-readiness-delay and --horizontal-pod-autoscaler-cpu-initialization-period. But, after reading the Kubernetes documentation and finding some Kubernetes' Github issue, I still don't quite understand the exact effect from the flags and how to apply them at all: kubectl autoscale doesn't seem to accept them in any form.

This 3rd-party documentation demonstrates how to specify these values in yaml but it uses some custom API version and their configuration doesn't work for autoscaling/v2beta2.

How these flags are supposed to be put to use?

-- kazarey
kubernetes

1 Answer

4/10/2020

You need to set these flags in kube controller manager which is a control plane component of kubernetes

--horizontal-pod-autoscaler-initial-readiness-delay duration     Default: 30s
The period after pod start during which readiness changes will be treated as initial readiness.

--horizontal-pod-autoscaler-cpu-initialization-period duration     Default: 5m0s
The period after pod start when CPU samples might be skipped.

https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/

-- Arghya Sadhu
Source: StackOverflow