vpa

by Fairwinds

Helm chartv5.2.0App 1.7.1Verified publisher

A Helm chart for Kubernetes Vertical Pod Autoscaler

About this chart

VPA

A chart to install the Kubernetes Vertical Pod Autoscaler

This chart is mostly based on the manifests and various scripts in the deploy and hack directories of the VPA repository.

Tests and Debugging

There are a few tests included with this chart that can help debug why your installation of VPA isn't working as expected. You can run helm test -n <Release Namespace> <Release Name> to run them.

  • crds-available - Checks for both the verticalpodautoscalers and verticalpodautoscalercheckpoints CRDs
  • metrics-api-available - Checks to make sure that the metrics API endpoint is available. If it's not, install metrics-server in your cluster.
  • create-vpa - A simple check to make sure that VPA objects can be created in your cluster. Does not check for functionality of that VPA.
  • webhook-configuration - Checks that both the service and the CA bundle in the MutatingWebhookconfiguration are configured correctly.

Components

There are three primary components to the Vertical Pod Autoscaler that can be enabled individually here.

  • recommender
  • updater
  • admissionController

The admissionController is the only one that poses a stability consideration because it will create a MutatingWebhookconfiguration in your cluster. This could cause the cluster to stop accepting pod creation requests, if it is not configured correctly. Because of this, the MutatingWebhookconfiguration has its failurePolicy set to Ignore by default.

For more details, please see the values below, and the vertical pod autosclaer documentation.

BREAKING Upgrading to >=5.0.0

VPA 1.7 requires Kubernetes 1.28 or later. The InPlace, InPlaceOrRecreate, and CPUStartupBoost features require Kubernetes 1.33 or later.

Update the installed CRDs from the chart's crds/ directory before upgrading. The VPA 1.7 CRDs add the InPlace update mode, CPU startup boost, per-VPA configuration fields, and observed generation status fields. Helm does not upgrade CRDs automatically.

The InPlace, CPUStartupBoost, and PerVPAConfig features are alpha and disabled by default. Configure InPlace and CPUStartupBoost on the admission controller and updater. Configure PerVPAConfig on the admission controller, recommender, and updater. See the VPA 1.7 feature documentation for configuration and requirements.

BREAKING Upgrading to >=4.0.0

Ensure that you update the CRDs from the autoscaler repository or the crds/ folder.

BREAKING Upgrading from <= v2.5.1 to 3.0.0

ClusterRole rules

Previously, ClusterRoles were created by default from templates and could not be extended with custom rules. Since 3.0.0 version it is possible.

You can define it as follows:

rbac:
  extraRules:
    vpaActor:
      - apiGroups:
          - batch
        resources:
          - '*'
        verbs:
          - get
    vpaCheckpointActor: []
    vpaEvictioner: []
    vpaMetricsReader: []
    vpaTargetReader: []
    vpaStatusReader: []

BREAKING Upgrading from <= v1.7.x to 2.0.0

Certificate generation

The certificate creation process was changed from using OpenSSL to kube-webhook-certgen to simplify the process. It still uses the same configuration keys (.Values.admissionController.certGen), which makes it impossible to reuse the values from a previous install.

You can mitigate this change by setting the correct image for the upgrade:

helm upgrade <release name> fairwinds-stable/vpa --version 2.0.0 --reuse-values \
  --set "admissionController.certGen.image.repository=registry.k8s.io/ingress-nginx/kube-webhook-certgen" \
  --set "admissionController.certGen.image.tag=v20230312-helm-chart-4.5.2-28-g66a760794"

The new process is incompatible with the old secrets layout. To mitigate this, the secret was renamed to (by default) <release name>-tls-certs and can now also be customized.

All other changes are implemented in a non breaking fashion.

MutatingWebhookconfiguration

Previously, the webhook creation was handled by the admission controller itself. This had the downside that Helm is not in control of the resource and therefore required the cleanupOnDelete job.

This version disables the selfRegistration by the admission controller and creates the MutatingWebhookconfiguration using Helm.

You can either:

  • Migrate the MutatingWebhookconfiguration by:

    • adding the label app.kubernetes.io/managed-by: Helm
    • adding the annotation meta.helm.sh/release-name: <release name>
    • adding the annotation meta.helm.sh/release-namespace: <release namespace>
  • delete the configuration and it will be recreated by Helm

  • or keep the configuration as it is and Helm will ignore it. Execute the tests, to make sure everything works.

Also, the cleanupOnDelete configuration is obsolete.

Admission controller

The admission controller is enabled by default.

BREAKING Upgrading from v0.x.x to v1.x.x

In the previous version, when the admissionController.cleanupOnDelete flag was set to true, MutatingWebhookconfiguration and the tls secret for the admission controller were removed. There was no chance to pass any image information to start remove process. Now, it could be passed custom image by version 1.0.0.

cleanupOnDelete:
    enabled: true
    image:
      repository: us-docker.pkg.dev/fairwinds-ops/oss/ci-images
      tag: v11-alpine

Installation

helm repo add fairwinds-stable https://charts.fairwinds.com/stable
helm install vpa fairwinds-stable/vpa --namespace vpa --create-namespace

Utilize Prometheus for History

In order to utilize prometheus for recommender history, you will need to pass some extra flags to the recommender. If you use prometheus operator installed in the prometheus-operator namespace, these values will do the trick.

recommender:
  extraArgs:
    prometheus-address: |
      http://prometheus-operator-prometheus.prometheus-operator.svc.cluster.local:9090
    storage: prometheus

Utilize In-Place Pod Vertical Scaling

In VPA 1.7.0, the InPlaceOrRecreate feature gate was removed. No VPA feature gate configuration is required for this update mode.

To use in-place scaling, configure your VPA resources with:

spec:
  updatePolicy:
    updateMode: "InPlaceOrRecreate"

Note: your Kubernetes cluster must support in-place pod resizing (InPlacePodVerticalScaling is GA since Kubernetes 1.33).

Optional: Skip disruption budget checks for in-place updates

VPA 1.6.0 introduces an opt-in flag that skips PDB checks for in-place updates when all containers have NotRequired resize policy (i.e. no pod restart needed). Disruption budgets are still respected when any container has RestartContainer resize policy.

updater:
  extraArgs:
    "in-place-skip-disruption-budget": "true"

Deprecated: Auto update mode

The Auto update mode is deprecated since VPA 1.5 and will be removed in a future release. It currently behaves identically to Recreate. Migrate to either Recreate or InPlaceOrRecreate.

For more information, see VPA docs and Kubernetes docs.

Values

KeyTypeDefaultDescription
imagePullSecretslist[]A list of image pull secrets to be used for all pods
priorityClassNamestring""To set the priorityclass for all pods
nameOverridestring""A template override for the name
fullnameOverridestring""A template override for the fullname
podLabelsobject{}Labels to add to all pods
rbac.createbooltrueIf true, then rbac resources (ClusterRoles and ClusterRoleBindings) will be created for the selected components. Temporary rbac resources will still be created, to ensure a functioning installation process
rbac.extraRulesobject{"vpaActor":[],"vpaCheckpointActor":[],"vpaEvictioner":[],"vpaMetricsReader":[],"vpaStatusActor":[],"vpaStatusReader":[],"vpaTargetReader":[],"vpaUpdaterInPlace":[]}Extra rbac rules for ClusterRoles
rbac.extraRules.vpaActorlist[]Extra rbac rules for the vpa-actor ClusterRole
rbac.extraRules.vpaStatusActorlist[]Extra rbac rules for the vpa-status-actor ClusterRole
rbac.extraRules.vpaCheckpointActorlist[]Extra rbac rules for the vpa-checkpoint-actor ClusterRole
rbac.extraRules.vpaEvictionerlist[]Extra rbac rules for the vpa-evictioner ClusterRole
rbac.extraRules.vpaMetricsReaderlist[]Extra rbac rules for the vpa-metrics-reader ClusterRole
rbac.extraRules.vpaUpdaterInPlacelist[]Extra rbac rules for the vpa-updater-in-place ClusterRole
rbac.extraRules.vpaTargetReaderlist[]Extra rbac rules for the vpa-target-reader ClusterRole
rbac.extraRules.vpaStatusReaderlist[]Extra rbac rules for the vpa-status-reader ClusterRole
serviceAccount.createbooltrueSpecifies whether a service account should be created for each component
serviceAccount.annotationsobject{}Annotations to add to the service accounts for each component
serviceAccount.namestring""The base name of the service account to use (appended with the component). If not set and create is true, a name is generated using the fullname template and appended for each component
serviceAccount.automountServiceAccountTokenbooltrueAutomount API credentials for the Service Account
recommender.enabledbooltrueIf true, the vpa recommender component will be installed.
recommender.envFromSecretstring""Specify a secret to get environment variables from
recommender.annotationsobject{}Annotations to add to the recommender deployment
recommender.extraArgsobject{"pod-recommendation-min-cpu-millicores":15,"pod-recommendation-min-memory-mb":100,"v":"4"}A set of key-value flags to be passed to the recommender
recommender.replicaCountint1
recommender.revisionHistoryLimitint10The number of old replicasets to retain, default is 10, 0 will garbage-collect old replicasets
recommender.podDisruptionBudgetobject{}This is the setting for the pod disruption budget
recommender.image.repositorystring"registry.k8s.io/autoscaling/vpa-recommender"The location of the recommender image
recommender.image.tagstring""Overrides the image tag whose default is the chart appVersion
recommender.image.pullPolicystring"Always"The pull policy for the recommender image. Recommend not changing this
recommender.podAnnotationsobject{}Annotations to add to the recommender pod
recommender.podLabelsobject{}Labels to add to the recommender pod
recommender.podSecurityContextobject{"runAsNonRoot":true,"runAsUser":65534,"seccompProfile":{"type":"RuntimeDefault"}}The security context for the recommender pod
recommender.securityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}The security context for the containers inside the recommender pod
recommender.livenessProbeobject{"failureThreshold":6,"httpGet":{"path":"/health-check","port":"metrics","scheme":"HTTP"},"periodSeconds":5,"successThreshold":1,"timeoutSeconds":3}The liveness probe definition inside the recommender pod
recommender.readinessProbeobject{"failureThreshold":120,"httpGet":{"path":"/health-check","port":"metrics","scheme":"HTTP"},"periodSeconds":5,"successThreshold":1,"timeoutSeconds":3}The readiness probe definition inside the recommender pod
recommender.resourcesobject{"limits":{},"requests":{"cpu":"50m","memory":"500Mi"}}The resources block for the recommender pod
recommender.nodeSelectorobject{}
recommender.tolerationslist[]
recommender.affinityobject{}
recommender.podMonitorobject{"annotations":{},"enabled":false,"labels":{}}Enables a prometheus operator podMonitor for the recommender
updater.enabledbooltrueIf true, the updater component will be deployed
updater.annotationsobject{}Annotations to add to the updater deployment
updater.extraArgsobject{}A key-value map of flags to pass to the updater. Since VPA 1.6.0: set "in-place-skip-disruption-budget": "true" to skip PDB checks for in-place updates when all containers have NotRequired resize policy.
updater.replicaCountint1
updater.revisionHistoryLimitint10The number of old replicasets to retain, default is 10, 0 will garbage-collect old replicasets
updater.podDisruptionBudgetobject{}This is the setting for the pod disruption budget
updater.image.repositorystring"registry.k8s.io/autoscaling/vpa-updater"The location of the updater image
updater.image.tagstring""Overrides the image tag whose default is the chart appVersion
updater.image.pullPolicystring"Always"The pull policy for the updater image. Recommend not changing this
updater.podAnnotationsobject{}Annotations to add to the updater pod
updater.podLabelsobject{}Labels to add to the updater pod
upda

Deploy vpa with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has vpa on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartvpa is pinned at v5.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply