Skip to content

Commit

Permalink
Fix vpa (#151)
Browse files Browse the repository at this point in the history
* Update VPA config for failing VPA
  • Loading branch information
mproffitt authored Nov 8, 2022
1 parent 355f289 commit 9bb147e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 36 deletions.
63 changes: 63 additions & 0 deletions helm/flux-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,66 @@ app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- print "unsupported: false" -}}
{{- end -}}
{{- end -}}


{{/*
VPA settings for each controller
*/}}

{{- define "resource.vpa.enabled" -}}
{{- if and (.Capabilities.APIVersions.Has "autoscaling.k8s.io/v1") (.Values.verticalPodAutoscaler.enabled) }}true{{ else }}false{{ end }}
{{- end -}}

{{- define "resources.helmController" -}}
requests:
{{ toYaml .Values.resources.helmController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.helmController.limits | indent 2 -}}
{{- end -}}
{{- end -}}

{{- define "resources.imageAutomationController" -}}
requests:
{{ toYaml .Values.resources.imageAutomationController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.imageAutomationController.limits | indent 2 -}}
{{- end -}}
{{- end -}}

{{- define "resources.imageReflectorController" -}}
requests:
{{ toYaml .Values.resources.imageReflectorController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.imageReflectorController.limits | indent 2 -}}
{{- end -}}
{{- end -}}

{{- define "resources.kustomizeController" -}}
requests:
{{ toYaml .Values.resources.kustomizeController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.kustomizeController.limits | indent 2 -}}
{{- end -}}
{{- end -}}

{{- define "resources.notificationController" -}}
requests:
{{ toYaml .Values.resources.notificationController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.notificationController.limits | indent 2 -}}
{{- end -}}
{{- end -}}

{{- define "resources.sourceController" -}}
requests:
{{ toYaml .Values.resources.sourceController.requests | indent 2 -}}
{{ if eq (include "resource.vpa.enabled" .) "false" }}
limits:
{{ toYaml .Values.resources.sourceController.limits | indent 2 -}}
{{- end -}}
{{- end -}}
42 changes: 6 additions & 36 deletions helm/flux-app/templates/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,7 @@ spec:
path: /readyz
port: healthz
resources:
limits:
cpu: {{ .Values.resources.helmController.limits.cpu }}
memory: {{ .Values.resources.helmController.limits.memory }}
requests:
cpu: {{ .Values.resources.helmController.requests.cpu }}
memory: {{ .Values.resources.helmController.requests.memory }}
{{ include "resources.helmController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down Expand Up @@ -552,12 +547,7 @@ spec:
path: /readyz
port: healthz
resources:
limits:
cpu: {{ .Values.resources.imageAutomationController.limits.cpu }}
memory: {{ .Values.resources.imageAutomationController.limits.memory }}
requests:
cpu: {{ .Values.resources.imageAutomationController.requests.cpu }}
memory: {{ .Values.resources.imageAutomationController.requests.memory }}
{{ include "resources.imageAutomationController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down Expand Up @@ -642,12 +632,7 @@ spec:
path: /readyz
port: healthz
resources:
limits:
cpu: {{ .Values.resources.imageReflectorController.limits.cpu }}
memory: {{ .Values.resources.imageReflectorController.limits.memory }}
requests:
cpu: {{ .Values.resources.imageReflectorController.requests.cpu }}
memory: {{ .Values.resources.imageReflectorController.requests.memory }}
{{ include "resources.imageReflectorController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down Expand Up @@ -736,12 +721,7 @@ spec:
path: /readyz
port: healthz
resources:
limits:
cpu: {{ .Values.resources.kustomizeController.limits.cpu }}
memory: {{ .Values.resources.kustomizeController.limits.memory }}
requests:
cpu: {{ .Values.resources.kustomizeController.requests.cpu }}
memory: {{ .Values.resources.kustomizeController.requests.memory }}
{{ include "resources.kustomizeController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down Expand Up @@ -831,12 +811,7 @@ spec:
path: /readyz
port: healthz
resources:
limits:
cpu: {{ .Values.resources.notificationController.limits.cpu }}
memory: {{ .Values.resources.notificationController.limits.memory }}
requests:
cpu: {{ .Values.resources.notificationController.requests.cpu }}
memory: {{ .Values.resources.notificationController.requests.memory }}
{{ include "resources.notificationController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down Expand Up @@ -930,12 +905,7 @@ spec:
path: /
port: http
resources:
limits:
cpu: {{ .Values.resources.sourceController.limits.cpu }}
memory: {{ .Values.resources.sourceController.limits.memory }}
requests:
cpu: {{ .Values.resources.sourceController.requests.cpu }}
memory: {{ .Values.resources.sourceController.requests.memory }}
{{ include "resources.sourceController" . | indent 12 }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down
10 changes: 10 additions & 0 deletions helm/flux-app/templates/vpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
containerPolicies:
- containerName: manager
controlledValues: RequestsAndLimits
maxAllowed:
memory: {{ .Values.resources.imageAutomationController.limits.memory }}
mode: Auto
targetRef:
apiVersion: apps/v1
Expand All @@ -52,6 +54,8 @@ spec:
containerPolicies:
- containerName: manager
controlledValues: RequestsAndLimits
maxAllowed:
memory: {{ .Values.resources.imageReflectionController.limits.memory }}
mode: Auto
targetRef:
apiVersion: apps/v1
Expand All @@ -72,6 +76,8 @@ spec:
containerPolicies:
- containerName: manager
controlledValues: RequestsAndLimits
maxAllowed:
memory: {{ .Values.resources.kustomizeController.limits.memory }}
mode: Auto
targetRef:
apiVersion: apps/v1
Expand All @@ -90,6 +96,8 @@ spec:
containerPolicies:
- containerName: manager
controlledValues: RequestsAndLimits
maxAllowed:
memory: {{ .Values.resources.notificationController.limits.memory }}
mode: Auto
targetRef:
apiVersion: apps/v1
Expand All @@ -110,6 +118,8 @@ spec:
containerPolicies:
- containerName: manager
controlledValues: RequestsAndLimits
maxAllowed:
memory: {{ .Values.resources.sourceController.limits.memory }}
mode: Auto
targetRef:
apiVersion: apps/v1
Expand Down

0 comments on commit 9bb147e

Please sign in to comment.