diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-09-09 08:48:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-09 08:48:34 -0700 |
| commit | 8ed1b104cea39856a51b67d31c6782031c89f642 (patch) | |
| tree | 4d8f7ee4fdc0e557f0fe0d7e7ff2cc9730327b3f | |
| parent | b3a401d9f9da02fa45f96c838caf48773d5ea177 (diff) | |
| download | seaweedfs-8ed1b104cea39856a51b67d31c6782031c89f642.tar.xz seaweedfs-8ed1b104cea39856a51b67d31c6782031c89f642.zip | |
WEED_CLUSTER_SW_* Environment Variables should not be passed to allIn… (#7217)
* WEED_CLUSTER_SW_* Environment Variables should not be passed to allInOne config
* address comment
* address comments
Fixed filtering logic: Replaced specific key matching with regex patterns that catch ALL WEED_CLUSTER_*_MASTER and WEED_CLUSTER_*_FILER variables:
}
Corrected merge precedence: Fixed the merge order so global environment variables properly override allInOne variables:
* refactoring
| -rw-r--r-- | k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml | 15 | ||||
| -rw-r--r-- | k8s/charts/seaweedfs/templates/shared/_helpers.tpl | 24 |
2 files changed, 39 insertions, 0 deletions
diff --git a/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml b/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml index 86bb45a8e..8700a8a69 100644 --- a/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml +++ b/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml @@ -79,6 +79,12 @@ spec: image: {{ template "master.image" . }} imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }} env: + {{- /* Determine default cluster alias and the corresponding env var keys to avoid conflicts */}} + {{- $envMerged := merge (.Values.global.extraEnvironmentVars | default dict) (.Values.allInOne.extraEnvironmentVars | default dict) }} + {{- $clusterDefault := default "sw" (index $envMerged "WEED_CLUSTER_DEFAULT") }} + {{- $clusterUpper := upper $clusterDefault }} + {{- $clusterMasterKey := printf "WEED_CLUSTER_%s_MASTER" $clusterUpper }} + {{- $clusterFilerKey := printf "WEED_CLUSTER_%s_FILER" $clusterUpper }} - name: POD_IP valueFrom: fieldRef: @@ -95,6 +101,7 @@ spec: value: "{{ template "seaweedfs.name" . }}" {{- if .Values.allInOne.extraEnvironmentVars }} {{- range $key, $value := .Values.allInOne.extraEnvironmentVars }} + {{- if and (ne $key $clusterMasterKey) (ne $key $clusterFilerKey) }} - name: {{ $key }} {{- if kindIs "string" $value }} value: {{ $value | quote }} @@ -104,8 +111,10 @@ spec: {{- end }} {{- end }} {{- end }} + {{- end }} {{- if .Values.global.extraEnvironmentVars }} {{- range $key, $value := .Values.global.extraEnvironmentVars }} + {{- if and (ne $key $clusterMasterKey) (ne $key $clusterFilerKey) }} - name: {{ $key }} {{- if kindIs "string" $value }} value: {{ $value | quote }} @@ -115,6 +124,12 @@ spec: {{- end }} {{- end }} {{- end }} + {{- end }} + # Inject computed cluster endpoints for the default cluster + - name: {{ $clusterMasterKey }} + value: {{ include "seaweedfs.cluster.masterAddress" . | quote }} + - name: {{ $clusterFilerKey }} + value: {{ include "seaweedfs.cluster.filerAddress" . | quote }} command: - "/bin/sh" - "-ec" diff --git a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl b/k8s/charts/seaweedfs/templates/shared/_helpers.tpl index 404981976..d22d14224 100644 --- a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl +++ b/k8s/charts/seaweedfs/templates/shared/_helpers.tpl @@ -222,3 +222,27 @@ or generate a new random password if it doesn't exist. {{- randAlphaNum $length -}} {{- end -}} {{- end -}} + +{{/* +Compute the master service address to be used in cluster env vars. +If allInOne is enabled, point to the all-in-one service; otherwise, point to the master service. +*/}} +{{- define "seaweedfs.cluster.masterAddress" -}} +{{- $serviceNameSuffix := "-master" -}} +{{- if .Values.allInOne.enabled -}} +{{- $serviceNameSuffix = "-all-in-one" -}} +{{- end -}} +{{- printf "%s%s.%s:%d" (include "seaweedfs.name" .) $serviceNameSuffix .Release.Namespace (int .Values.master.port) -}} +{{- end -}} + +{{/* +Compute the filer service address to be used in cluster env vars. +If allInOne is enabled, point to the all-in-one service; otherwise, point to the filer-client service. +*/}} +{{- define "seaweedfs.cluster.filerAddress" -}} +{{- $serviceNameSuffix := "-filer-client" -}} +{{- if .Values.allInOne.enabled -}} +{{- $serviceNameSuffix = "-all-in-one" -}} +{{- end -}} +{{- printf "%s%s.%s:%d" (include "seaweedfs.name" .) $serviceNameSuffix .Release.Namespace (int .Values.filer.port) -}} +{{- end -}} |
