<p>The Kubernetes Horizontal Pod Autoscaler walkthrough in <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/" rel="noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/</a> explains that we can perform autoscaling on custom metrics. What I didn't understand is when to use the two API versions: v2beta1 and v2beta2. If anybody can explain, I would really appreciate it.</p>

<p>Thanks in advance.</p>

Ajay Maity
<p>The first metrics <strong>autoscaling/V2beta1</strong> doesn't allow you to scale your pods based on custom metrics. That only allows you to scale your application based on <code>CPU</code> and <code>memory</code> utilization of your application</p>

<p>The second metrics <strong>autoscaling/V2beta2</strong> allows users to autoscale based on custom metrics. It allow autoscaling based on metrics coming from outside of Kubernetes. A new External metric source is added in this api.</p>

<pre><code>metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
</code></pre>

<p>It will identify a specific metric to autoscale on based on metric name and a label selector. Those metrics can come from anywhere like a stackdriver or prometheus monitoring application and based on some query from prometheus you want to scale your application.</p>

<p>It would always better to use <code>V2beta2</code> api because it can do scaling on CPU and memory as well as on custom metrics, while V2beta1 API can scale only on internal metrics.</p>

<p>The snippet I mentioned in answer denotes how you can specify the target CPU utilisation in <code>V2beta2</code> API</p>
