Menu

HPA does not keep the replicas you set with kubectl scale
📰

HPA does not keep the replicas you set with kubectl scale

DEV Community: kubernetes·Kazu·2 days ago
#oOi47TbW
#devtokubernetes#devto#dev#count#scale
Reading 0:00
15s threshold

Sometimes you want more Pods even though CPU usage is low: when the workers in each Pod are all tied up waiting on a downstream response, or when you want capacity in place before an event. In those cases, people sometimes raise replicas with kubectl scale , even on a Deployment that has an HPA (HorizontalPodAutoscaler). HPA is a controller that decides the number of Pods from metrics such as CPU usage and rewrites the Deployment's replicas.

Right after the scale-up, READY in kubectl get deploy matches the new count. HPA does not revert it right away either, so the count looks like it will hold.

A few minutes later, it is back to the original count. No errors or warnings appear. If HPA reverted it, it is not clear why it took a few minutes to do so.

I reproduced this state and checked whether HPA was really what reverted it, and why the revert happens a few minutes later.

Reproduction

I reproduced the state above on a Kubernetes v1.37.0 cluster created with kind.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.