Skip to content

Commit 3b456cf

Browse files
committed
[app] initial VPA support
1 parent b0c84b7 commit 3b456cf

File tree

7 files changed

+100
-2
lines changed

7 files changed

+100
-2
lines changed

dysnix/app/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: app
33
description: Generic application Helm chart
44
home: https://github.com/dysnix/charts/tree/main/dysnix/app
55
icon: https://dysnix.com/images/logo.svg
6-
version: 0.99.19
6+
version: 0.99.20
77
sources:
88
- https://github.com/dysnix/charts
99
keywords:

dysnix/app/templates/_containers.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ envFrom:
4444
{{- if .Values.resources }}
4545
resources: {{- toYaml .Values.resources | nindent 12 }}
4646
{{- end }}
47+
{{- if .Values.resizePolicy }}
48+
resizePolicy: {{- toYaml .Values.resizePolicy | nindent 12 }}
49+
{{- end }}
4750
{{- with include "app.tplvalues.named-list" ( dict "value" .Values.containerPorts "valueKey" "containerPort" "context" $) }}
4851
ports: {{ . | nindent 12 }}
4952
{{- end }}
@@ -122,4 +125,4 @@ volumeMounts:
122125
{{- if $containers -}}
123126
{{- $containers | toYaml -}}
124127
{{- end -}}
125-
{{- end -}}
128+
{{- end -}}

dysnix/app/templates/_resources.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,7 @@ Usage
9999
{{- define "app.rbac" -}}
100100
{{- include "app.resources.include" (dict "resource" "rbac" | merge .) -}}
101101
{{- end -}}
102+
103+
{{- define "app.vpa" -}}
104+
{{- include "app.resources.include" (dict "resource" "vpa" | merge .) -}}
105+
{{- end -}}

dysnix/app/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ spec:
157157
{{- if .Values.resources }}
158158
resources: {{- toYaml .Values.resources | nindent 12 }}
159159
{{- end }}
160+
{{- if .Values.resizePolicy }}
161+
resizePolicy: {{- toYaml .Values.resizePolicy | nindent 12 }}
162+
{{- end }}
160163
{{- with include "app.tplvalues.named-list" ( dict "value" .Values.containerPorts "valueKey" "containerPort" "context" $) }}
161164
ports: {{ . | nindent 12 }}
162165
{{- end }}

dysnix/app/templates/statefulset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ spec:
162162
{{- if .Values.resources }}
163163
resources: {{- toYaml .Values.resources | nindent 12 }}
164164
{{- end }}
165+
{{- if .Values.resizePolicy }}
166+
resizePolicy: {{- toYaml .Values.resizePolicy | nindent 12 }}
167+
{{- end }}
165168
{{- with include "app.tplvalues.named-list" ( dict "value" .Values.containerPorts "valueKey" "containerPort" "context" $) }}
166169
ports: {{ . | nindent 12 }}
167170
{{- end }}

dysnix/app/templates/vpa.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{/* vim: set filetype=helm: */}}
2+
{{- define "app.resources.vpa" -}}
3+
{{- if .Values.vpa.enabled }}
4+
---
5+
apiVersion: autoscaling.k8s.io/v1
6+
kind: VerticalPodAutoscaler
7+
metadata:
8+
name: {{ include "common.names.fullname" . }}
9+
namespace: {{ include "common.names.namespace" . | quote }}
10+
labels: {{- include "common.labels.standard" . | nindent 4 }}
11+
{{- include "app.labels.component" . | nindent 4 }}
12+
{{- if .Values.commonLabels }}
13+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
{{- if or .Values.vpa.annotations .Values.commonAnnotations }}
16+
annotations:
17+
{{- if .Values.commonAnnotations }}
18+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
19+
{{- end }}
20+
{{- if .Values.vpa.annotations }}
21+
{{- include "common.tplvalues.render" ( dict "value" .Values.vpa.annotations "context" $) | nindent 4 }}
22+
{{- end }}
23+
{{- end }}
24+
spec:
25+
targetRef:
26+
{{- if and .Values.app.workload.enabled (has .Values.app.workload.type (list "statefulset" "sts")) }}
27+
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
28+
kind: StatefulSet
29+
{{- end }}
30+
{{- if and .Values.app.workload.enabled (eq .Values.app.workload.type "deployment") }}
31+
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
32+
kind: Deployment
33+
{{- end }}
34+
name: {{ template "common.names.fullname" . }}
35+
updatePolicy:
36+
{{- with .Values.vpa.updatePolicy }}
37+
updateMode: {{ .updateMode }}
38+
minReplicas: {{ .minReplicas }}
39+
{{- with .evictionRequirements }}
40+
evictionRequirements: {{- toYaml . | nindent 6 }}
41+
{{- end }}
42+
{{- end }}
43+
{{- with .Values.vpa.recommenders }}
44+
recommenders: {{- toYaml . | nindent 4 }}
45+
{{- end }}
46+
{{- with .Values.vpa.resourcePolicy.containerPolicies }}
47+
resourcePolicy:
48+
containerPolicies: {{- toYaml . | nindent 6 }}
49+
{{- end }}
50+
51+
{{- end }}
52+
{{- end -}}
53+
54+
{{/* Include the resource */}}
55+
{{- if eq "direct" (include "app.chart.mode" .) -}}
56+
{{- range $_, $component := concat (list "") $.Values.app.components -}}
57+
{{- $values := ternary $.Values (get $.Values "component") (eq $component "") | default dict -}}
58+
{{- include "app.vpa" (dict "component" $component "values" $values "top" $) -}}
59+
{{- end -}}
60+
{{- end -}}

dysnix/app/values.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ customStartupProbe: {}
337337
resources:
338338
limits: {}
339339
requests: {}
340+
## @param resizePolicy specifies container resize policies
341+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#container-resize-policies
342+
##
343+
resizePolicy: {}
340344
## Configure Pods Security Context
341345
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
342346
## @param podSecurityContext.enabled Enabled pods' Security Context
@@ -414,6 +418,27 @@ autoscaling:
414418
targetCPU: ""
415419
targetMemory: ""
416420
behavior: {}
421+
## Vertical Pod Autoscaler configuration
422+
## ref: https://kubernetes.io/docs/concepts/workloads/autoscaling/vertical-pod-autoscale/
423+
## ref: https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/api.md
424+
## @param vpa.enabled Enable/disable Vertical Pod Autoscaler
425+
## @param vpa.annotations Additional annotations for the VPA resource
426+
## @param vpa.updatePolicy.updateMode VPA update mode. Allowed values: `Off`, `Initial`, `Recreate`, `InPlaceOrRecreate`
427+
## @param vpa.updatePolicy.minReplicas Minimum number of replicas that need to be alive for the updater to attempt pod eviction
428+
## @param vpa.updatePolicy.evictionRequirements Additional eviction requirements for the VPA updater
429+
## @param vpa.recommenders Custom VPA recommenders configuration
430+
## @param vpa.resourcePolicy.containerPolicies Per-container resource policies for VPA
431+
##
432+
vpa:
433+
enabled: false
434+
annotations: {}
435+
updatePolicy:
436+
updateMode: "InPlaceOrRecreate" # Off, Initial, Recreate, InPlaceOrRecreate
437+
minReplicas: 1
438+
evictionRequirements: []
439+
recommenders: []
440+
resourcePolicy:
441+
containerPolicies: []
417442
## Node affinity preset
418443
## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity
419444
##

0 commit comments

Comments
 (0)