⎈ k8s knowledge compiler

Autoscaling Workloads [page]deterministic

With autoscaling, you can automatically update your workloads in one way or another. This allows your cluster to react to changes in resource demand more elastically and efficiently.

concepts

In Kubernetes, you can _scale_ a workload depending on the current demand of resources. This allows your cluster to react to changes in resource demand more elastically and efficiently.

When you scale a workload, you can either increase or decrease the number of replicas managed by the workload, or adjust the resources available to the replicas in-place.

The first approach is referred to as _horizontal scaling_, while the second is referred to as _vertical scaling_.

There are manual and automatic ways to scale your workloads, depending on your use case.

## Scaling workloads manually

Kubernetes supports _manual scaling_ of workloads. Horizontal scaling can be done using the `kubectl` CLI. For vertical scaling, you need to _patch_ the resource definition of your workload.

See below for examples of both strategies.

  • Horizontal scaling: [Running multiple instances of your app](/docs/tutorials/kubernetes-basics/scale/scale-intro/)
  • Vertical scaling: [Resizing CPU and memory resources assigned to containers](/docs/tasks/configure-pod-container/resize-container-resources)

## Scaling workloads automatically

Kubernetes also supports _automatic scaling_ of workloads, which is the focus of this page.

The concept of _Autoscaling_ in Kubernetes refers to the ability to automatically update an object that manages a set of Pods (for example a [Deployment](#gloss:deployment)).

### Scaling workloads horizontally

In Kubernetes, you can automatically scale a workload horizontally using a [HorizontalPodAutoscaler](/docs/concepts/workloads/autoscaling/horizontal-pod-autoscale/) (HPA).

It is implemented as a Kubernetes API resource and a [controller](#gloss:controller) and periodically adjusts the number of [replicas](#gloss:replica) in a workload to match observed resource utilization such as CPU or memory usage.

There is a [walkthrough tutorial](/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough) of configuring a HorizontalPodAutoscaler for a Deployment.

### Scaling workloads vertically

You can automatically scale a workload vertically using a [VerticalPodAutoscaler](/docs/concepts/workloads/autoscaling/vertical-pod-autoscale/) (VPA). Unlike the HPA, the VPA doesn't come with Kubernetes by default, but is a an add-on that you or a cluster administrator may need to deploy before you can use it.

Once installed, it allows you to create [CustomResourceDefinitions](#gloss:customresourcedefinition) (CRDs) for your workloads which define _how_ and _when_ to scale the resources of the managed replicas.

> Note: You will need to have the [Metrics Server](https://github.com/kubernetes-sigs/metrics-server) installed to your cluster for the VPA to work.

#### In-place pod vertical scaling

As of Kubernetes , VPA does not support resizing pods in-place, but this integration is being worked on. For manually resizing pods in-place, see [Resize Container Resources In-Place](/docs/tasks/configure-pod-container/resize-container-resources/).

### Autoscaling based on cluster size

For workloads that need to be scaled based on the size of the cluster (for example `cluster-dns` or other system components), you can use the [_Cluster Proportional Autoscaler_](https://github.com/kubernetes-sigs/cluster-proportional-autoscaler). Just like the VPA, it is not part of the Kubernetes core, but hosted as its own project on GitHub.

The Cluster Proportional Autoscaler watches the number of schedulable [nodes](#gloss:node) and cores and scales the number of replicas of the target workload accordingly.

If the number of replicas should stay the same, you can scale your workloads vertically according to the cluster size using the [_Cluster Proportional Vertical Autoscaler_](https://github.com/kubernetes-sigs/cluster-proportional-vertical-autoscaler). The project is currently in beta and can be found on GitHub.

While the Cluster Proportional Autoscaler scales the number of replicas of a workload, the Cluster Proportional …(trimmed)

Sources

concepts/workloads/autoscaling.md · docAutoscaling Workloads

Related (14)

references DeploymentDeployment conf=1
references Controllercontroller conf=1
references Replicareplicas conf=1
references Nodenodes conf=1
part_of Scaling workloads manuallydescribes conf=1
part_of Scaling workloads automaticallydescribes conf=1
part_of Scaling cluster infrastructuredescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of Scaling workloads horizontallydescribes conf=1
part_of Scaling workloads verticallydescribes conf=1
part_of Autoscaling based on cluster sizedescribes conf=1
part_of Event driven Autoscalingdescribes conf=1
part_of Autoscaling based on schedulesdescribes conf=1
api_for Workloaddocuments API object conf=1

← all Docs