Skip to content

Commit 8dd9616

Browse files
Fixes github issue 1070: Helm chart not applying resources.limits.memory to operator's deployment
Co-authored-by: Etienne Divet <[email protected]>
1 parent 767c4af commit 8dd9616

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

helm/trident-operator/templates/_helpers.tpl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,38 @@ Helper functions to check if resources are actually defined (not just empty stru
379379
{{- end -}}
380380
{{- if $hasResources -}}true{{- end -}}
381381
{{- end -}}
382+
383+
{{/*
384+
Helper function to check if operator resources are defined
385+
*/}}
386+
{{- define "trident-operator.hasResources" -}}
387+
{{- $val := . -}}
388+
{{- if or $val.requests.cpu $val.requests.memory $val.limits.cpu $val.limits.memory -}}
389+
true
390+
{{- end -}}
391+
{{- end -}}
392+
393+
{{/*
394+
Helper function to render resource requests and limits for the operator
395+
*/}}
396+
{{- define "trident-operator.resources" }}
397+
{{- $val := .}}
398+
{{- if or $val.requests.cpu $val.requests.memory }}
399+
requests:
400+
{{- if $val.requests.cpu }}
401+
cpu: {{ $val.requests.cpu }}
402+
{{- end }}
403+
{{- if $val.requests.memory }}
404+
memory: {{ $val.requests.memory }}
405+
{{- end }}
406+
{{- end }}
407+
{{- if or $val.limits.cpu $val.limits.memory }}
408+
limits:
409+
{{- if $val.limits.cpu }}
410+
cpu: {{ $val.limits.cpu }}
411+
{{- end }}
412+
{{- if $val.limits.memory }}
413+
memory: {{ $val.limits.memory }}
414+
{{- end }}
415+
{{- end }}
416+
{{- end -}}

helm/trident-operator/templates/deployment.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,10 @@ spec:
6969
image: {{ include "trident-operator.image" $ }}
7070
imagePullPolicy: {{ .Values.imagePullPolicy }}
7171
name: trident-operator
72+
{{- if (include "trident-operator.hasResources" .Values.resources.operator) }}
7273
resources:
73-
requests:
74-
cpu: {{ .Values.resources.operator.requests.cpu }}
75-
memory: {{ .Values.resources.operator.requests.memory }}
76-
{{- if .Values.resources.operator.limits.cpu }}
77-
limits:
78-
cpu: {{ .Values.resources.operator.limits.cpu }}
79-
memory: {{ .Values.resources.operator.limits.memory }}
80-
{{- end }}
74+
{{- include "trident-operator.resources" .Values.resources.operator | indent 10 }}
75+
{{- end }}
8176
{{- if and (eq .Values.cloudProvider "Azure") (eq .Values.cloudIdentity "") }}
8277
volumes:
8378
- name: azure-cred

0 commit comments

Comments
 (0)