<p>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.</p>

<p>There is a <a href="https://stackoverflow.com/questions/57375952/kubernetes-horizontal-pod-autoscaling-initial-delay">question</a> which asks just that, and the answer mentions some relevant flags <code>--horizontal-pod-autoscaler-initial-readiness-delay</code> and <code>--horizontal-pod-autoscaler-cpu-initialization-period</code>. But, after reading the <a href="https://v1-14.docs.kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">Kubernetes documentation</a> and finding some Kubernetes' <a href="https://github.com/kubernetes/website/issues/12657" rel="nofollow noreferrer">Github issue</a>, I still don't quite understand the exact effect from the flags and how to apply them at all: <code>kubectl autoscale</code> doesn't seem to accept them in any form.</p>

<p><a href="https://horizontal-pod-autoscaler.readthedocs.io/en/latest/user-guide/initial-readiness-delay/" rel="nofollow noreferrer">This 3rd-party documentation</a> demonstrates how to specify these values in yaml but it uses some custom API version and their configuration doesn't work for <code>autoscaling/v2beta2</code>.</p>

<p>How these flags are supposed to be put to use?</p>

kazarey
<p>You need to set these flags in kube controller manager which is a control plane component of kubernetes</p>

<pre><code>--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.
</code></pre>

<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/</a></p>
