From e66babcacf0b4dd9535cf2500006410cfab054cf Mon Sep 17 00:00:00 2001 From: Omer Aplatony Date: Tue, 16 Sep 2025 14:14:14 +0000 Subject: [PATCH] Add helm chart for VPA Signed-off-by: Omer Aplatony --- charts/vertical-pod-autoscaler/.helmignore | 23 ++++ charts/vertical-pod-autoscaler/Chart.yaml | 24 ++++ charts/vertical-pod-autoscaler/OWNERS | 6 + .../templates/_helpers.tpl | 64 +++++++++++ .../admission-contoller-serviceaccount.yaml | 16 +++ .../admission-controller-clusterrole.yaml | 56 +++++++++ ...mission-controller-clusterrolebinding.yaml | 16 +++ .../admission-controller-deployment.yaml | 76 +++++++++++++ .../admission-controller-service.yaml | 19 ++++ charts/vertical-pod-autoscaler/values.yaml | 106 ++++++++++++++++++ 10 files changed, 406 insertions(+) create mode 100644 charts/vertical-pod-autoscaler/.helmignore create mode 100644 charts/vertical-pod-autoscaler/Chart.yaml create mode 100644 charts/vertical-pod-autoscaler/OWNERS create mode 100644 charts/vertical-pod-autoscaler/templates/_helpers.tpl create mode 100644 charts/vertical-pod-autoscaler/templates/admission-contoller-serviceaccount.yaml create mode 100644 charts/vertical-pod-autoscaler/templates/admission-controller-clusterrole.yaml create mode 100644 charts/vertical-pod-autoscaler/templates/admission-controller-clusterrolebinding.yaml create mode 100644 charts/vertical-pod-autoscaler/templates/admission-controller-deployment.yaml create mode 100644 charts/vertical-pod-autoscaler/templates/admission-controller-service.yaml create mode 100644 charts/vertical-pod-autoscaler/values.yaml diff --git a/charts/vertical-pod-autoscaler/.helmignore b/charts/vertical-pod-autoscaler/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/charts/vertical-pod-autoscaler/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/vertical-pod-autoscaler/Chart.yaml b/charts/vertical-pod-autoscaler/Chart.yaml new file mode 100644 index 0000000000..cd8db81cdd --- /dev/null +++ b/charts/vertical-pod-autoscaler/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: vertical-pod-autoscaler +description: Automatically adjust resources for your workloads + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.4.2" diff --git a/charts/vertical-pod-autoscaler/OWNERS b/charts/vertical-pod-autoscaler/OWNERS new file mode 100644 index 0000000000..a2b79174d9 --- /dev/null +++ b/charts/vertical-pod-autoscaler/OWNERS @@ -0,0 +1,6 @@ +approvers: +- sig-autoscaling-vpa-approvers +reviewers: +- sig-autoscaling-vpa-reviewers +labels: +- area/vertical-pod-autoscaler diff --git a/charts/vertical-pod-autoscaler/templates/_helpers.tpl b/charts/vertical-pod-autoscaler/templates/_helpers.tpl new file mode 100644 index 0000000000..0f67abb28e --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/_helpers.tpl @@ -0,0 +1,64 @@ +{{/* +Chart +*/}} +{{- define "vertical-pod-autoscaler.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "vertical-pod-autoscaler.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "vertical-pod-autoscaler.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "vertical-pod-autoscaler.labels" -}} +helm.sh/chart: {{ include "vertical-pod-autoscaler.chart" . }} +{{ include "vertical-pod-autoscaler.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- with .Values.commonLabels }} +{{ toYaml . }} +{{- end }} +{{- end }} + +{{- define "vertical-pod-autoscaler.selectorLabels" -}} +app.kubernetes.io/name: {{ include "vertical-pod-autoscaler.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + + +{{/* +admissionController +*/}} +{{- define "vertical-pod-autoscaler.admissionController.fullname" -}} +{{ include "vertical-pod-autoscaler.fullname" . }}-admission-controller +{{- end }} + +{{- define "vertical-pod-autoscaler.admissionController.labels" -}} +{{ include "vertical-pod-autoscaler.labels" . }} +app.kubernetes.io/component: admission-controller +app.kubernetes.io/component-instance: {{ .Release.Name }}-admission-controller +{{- end }} + +{{- define "vertical-pod-autoscaler.admissionController.selectorLabels" -}} +{{ include "vertical-pod-autoscaler.selectorLabels" . }} +app.kubernetes.io/component: admission-controller +{{- end }} + +{{- define "vertical-pod-autoscaler.admissionController.image" -}} +{{- printf "%s:%s" .Values.admissionController.image.repository (default .Chart.AppVersion .Values.admissionController.image.tag) }} +{{- end }} + diff --git a/charts/vertical-pod-autoscaler/templates/admission-contoller-serviceaccount.yaml b/charts/vertical-pod-autoscaler/templates/admission-contoller-serviceaccount.yaml new file mode 100644 index 0000000000..c21fcd1d59 --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/admission-contoller-serviceaccount.yaml @@ -0,0 +1,16 @@ +{{- if and (not .Values.recommenderOnly) .Values.admissionController.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "vertical-pod-autoscaler.admissionController.labels" . | nindent 4 }} + {{- with .Values.admissionController.serviceAccount.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.admissionController.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrole.yaml b/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrole.yaml new file mode 100644 index 0000000000..3d53f2f1c6 --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrole.yaml @@ -0,0 +1,56 @@ +{{- if and (not .Values.recommenderOnly) .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + labels: + {{- include "vertical-pod-autoscaler.admissionController.labels" . | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - pods + - configmaps + - nodes + - limitranges + verbs: + - get + - list + - watch +- apiGroups: + - admissionregistration.k8s.io + resources: + - mutatingwebhookconfigurations + verbs: + - create + - delete + - get + - list + - patch +- apiGroups: + - poc.autoscaling.k8s.io + resources: + - verticalpodautoscalers + verbs: + - get + - list + - watch +- apiGroups: + - autoscaling.k8s.io + resources: + - verticalpodautoscalers + verbs: + - get + - list + - watch +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - update + - get + - list + - watch +{{- end -}} \ No newline at end of file diff --git a/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrolebinding.yaml b/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrolebinding.yaml new file mode 100644 index 0000000000..88fe79fa26 --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/admission-controller-clusterrolebinding.yaml @@ -0,0 +1,16 @@ +{{- if and (not .Values.recommenderOnly) .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + labels: + {{- include "vertical-pod-autoscaler.admissionController.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + namespace: {{ .Release.Namespace }} +{{- end -}} \ No newline at end of file diff --git a/charts/vertical-pod-autoscaler/templates/admission-controller-deployment.yaml b/charts/vertical-pod-autoscaler/templates/admission-controller-deployment.yaml new file mode 100644 index 0000000000..41fe8bab97 --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/admission-controller-deployment.yaml @@ -0,0 +1,76 @@ +{{- if not .Values.recommenderOnly -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "vertical-pod-autoscaler.admissionController.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.admissionController.replicas }} + {{- with .Values.admissionController.updateStrategy }} + strategy: + {{- toYaml . | nindent 4 }} + {{- end }} + selector: + matchLabels: + {{- include "vertical-pod-autoscaler.admissionController.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "vertical-pod-autoscaler.admissionController.selectorLabels" . | nindent 8 }} + {{- with .Values.admissionController.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.admissionController.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }} + {{- with .Values.admissionController.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: admission-controller + image: {{ include "vertical-pod-autoscaler.admissionController.image" . }} + imagePullPolicy: {{ .Values.admissionController.image.pullPolicy }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + {{- with .Values.admissionController.extraEnv }} + {{- toYaml . | nindent 12 }} + {{- end }} + args: + - --v=4 + - --stderrthreshold=info + - --reload-cert + {{- with .Values.admissionController.extraArgs }} + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - containerPort: 8000 + protocol: TCP + - containerPort: 8944 + name: prometheus + protocol: TCP + livenessProbe: + {{- toYaml .Values.admissionController.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.admissionController.readinessProbe | nindent 12 }} + volumeMounts: + {{- toYaml .Values.admissionController.volumeMounts | nindent 12 }} + {{- with .Values.admissionController.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + {{- toYaml .Values.admissionController.volumes | nindent 12 }} +{{- end -}} diff --git a/charts/vertical-pod-autoscaler/templates/admission-controller-service.yaml b/charts/vertical-pod-autoscaler/templates/admission-controller-service.yaml new file mode 100644 index 0000000000..18ef1ab4d0 --- /dev/null +++ b/charts/vertical-pod-autoscaler/templates/admission-controller-service.yaml @@ -0,0 +1,19 @@ +{{- if not .Values.recommenderOnly -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.admissionController.service.name }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "vertical-pod-autoscaler.admissionController.labels" . | nindent 4 }} + {{- with .Values.admissionController.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: ClusterIP + ports: + {{- toYaml .Values.admissionController.service.ports | nindent 4 }} + selector: + {{- include "vertical-pod-autoscaler.admissionController.selectorLabels" . | nindent 4 }} +{{- end -}} diff --git a/charts/vertical-pod-autoscaler/values.yaml b/charts/vertical-pod-autoscaler/values.yaml new file mode 100644 index 0000000000..ed6f11bccd --- /dev/null +++ b/charts/vertical-pod-autoscaler/values.yaml @@ -0,0 +1,106 @@ +# Image pull secrets. +imagePullSecrets: [] + +# Override the name of the chart. +nameOverride: + +# Override the full name of the chart. +fullnameOverride: + +# Labels to add to all chart resources. +commonLabels: {} + +rbac: + # If `true`, create `ClusterRole` & `ClusterRoleBinding` resources to enable access to the Kubernetes API. + create: true + +recommenderOnly: false + +admissionController: + image: + # Image repository for the Admission Controller default container. + repository: registry.k8s.io/autoscaling/vpa-admission-controller + # Image tag for the Admission Controller default container; this will default to `.Chart.AppVersion` if not set + tag: + # Image pull policy for the Admission Controller default container. + pullPolicy: IfNotPresent + + serviceAccount: + # If `true`, create a new `ServiceAccount` for the Admission Controller. + create: true + # Labels to add to the Admission Controller service account. + labels: {} + # Annotations to add to the Admission Controller service account. + annotations: {} + + service: + name: vpa-webhook + # Annotations to add to the Admission Controller service. + annotations: {} + ports: + - port: 443 + protocol: TCP + targetPort: 8000 + + # Number of Admission Controller replicas to create. + replicas: 1 + + # Labels to add to the Admission Controller pod. + podLabels: {} + + # Annotations to add to the Admission Controller pod. + podAnnotations: {} + + # Additional environment variables for the Admission Controller default container. + extraEnv: [] + + # Additional args for the Admission Controller default container. + extraArgs: [] + + # Security context for the Admission Controller pod + podSecurityContext: + runAsNonRoot: true + runAsUser: 65534 + + # Liveness probe configuration for the Admission Controller default container. + livenessProbe: + httpGet: + path: /health-check + port: prometheus + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + failureThreshold: 3 + + # Readiness probe configuration for the _Updater_ default container. + readinessProbe: + httpGet: + path: /health-check + port: prometheus + scheme: HTTP + periodSeconds: 10 + failureThreshold: 3 + + # Resources for the Admission Controller default container. + resources: + limits: + cpu: 200m + memory: 500Mi + requests: + cpu: 50m + memory: 200Mi + + # Node selector labels for scheduling the Admission Controller. + nodeSelector: {} + + volumes: + name: tls-certs + secret: + defaultMode: 420 + secretName: vpa-tls-certs + + volumeMounts: + - name: tls-certs + mountPath: /etc/tls-certs + readOnly: true + \ No newline at end of file