Add helm chart for VPA

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
This commit is contained in:
Omer Aplatony 2025-09-16 14:14:14 +00:00
parent 64a815fe45
commit e66babcacf
10 changed files with 406 additions and 0 deletions

View File

@ -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/

View File

@ -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"

View File

@ -0,0 +1,6 @@
approvers:
- sig-autoscaling-vpa-approvers
reviewers:
- sig-autoscaling-vpa-reviewers
labels:
- area/vertical-pod-autoscaler

View File

@ -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 }}

View File

@ -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 -}}

View File

@ -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 -}}

View File

@ -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 -}}

View File

@ -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 -}}

View File

@ -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 -}}

View File

@ -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