Skip to content

Vertical Pod Scaling

Vertical pod scaling (VPA) configuration#

# vpa.yaml
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: test-vpa
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind:       Deployment
    name:       test-deployment
  updatePolicy:
    updateMode: "Auto"

updateMode is crucial here, it's recommended to deploy with update mode "Off."

// UpdateMode controls when autoscaler applies changes to the pod resoures.
// +kubebuilder:validation:Enum=Off;Initial;Recreate;Auto
type UpdateMode string

const (
    // UpdateModeOff means that autoscaler never changes Pod resources.
    // The recommender still sets the recommended resources in the
    // VerticalPodAutoscaler object. This can be used for a "dry run".
    UpdateModeOff UpdateMode = "Off"
    // UpdateModeInitial means that autoscaler only assigns resources on pod
    // creation and does not change them during the lifetime of the pod.
    UpdateModeInitial UpdateMode = "Initial"
    // UpdateModeRecreate means that autoscaler assigns resources on pod
    // creation and additionally can update them during the lifetime of the
    // pod by deleting and recreating the pod.
    UpdateModeRecreate UpdateMode = "Recreate"
    // UpdateModeAuto means that autoscaler assigns resources on pod creation
    // and additionally can update them during the lifetime of the pod,
    // using any available update method. Currently this is equivalent to
    // Recreate, which is the only available update method.
    UpdateModeAuto UpdateMode = "Auto"
)

Get output#

$ kubectl get vpa test-vpa

NAME                  MODE   CPU   MEM        PROVIDED   AGE
test-vpa              Auto   1m    10485760   True       26h

YAML output#

kubectl get vpa test-vpa -o yaml
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  annotations:
  creationTimestamp: "2022-03-25T05:44:02Z"
  generation: 692
  name: test-vpa
  namespace: default
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: test-deployment
  updatePolicy:
    updateMode: Auto
status:
  conditions:
  - lastTransitionTime: "2022-03-25T05:44:34Z"
    status: "False"
    type: LowConfidence
  - lastTransitionTime: "2022-03-25T05:44:34Z"
    status: "True"
    type: RecommendationProvided
  recommendation:
    containerRecommendations:
    - containerName: sidecar
      lowerBound:
        cpu: 1m
        memory: "9437184"
      target:
        cpu: 1m
        memory: "10485760"
      uncappedTarget:
        cpu: 1m
        memory: "10485760"
      upperBound:
        cpu: 2m
        memory: "12582912"
    - containerName: test-deployment
      lowerBound:
        cpu: 5m
        memory: "179306496"
      target:
        cpu: 6m
        memory: "243269632"
      uncappedTarget:
        cpu: 6m
        memory: "243269632"
      upperBound:
        cpu: 7m
        memory: "273678336"

References & further reading#


Last update: December 13, 2022
Created: July 13, 2022