Skip to content

Commit

Permalink
fix: resource overrides in nginx-php templates
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Nov 23, 2023
1 parent ab2e6d1 commit 73fbe04
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
14 changes: 14 additions & 0 deletions legacy/helmcharts/nginx-php-persistent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,17 @@ Generate path for twig storage emptyDir
{{- define "nginx-php-persistent.twig-storage.path" -}}
{{- printf "%s/php" .Values.persistentStorage.path }}
{{- end -}}
{{/*
Merge resources from global over resources defined in the values
*/}}
{{- define "resources" -}}
{{- $value := dict -}}
{{- range (rest .) -}}
{{- $value = merge $value . -}}
{{- end -}}
{{- if $value -}}
{{- printf "%s:" (first .) }}
{{- toYaml $value | nindent 2 }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ spec:
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources.nginx | nindent 12 }}

{{- include "resources" (list "resources" .Values.resources .Values.containerResources.nginx) | nindent 12 }}
- image: {{ .Values.images.php | quote }}
name: "php"
imagePullPolicy: {{ .Values.imagePullPolicy }}
Expand Down Expand Up @@ -146,7 +145,7 @@ spec:
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources.php | nindent 12 }}
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.php ) | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 3 additions & 1 deletion legacy/helmcharts/nginx-php-persistent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fastly:
# serviceId: ''
# apiSecretName: ''

resources:
containerResources:
nginx:
# limits:
# cpu: 100m
Expand All @@ -56,6 +56,8 @@ resources:
cpu: 10m
memory: 100Mi

resources: {}

nodeSelector: {}

cronjobNodeSelector: {}
Expand Down
14 changes: 14 additions & 0 deletions legacy/helmcharts/nginx-php/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,17 @@ lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }}
lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }}
{{- end }}
{{- end -}}

{{/*
Merge resources from global over resources defined in the values
*/}}
{{- define "resources" -}}
{{- $value := dict -}}
{{- range (rest .) -}}
{{- $value = merge $value . -}}
{{- end -}}
{{- if $value -}}
{{- printf "%s:" (first .) }}
{{- toYaml $value | nindent 2 }}
{{- end }}
{{- end -}}
4 changes: 2 additions & 2 deletions legacy/helmcharts/nginx-php/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- configMapRef:
name: lagoon-env
resources:
{{- toYaml .Values.resources.nginx | nindent 12 }}
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.nginx ) | nindent 12 }}
{{- if .Values.dynamicSecretMounts }}
volumeMounts:
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
Expand Down Expand Up @@ -105,7 +105,7 @@ spec:
- name: NGINX_FASTCGI_PASS
value: '127.0.0.1'
resources:
{{- toYaml .Values.resources.php | nindent 12 }}
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.php ) | nindent 12 }}
{{- if .Values.dynamicSecretMounts }}
volumeMounts:
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
Expand Down
4 changes: 3 additions & 1 deletion legacy/helmcharts/nginx-php/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fastly:
# serviceId: ''
# apiSecretName: ''

resources:
containerResources:
nginx:
# limits:
# cpu: 100m
Expand All @@ -53,6 +53,8 @@ resources:
cpu: 10m
memory: 100Mi

resources: {}

nodeSelector: {}

cronjobNodeSelector: {}
Expand Down

0 comments on commit 73fbe04

Please sign in to comment.