From 795f9a931a447d9d66bdca0f600d49ad85489f68 Mon Sep 17 00:00:00 2001 From: t3mi Date: Thu, 10 Aug 2023 17:11:47 +0000 Subject: [PATCH] feat: add vpa support Signed-off-by: t3mi --- .../templates/verticalpodautoscaler.yaml | 42 +++++++++++++++++++ snyk-monitor/values.yaml | 32 ++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 snyk-monitor/templates/verticalpodautoscaler.yaml diff --git a/snyk-monitor/templates/verticalpodautoscaler.yaml b/snyk-monitor/templates/verticalpodautoscaler.yaml new file mode 100644 index 000000000..23040b826 --- /dev/null +++ b/snyk-monitor/templates/verticalpodautoscaler.yaml @@ -0,0 +1,42 @@ +{{- if and (.Capabilities.APIVersions.Has "autoscaling.k8s.io/v1") (.Values.verticalPodAutoscaler.enabled) }} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: {{ include "snyk-monitor.name" . }} + labels: + app.kubernetes.io/name: {{ include "snyk-monitor.name" . }} + helm.sh/chart: {{ include "snyk-monitor.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + {{- with .Values.verticalPodAutoscaler.recommenders }} + recommenders: + {{- toYaml . | nindent 4 }} + {{- end }} + resourcePolicy: + containerPolicies: + - containerName: {{ include "snyk-monitor.name" . }} + {{- with .Values.verticalPodAutoscaler.controlledResources }} + controlledResources: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.verticalPodAutoscaler.controlledValues }} + controlledValues: {{ .Values.verticalPodAutoscaler.controlledValues }} + {{- end }} + {{- if .Values.verticalPodAutoscaler.maxAllowed }} + maxAllowed: + {{ toYaml .Values.verticalPodAutoscaler.maxAllowed | nindent 8 }} + {{- end }} + {{- if .Values.verticalPodAutoscaler.minAllowed }} + minAllowed: + {{ toYaml .Values.verticalPodAutoscaler.minAllowed | nindent 8 }} + {{- end }} + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "snyk-monitor.name" . }} + {{- with .Values.verticalPodAutoscaler.updatePolicy }} + updatePolicy: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/snyk-monitor/values.yaml b/snyk-monitor/values.yaml index 991f3413e..4f4e899f6 100644 --- a/snyk-monitor/values.yaml +++ b/snyk-monitor/values.yaml @@ -180,3 +180,35 @@ extraInitContainers: [] # - name: wait-for-condition # image: "{{ .Values.initContainerImage.repository }}:{{ .Values.initContainerImage.tag }}" # command: ['sh', '-c', 'sleep 10 || :'] + +# Enable vertical pod autoscaler support +# https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler +verticalPodAutoscaler: + enabled: false + + # Recommender responsible for generating recommendation for the object. + # List should be empty (then the default recommender will generate the recommendation) + # or contain exactly one recommender. + # recommenders: + # - name: custom-recommender-performance + + # List of resources that the vertical pod autoscaler can control. Defaults to cpu and memory + controlledResources: [] + # Specifies which resource values should be controlled: RequestsOnly or RequestsAndLimits. + # controlledValues: RequestsAndLimits + + # Define the max allowed resources for the pod + maxAllowed: {} + # cpu: 1 + # memory: 2Gi + # Define the min allowed resources for the pod + minAllowed: {} + # cpu: 250m + # memory: 400Mi + + updatePolicy: + # Specifies minimal number of replicas which need to be alive for VPA Updater to attempt pod eviction + # minReplicas: 1 + # Specifies whether recommended updates are applied when a Pod is started and whether recommended updates + # are applied during the life of a Pod. Possible values are "Off", "Initial", "Recreate", and "Auto". + updateMode: Auto \ No newline at end of file