vertical-pod-autoscaler

by Kubernetes

Helm chartv0.17.0App 1.8.1

Automatically adjust resources for your workloads

About this chart

vertical-pod-autoscaler

WARNING: This chart is currently under development and is not ready for production use.

Automatically adjust resources for your workloads

Introduction

The Vertical Pod Autoscaler (VPA) automatically adjusts the CPU and memory resource requests of pods to match their actual resource utilization.

Helm Installation & upgrade

helm repo add autoscalers https://kubernetes.github.io/autoscaler
helm upgrade -i vertical-pod-autoscaler autoscalers/vertical-pod-autoscaler

Maintainers

NameEmailUrl
adrianmoisey[email protected]
omerap12[email protected]

Webhook Management

The admission controller requires a MutatingWebhookConfiguration and TLS certificates. This chart supports three mutually exclusive modes:

Helm-managed (default)

admissionController:
  registerWebhook: false
  certGen:
    enabled: true

In this mode:

  • Helm creates the MutatingWebhookConfiguration
  • The kube-webhook-certgen job generates TLS certificates and stores them in a Secret
  • The certificates are automatically injected into the webhook configuration

Application-managed

admissionController:
  registerWebhook: true
  certGen:
    enabled: false

In this mode:

  • The VPA admission controller creates and manages the webhook itself Important: You are responsible for creating the TLS secret before or after installing the chart. The admission controller will only create the MutatingWebhookConfiguration once the secret exists. If the secret is created after the Helm install, you must restart the admission controller pod to trigger webhook registration.

cert-manager managed

Using an existing Issuer or ClusterIssuer:

admissionController:
  registerWebhook: false
  certGen:
    enabled: false
  certManager:
    enabled: true
    issuerRef:
      name: my-issuer
      kind: ClusterIssuer

Or letting the chart create a namespaced self-signed issuer:

admissionController:
  registerWebhook: false
  certGen:
    enabled: false
  certManager:
    enabled: true
    createSelfSignedIssuer:
      enabled: true

In this mode:

  • Helm creates the MutatingWebhookConfiguration
  • cert-manager issues and renews TLS certificates automatically
  • cert-manager's cainjector injects the CA into the webhook configuration

By default, you must provide an existing Issuer or ClusterIssuer via admissionController.certManager.issuerRef. Alternatively, enable admissionController.certManager.createSelfSignedIssuer.enabled: true to let the chart create a namespaced self-signed issuer automatically.

Custom Resource Definitions

The VPA CRDs are managed as regular chart templates and are kept in sync automatically on helm upgrade (set crds.enabled: false if you manage CRDs separately, e.g. via Argo CD or Fleet).

By default, the CRDs are annotated with helm.sh/resource-policy: keep, so helm uninstall will not remove them, protecting any existing VPA objects from being deleted. Set crds.keep: false to disable this.

[!WARNING] If you're upgrading from a chart version before 0.12.0 (when CRDs moved from crds/ to templates/) and crds.enabled is true, the upgrade will fail with an "invalid ownership metadata" error unless you use --take-ownership or apply the manual fix below first. If crds.enabled is false, these CRDs are not rendered by the chart. This is because Helm never took ownership of CRDs installed via the old crds/ folder, so it refuses to adopt them without one of these steps. This only needs to be done once, on your first upgrade past 0.12.0.

If you're on Helm 3.17+, pass --take-ownership on that upgrade:

helm upgrade <release-name> <chart> --namespace <namespace> --take-ownership

On older Helm versions --take-ownership isn't available, so add the ownership metadata manually first:

kubectl label crd verticalpodautoscalercheckpoints.autoscaling.k8s.io app.kubernetes.io/managed-by=Helm --overwrite
kubectl annotate crd verticalpodautoscalercheckpoints.autoscaling.k8s.io meta.helm.sh/release-name=<release-name> meta.helm.sh/release-namespace=<namespace> --overwrite

kubectl label crd verticalpodautoscalers.autoscaling.k8s.io app.kubernetes.io/managed-by=Helm --overwrite
kubectl annotate crd verticalpodautoscalers.autoscaling.k8s.io meta.helm.sh/release-name=<release-name> meta.helm.sh/release-namespace=<namespace> --overwrite

Extra Objects

extraObjects deploys additional Kubernetes manifests alongside the release, for example a PodMonitor, a NetworkPolicy or a ConfigMap. This avoids a separate chart or a manual kubectl apply, and the chart does not need to know about (or depend on the CRDs of) those resource types.

Each item in the list is either a YAML map or a multi-line string. Both forms are evaluated as templates, so .Release, .Values, .Chart and the named templates of this chart are available. Objects without metadata.namespace are created in the release namespace.

Map form:

extraObjects:
  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: "{{ .Release.Name }}-example"
    data:
      key: value

String form, which you need when using pipelines such as nindent. This example scrapes the Recommender's metrics with the Prometheus Operator (requires its CRDs):

extraObjects:
  - |
    apiVersion: monitoring.coreos.com/v1
    kind: PodMonitor
    metadata:
      name: {{ include "vertical-pod-autoscaler.recommender.fullname" . }}
      labels:
        {{- include "vertical-pod-autoscaler.recommender.labels" . | nindent 4 }}
    spec:
      selector:
        matchLabels:
          {{- include "vertical-pod-autoscaler.recommender.selectorLabels" . | nindent 6 }}
      podMetricsEndpoints:
        - port: prometheus

Because items are evaluated as templates, a literal {{ ... }} in a manifest (for example in a PrometheusRule annotation) must be escaped:

summary: "{{`{{ $labels.pod }}`}} is restarting"

Feature Gates

VPA feature gates are set once at the top level and passed to every component as a single --feature-gates argument:

featureGates:
  InPlace: true
  CPUStartupBoost: true

If a component's extraArgs already contains a --feature-gates argument, the chart does not add its own for that component, so you can override the gates of a single component:

featureGates:
  InPlace: true
recommender:
  extraArgs:
    - --feature-gates=InPlace=true,CPUStartupBoost=true

Probes

Each component (admissionController, recommender, updater) has livenessProbe, readinessProbe and startupProbe values. The liveness and readiness defaults call /health-check on the prometheus port. You can override single fields, for example:

recommender:
  livenessProbe:
    initialDelaySeconds: 30

The startup probe is off by default. Enable it for a component that needs more time to start, for example a Recommender with a large cluster to load:

recommender:
  startupProbe:
    httpGet:
      path: /health-check
      port: prometheus
    periodSeconds: 10
    failureThreshold: 30

Set a probe to null to remove it. Helm merges your values into the defaults, so to switch a probe to a different handler (for example tcpSocket), also set httpGet: null.

Migration Guides

Migrating from vpa-up.sh script

TBD

Migrating from Application-managed to Helm-managed webhook

If you previously deployed with registerWebhook: true and want to switch to Helm-managed:

  • Delete the existing webhook:
kubectl delete mutatingwebhookconfiguration vpa-webhook-config
  • Delete the existing secret (to allow certgen to create new certificates):
kubectl delete secret -n <namespace> vpa-tls-certs
  • Upgrade with the new values:
helm upgrade <release-name> <chart> \
  --set admissionController.registerWebhook=false \
  --set admissionController.certGen.enabled=true

Testing

This chart includes helm-unittest test suites under tests/ that validate template rendering logic (e.g. recommender leader-election defaults). See TESTING.md for setup instructions, how to run the tests, and how to add new ones.

Values

KeyTypeDefaultDescription
admissionController.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].keystring"app.kubernetes.io/component"
admissionController.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operatorstring"In"
admissionController.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0]string"admission-controller"
admissionController.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKeystring"kubernetes.io/hostname"
admissionController.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weightint100
admissionController.annotationsobject{}
admissionController.certGen.affinityobject{}
admissionController.certGen.enabledbooltrue
admissionController.certGen.envobject{}Additional environment variables to be added to the certgen container. Format is KEY: Value format
admissionController.certGen.image.pullPolicystring"IfNotPresent"The pull policy for the certgen image. Recommend not changing this
admissionController.certGen.image.repositorystring"registry.k8s.io/ingress-nginx/kube-webhook-certgen"An image that contains certgen for creating certificates.
admissionController.certGen.image.tagstring"v20231011-8b53cabe0"An image tag for the admissionController.certGen.image.repository image.
admissionController.certGen.nodeSelectorobject{}
admissionController.certGen.podSecurityContextobject{"runAsNonRoot":true,"runAsUser":65534,"seccompProfile":{"type":"RuntimeDefault"}}The securityContext block for the certgen pod(s)
admissionController.certGen.priorityClassNamestring""Priority class name for the certgen job pods. These jobs gate the release as pre-install/pre-upgrade and post-install/post-upgrade hooks, so a priority class can help them schedule on a busy cluster.
admissionController.certGen.resourcesobject{}The resources block for the certgen pod
admissionController.certGen.securityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}The securityContext block for the certgen container(s)
admissionController.certGen.tolerationslist[]
admissionController.certManager.annotationsobject{}Annotations to add to all cert-manager resources created by Chart.
admissionController.certManager.createSelfSignedIssuerobject{"duration":"8760h","enabled":false,"renewBefore":"720h"}Optionally create a SelfSigned Issuer for CA generation. When enabled, a namespaced SelfSigned Issuer is created in the VPA namespace to issue the intermediate CA certificate, which in turn signs the webhook TLS certificate.
admissionController.certManager.createSelfSignedIssuer.durationstring"8760h"Lifetime of the intermediate CA certificate.
admissionController.certManager.createSelfSignedIssuer.renewBeforestring"720h"Time before expiry to renew the CA certificate.
admissionController.certManager.durationstring"168h"Lifetime of the webhook TLS certificate.
admissionController.certManager.enabledboolfalseIf true, cert-manager manages the webhook certificate lifecycle. cert-manager must be installed in the cluster, see https://cert-manager.io/docs/installation. Mutually exclusive with certGen.enabled, registerWebhook, and tls.create.
admissionController.certManager.issuerRefobject{"group":"cert-manager.io","kind":"ClusterIssuer","name":""}Reference to an existing issuer for signing the webhook TLS certificate. Required when createSelfSignedIssuer.enabled is false.
admissionController.certManager.issuerRef.groupstring"cert-manager.io"API group of the issuer.
admissionController.certManager.issuerRef.kindstring"ClusterIssuer"Kind of the issuer (ClusterIssuer or Issuer).
admissionController.certManager.issuerRef.namestring""Name of the issuer.
admissionController.certManager.privateKey.algorithmstring"RSA"Key algorithm for certificates (RSA, ECDSA, Ed25519).
admissionController.certManager.privateKey.sizeint2048Key size for RSA or ECDSA. Ignored for Ed25519.
admissionController.certManager.renewBeforestring"24h"Time before expiry to renew the TLS certificate.
admissionController.enabledbooltrue
admissionController.extraArgslist[]
admissionController.extraEnvlist[]
admissionController.hostNetworkboolfalseEnable host network for the admission controller pod. Set to true when the pod needs direct access to the host's network namespace. Note: this bypasses Kubernetes network isolation and may cause port conflicts i

Deploy vertical-pod-autoscaler with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has vertical-pod-autoscaler 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 chartvertical-pod-autoscaler is pinned at v0.17.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