Browse Source
helm: avoid duplicate env var keys in workload env lists (#8488)
* helm: dedupe merged extraEnvironmentVars in workloads
* address comments
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* range
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* helm: reuse merge helper for extraEnvironmentVars
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pull/3961/merge
Chris Lu
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with
44 additions and
112 deletions
-
k8s/charts/seaweedfs/templates/admin/admin-statefulset.yaml
-
k8s/charts/seaweedfs/templates/cosi/cosi-deployment.yaml
-
k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml
-
k8s/charts/seaweedfs/templates/master/master-statefulset.yaml
-
k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml
-
k8s/charts/seaweedfs/templates/sftp/sftp-deployment.yaml
-
k8s/charts/seaweedfs/templates/shared/_helpers.tpl
-
k8s/charts/seaweedfs/templates/volume/volume-statefulset.yaml
-
k8s/charts/seaweedfs/templates/worker/worker-deployment.yaml
|
|
|
@ -118,8 +118,10 @@ spec: |
|
|
|
fieldPath: metadata.namespace |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.admin.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.admin.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.admin "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -128,18 +130,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|
|
|
|
@ -96,8 +96,10 @@ spec: |
|
|
|
- name: WEED_GRPC_CA |
|
|
|
value: /usr/local/share/ca-certificates/client/ca.crt |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.cosi.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.cosi.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.cosi "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -106,18 +108,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
volumeMounts: |
|
|
|
- mountPath: /var/lib/cosi |
|
|
|
name: socket |
|
|
|
|
|
|
|
@ -114,8 +114,10 @@ spec: |
|
|
|
optional: true |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.filer.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.filer.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.filer "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -124,18 +126,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.filer.secretExtraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.filer.secretExtraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
|
|
|
|
@ -98,8 +98,10 @@ spec: |
|
|
|
fieldPath: metadata.namespace |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.master.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.master.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.master "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -108,18 +110,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|
|
|
|
@ -90,8 +90,10 @@ spec: |
|
|
|
fieldPath: metadata.namespace |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.s3.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.s3.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.s3 "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -100,18 +102,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|
|
|
|
@ -90,8 +90,10 @@ spec: |
|
|
|
fieldPath: metadata.namespace |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.sftp.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.sftp.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.sftp "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -100,18 +102,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|
|
|
|
@ -59,6 +59,18 @@ Inject extra environment vars in the format key:value, if populated |
|
|
|
{{- end -}} |
|
|
|
{{- end -}} |
|
|
|
|
|
|
|
{{- define "seaweedfs.mergeExtraEnvironmentVars" -}} |
|
|
|
{{- $global := ((.global | default dict).extraEnvironmentVars | default dict) -}} |
|
|
|
{{- $component := ((.component | default dict).extraEnvironmentVars | default dict) -}} |
|
|
|
{{- $target := .target -}} |
|
|
|
{{- range $key, $value := $global }} |
|
|
|
{{- $_ := set $target $key $value }} |
|
|
|
{{- end }} |
|
|
|
{{- range $key, $value := $component }} |
|
|
|
{{- $_ := set $target $key $value }} |
|
|
|
{{- end }} |
|
|
|
{{- end -}} |
|
|
|
|
|
|
|
{{/* Return the proper filer image */}} |
|
|
|
{{- define "filer.image" -}} |
|
|
|
{{- if .Values.filer.imageOverride -}} |
|
|
|
|
|
|
|
@ -118,8 +118,10 @@ spec: |
|
|
|
fieldPath: status.hostIP |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" $ }}" |
|
|
|
{{- if $volume.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := $volume.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" $.Values.global "component" $volume "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -128,18 +130,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if $.Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := $.Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|
|
|
|
@ -93,8 +93,10 @@ spec: |
|
|
|
fieldPath: metadata.namespace |
|
|
|
- name: SEAWEEDFS_FULLNAME |
|
|
|
value: "{{ include "seaweedfs.fullname" . }}" |
|
|
|
{{- if .Values.worker.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.worker.extraEnvironmentVars }} |
|
|
|
{{- $mergedExtraEnvironmentVars := dict }} |
|
|
|
{{- include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global "component" .Values.worker "target" $mergedExtraEnvironmentVars) }} |
|
|
|
{{- range $key := keys $mergedExtraEnvironmentVars | sortAlpha }} |
|
|
|
{{- $value := index $mergedExtraEnvironmentVars $key }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
@ -103,18 +105,6 @@ spec: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
{{- if .Values.global.extraEnvironmentVars }} |
|
|
|
{{- range $key, $value := .Values.global.extraEnvironmentVars }} |
|
|
|
- name: {{ $key }} |
|
|
|
{{- if kindIs "string" $value }} |
|
|
|
value: {{ tpl $value $ | quote }} |
|
|
|
{{- else }} |
|
|
|
valueFrom: |
|
|
|
{{ toYaml $value | nindent 16 | trim }} |
|
|
|
{{- end -}} |
|
|
|
{{- end }} |
|
|
|
{{- end }} |
|
|
|
command: |
|
|
|
- "/bin/sh" |
|
|
|
- "-ec" |
|
|
|
|