⎈ k8s knowledge compiler

Vertical Pod Autoscaling [page]deterministic

concepts

In Kubernetes, a _VerticalPodAutoscaler_ automatically updates a workload management [resource](#gloss:api-resource) (such as a [Deployment](#gloss:deployment) or [StatefulSet](#gloss:statefulset)), with the aim of automatically adjusting infrastructure [resource](#gloss:infrastructure-resource) [requests and limits](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits) to match actual usage.

Vertical scaling means that the response to increased resource demand is to assign more resources (for example: memory or CPU) to the [Pods](#gloss:pod) that are already running for the workload. This is also known as _rightsizing_, or sometimes _autopilot_. This is different from horizontal scaling, which for Kubernetes would mean deploying more Pods to distribute the load.

If the resource usage decreases, and the Pod resource requests are above optimal levels, the VerticalPodAutoscaler instructs the workload resource (the Deployment, StatefulSet, or other similar resource) to adjust resource requests back down, preventing resource waste.

The VerticalPodAutoscaler is implemented as a Kubernetes API resource and a [controller](#gloss:controller). The resource determines the behavior of the controller. The vertical pod autoscaling controller, running within the Kubernetes data plane, periodically adjusts the resource requests and limits of its target (for example, a Deployment) based on analysis of historical resource utilization, the amount of resources available in the cluster, and real-time events such as out-of-memory (OOM) conditions.

## API object

The VerticalPodAutoscaler is defined as a [Custom Resource Definition](#gloss:customresourcedefinition) (CRD) in Kubernetes. Unlike HorizontalPodAutoscaler, which is part of the core Kubernetes API, VPA must be installed separately in your cluster.

The current stable API version is `autoscaling.k8s.io/v1`. More details about the VPA installation and API can be found in the [VPA GitHub repository](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler).

## How does a VerticalPodAutoscaler work?

![Vertical Pod Autoscaling architecture](/images/docs/concepts/vpa-architecture.svg) — Figure 1. VerticalPodAutoscaler controls the resource requests and limits of Pods in a Deployment

Kubernetes implements vertical pod autoscaling through multiple cooperating components that run intermittently (it is not a continuous process). The VPA consists of three main components:

* The _recommender_, which analyzes resource usage and provides recommendations. * The _updater_, that Pod resource requests either by evicting Pods or modifying them in place. * And the VPA _admission controller_ webhook, which applies resource recommendations to new or recreated Pods.

Once during each period, the Recommender queries the resource utilization for Pods targeted by each VerticalPodAutoscaler definition. The Recommender finds the target resource defined by the `targetRef`, then selects the pods based on the target resource's `.spec.selector` labels, and obtains the metrics from the resource metrics API to analyze actual CPU and memory consumption.

The Recommender analyzes both current and historical resource usage data (CPU and memory) for each Pod targeted by the VerticalPodAutoscaler. It examines: - Historical consumption patterns over time to identify trends - Peak usage and variance to ensure sufficient headroom - Out-of-memory (OOM) events and other resource-related incidents

Based on this analysis, the Recommender calculates three types of recommendations: - Target recommendation (optimal resources for typical usage) - Lower bound (minimum viable resources) - Upper bound (maximum reasonable resources).

These recommendations are stored in the VerticalPodAutoscaler resource's `.status.recommendation` field.

The _updater_ component monitors the VerticalPodAutoscaler resources and compares current Pod resource requests with the recommendations. …(trimmed)

Sources

concepts/workloads/autoscaling/vertical-pod-autoscale.md · docVertical Pod Autoscaling

Related (21)

references API resourceresource conf=1
references DeploymentDeployment conf=1
references StatefulSetStatefulSet conf=1
references Resource (infrastructure)resource conf=1
references PodPods conf=1
references Controllercontroller conf=1
references Add-onsadd-on conf=1
part_of API Objectdescribes conf=1
part_of How does a VerticalPodAutoscaler work?describes conf=1
part_of Update modesdescribes conf=1
part_of Resource policiesdescribes conf=1
part_of LimitRange resourcesdescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of Off {#updateMode-Off}describes conf=1
part_of Initial {#updateMode-Initial}describes conf=1
part_of Recreate {#updateMode-Recreate}describes conf=1
part_of InPlace {#updateMode-InPlace}describes conf=1
part_of Auto (deprecated) {#updateMode-Auto}describes conf=1
part_of controlledValuesdescribes conf=1
api_for Poddocuments API object conf=1

← all Docs