<p>Could someone please help me understand the relationship between HorizontalPodAutoscaler and the number of nodes / pods. </p>

<p>If the autoscaler adds more pods than a node can handle, will the new pods just go into a 'pending' state or will it automatically trigger a new node / vCPU on say... Google Kubernetes Engine to spin up?</p>

<p>Cheers,
Clement</p>

Clement
<p>An HPA will essentially create a minimum number of pods and will increase to the maximum number of pods according to a defined metric like CPU percentage on the pod. This is just at the Kubernetes level, it won't scale your nodes.</p>

<p>To scale your nodes you need to use a different autoscaler which could be defined according to metrics on your servers. Examples of these are the Amazons Autoscaling Groups (ASGs). There are equivalents in GCP (server pools) and Azure.</p>

<p>So if you don't have your server autoscaler set up correctly or you don't have enough capacity in your cluster you could run into cases where Kubernetes HPA(s) want to scale and don't find enough server capacity. If that happens then you'll have a lot of pods go into "Pending" state.</p>

<p>Keep in mind that Kubernetes also has <a href="https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler" rel="nofollow noreferrer">Vertical Pod Autoscaler</a> and the takes care of autoscaling the resources inside the pods, such as memory and cpu percentage.</p>

<p>This <a href="https://banzaicloud.com/blog/k8s-horizontal-pod-autoscaler/" rel="nofollow noreferrer">link</a> has good information about all the autoscaling methods.</p>

<p>Hope it helps.</p>
