Horizontal Pod Autoscaler
API versions
v2beta1 vs v2beta2
Kubernetes
cloud computing

Difference between API versions v2beta1 and v2beta2 in Horizontal Pod Autoscaler?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The practical answer is that autoscaling/v2beta2 was the more complete successor to autoscaling/v2beta1, especially for scaling behavior controls, and both were transitional APIs on the way to stable autoscaling/v2. In current Kubernetes, you generally should not choose either beta version for new manifests if stable autoscaling/v2 is available in your cluster.

The Main Functional Difference

The biggest difference users noticed was the behavior field in v2beta2. That field lets you control how aggressively the HPA scales up or down, including stabilization windows and scaling policies.

A v2beta2 example looks like this:

yaml
1apiVersion: autoscaling/v2beta2
2kind: HorizontalPodAutoscaler
3metadata:
4  name: api-hpa
5spec:
6  scaleTargetRef:
7    apiVersion: apps/v1
8    kind: Deployment
9    name: api
10  minReplicas: 2
11  maxReplicas: 10
12  metrics:
13    - type: Resource
14      resource:
15        name: cpu
16        target:
17          type: Utilization
18          averageUtilization: 70
19  behavior:
20    scaleUp:
21      stabilizationWindowSeconds: 0
22      policies:
23        - type: Percent
24          value: 100
25          periodSeconds: 60
26    scaleDown:
27      stabilizationWindowSeconds: 300
28      policies:
29        - type: Pods
30          value: 1
31          periodSeconds: 60

That explicit behavior tuning was the main reason many teams moved from v2beta1 to v2beta2 before stable v2 became the preferred destination.

What Stayed Similar

Both versions were part of the more capable HPA API line beyond the old autoscaling/v1 CPU-only style. Both supported richer metric configurations than the original stable HPA API.

In both cases, the object model revolves around:

  • 'scaleTargetRef'
  • 'minReplicas and maxReplicas'
  • a list of metrics

So if you migrated between them, the manifest did not become conceptually different. The main shift was toward the newer target specification style and the added scaling behavior controls.

Metric Target Structure Evolved

One source of migration confusion is that newer HPA API versions use a nested target structure inside each metric block. That structure is also what stable autoscaling/v2 uses.

A modern metric block looks like this:

yaml
1metrics:
2  - type: Resource
3    resource:
4      name: cpu
5      target:
6        type: Utilization
7        averageUtilization: 70

This is easier to reason about than older field layouts scattered across different metric types. In practice, v2beta2 is closer to stable autoscaling/v2 and therefore a cleaner migration step if you are coming from older manifests.

Why v2beta2 Became The Better Migration Target

Historically, v2beta2 was the last beta form before stable autoscaling/v2 took over. That matters because it usually means:

  • fewer surprises when moving to stable v2
  • access to scaling behavior controls
  • a manifest shape closer to the current API

If you are maintaining old YAML, the better question is usually not "should I use v2beta1 or v2beta2?" It is "can I move straight to autoscaling/v2 on this cluster version?"

Deprecation Matters More Than The Beta Comparison

For current Kubernetes maintenance work, the deprecation timeline is operationally more important than the old feature comparison.

According to Kubernetes deprecation guidance:

  • 'autoscaling/v2beta1 was removed in Kubernetes 1.25'
  • 'autoscaling/v2beta2 was removed in Kubernetes 1.26'

That means a manifest still using either beta API will fail once the cluster is upgraded past the removal point.

So even if v2beta2 was functionally better than v2beta1, the durable answer today is to migrate to autoscaling/v2.

A Stable autoscaling/v2 Example

This is what new work should usually target:

yaml
1apiVersion: autoscaling/v2
2kind: HorizontalPodAutoscaler
3metadata:
4  name: api-hpa
5spec:
6  scaleTargetRef:
7    apiVersion: apps/v1
8    kind: Deployment
9    name: api
10  minReplicas: 2
11  maxReplicas: 10
12  metrics:
13    - type: Resource
14      resource:
15        name: cpu
16        target:
17          type: Utilization
18          averageUtilization: 70

If you also need behavior tuning, stable v2 supports that model too.

Migration Advice In Practice

If you encounter v2beta1 in an existing codebase:

  1. check the cluster version first
  2. convert metric targets to the newer nested target shape if needed
  3. move directly to autoscaling/v2 unless a very old cluster blocks that
  4. add behavior only if you actually need controlled scale-up or scale-down policies

That sequence reduces needless intermediate migrations.

Common Pitfalls

  • Treating the old beta-version choice as if it still matters more than stable autoscaling/v2.
  • Upgrading the cluster and forgetting that v2beta1 and v2beta2 were removed in later releases.
  • Copying old HPA metric fields without converting them to the newer target structure.
  • Assuming behavior exists in the older API just because it exists in later examples.
  • Migrating YAML mechanically without checking how the autoscaler should actually behave.

Summary

  • 'v2beta2 was the more complete successor to v2beta1, especially because it added behavior controls.'
  • Both beta APIs were transitional steps toward stable autoscaling/v2.
  • 'v2beta1 was removed in Kubernetes 1.25, and v2beta2 was removed in 1.26.'
  • For current clusters, new manifests should usually use autoscaling/v2.
  • When migrating, focus on metric target structure and scaling behavior, not only the API version string.

Course illustration
Course illustration

All Rights Reserved.