<p>I have deployed an app using Kubernetes to a Google Cloud Container Engine Cluster.</p>

<p>I got into autoscaling, and I found the following options:</p>

<p><strong>Kubernetes Horizontal Pod Autoscaling (HPA)</strong></p>

<p>As <a href="https://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/walkthrough/" rel="nofollow noreferrer">explained here</a>, Kubernetes offers the HPA on deployments. As per the <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">docs</a>:</p>

<blockquote>
  <p>Horizontal Pod Autoscaling automatically scales the number of pods in a replication controller, deployment or replica set based on observed CPU utilization</p>
</blockquote>

<p><strong>Google Cloud Container Cluster</strong></p>

<p>Now I have a Google Cloud Container Cluster using 3 instances, with autoscaling enabled. As per the <a href="https://cloud.google.com/container-engine/docs/cluster-autoscaler" rel="nofollow noreferrer">docs</a>:</p>

<blockquote>
  <p>Cluster Autoscaler enables users to automatically resize clusters so that all scheduled pods have a place to run.</p>
</blockquote>

<p>This means I have two places to define my autoscaling. Hence my questions: </p>

<ul>
<li>Is a Pod the same as VM instance inside my cluster, or can multiple Pod's run inside a single VM instance?</li>
<li>Are these two parameters doing the same (aka creating/removing VM instances inside my cluster). If not, what is their behaviour compared to one another?</li>
<li>What happens if e.g. I have a number of pods between <code>3</code> and <code>10</code> and a cluster with number of instances between <code>1</code> and <code>3</code> and autoscaling kicks in. When and how would both scale?</li>
</ul>

<p>Many thanks!</p>

<blockquote>
  <p>Is a Pod the same as VM instance inside my cluster, or can multiple
  Pod's run inside a single VM instance?</p>
</blockquote>

<p>Multiple Pods can run the same instance (called node in kuberenetes). You can define maximum resources to consume for a POD in the deployment yaml. See the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/limit-range/" rel="nofollow noreferrer">docs</a>. This is an important prerequisite for autoscaling.</p>

<blockquote>
  <p>Are these two parameters doing the same (aka creating/removing VM
  instances inside my cluster). If not, what is their behaviour compared
  to one another?</p>
</blockquote>

<p>Kubernetes autoscaler will schedule additional PODs in your existing nodes. Google autoscaler will add worker nodes (new instances) to your cluster. Google autoscaler looks at queued up PODs that cannot be scheduled because there is no space in your cluster and when it finds those will add nodes.</p>

<blockquote>
  <p>What happens if e.g. I have a number of pods between 3 and 10 and a
  cluster with number of instances between 1 and 3 and autoscaling kicks
  in. When and how would both scale?</p>
</blockquote>

<p>By the maximum resource usage you define for your pods google autoscaler will estimate how many new nodes are required to run all queued up, scheduled pods.</p>

<p>Also read this <a href="https://community.sdl.com/solutions/content-management/tridion/tridion-developer/b/feed/posts/autoscaling-your-kubernetes-cluster-on-aws" rel="nofollow noreferrer">article</a>.</p>
