SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
helm: decouple JWT signing from cert-manager mTLS (fixes #9506) (#9508)
Chris Lu2ed95d7ea936
diff --git a/.github/workflows/helm_ci.yml b/.github/workflows/helm_ci.ymlindex 0bc8318e30..60001a6d18 100644--- a/.github/workflows/helm_ci.yml+++ b/.github/workflows/helm_ci.yml@@ -68,6 +68,135 @@ jobs:grep -q "security-config" /tmp/security.yamlecho "✓ Security configuration renders correctly"+ echo ""+ echo "=== Testing IAM gRPC opt-in path ==="+ # Regression test: the filer registers the IAM gRPC service the+ # Admin UI Users tab calls only when jwt.filer_signing.key is in+ # security.toml. Operators must be able to enable that without+ # the cert-manager mTLS bundle.+ # Install PyYAML explicitly: this block runs before the later+ # security+S3 block that does the same install, and we don't+ # want to rely on the runner image shipping it.+ pip install pyyaml -q+ python3 - "$CHART_DIR" <<'PYEOF'+ import subprocess, sys, yaml+ chart = sys.argv[1]++ def render(values):+ args = ["helm", "template", "test", chart]+ for k, v in values.items():+ args += ["--set", f"{k}={v}"]+ return subprocess.check_output(args, text=True)++ def docs(manifest):+ return [d for d in yaml.safe_load_all(manifest) if d]++ def configmap(manifest, name):+ for d in docs(manifest):+ if d.get("kind") == "ConfigMap" and d["metadata"]["name"] == name:+ return d+ return None++ def workload_mounts(manifest, name):+ for d in docs(manifest):+ if d.get("kind") not in ("Deployment", "StatefulSet"):+ continue+ if d["metadata"]["name"] != name:+ continue+ pod = d["spec"]["template"]["spec"]+ vols = {v["name"] for v in pod.get("volumes", [])}+ mounts = set()+ for c in pod.get("containers", []):+ for vm in c.get("volumeMounts", []):+ mounts.add(vm["name"])+ return vols, mounts+ return None, None++ failed = []++ # Case 1: defaults. The chart historically rendered nothing+ # security-related; preserve that so this PR is non-breaking on+ # existing installs.+ out = render({})+ if configmap(out, "test-seaweedfs-security-config") is not None:+ failed.append("defaults: security ConfigMap should not render")+ else:+ print("✓ defaults: no security-config ConfigMap (unchanged)")++ # Case 2: filerWrite=true alone is the documented opt-in for+ # the Admin UI Users tab. Configmap must render with+ # [jwt.filer_signing] and NO [grpc.*] sections (cert paths+ # only exist with mTLS).+ out = render({+ "global.seaweedfs.securityConfig.jwtSigning.filerWrite": "true",+ "admin.enabled": "true",+ })+ cm = configmap(out, "test-seaweedfs-security-config")+ if cm is None:+ failed.append("filerWrite=true: security ConfigMap missing")+ else:+ toml = cm["data"]["security.toml"]+ if "[jwt.filer_signing]" not in toml:+ failed.append("filerWrite=true: security.toml missing [jwt.filer_signing]")+ if "[grpc" in toml:+ failed.append("filerWrite=true: security.toml unexpectedly has [grpc.*] (would need cert mounts)")+ if "[jwt.filer_signing]" in toml and "[grpc" not in toml:+ print("✓ filerWrite=true: security.toml has [jwt.filer_signing], no [grpc.*]")++ # Case 3: filer + admin pods must MOUNT the security ConfigMap+ # under filerWrite=true so the JWT key reaches both processes.+ # Cert volumes must NOT be present (no mTLS).+ for wl in ("test-seaweedfs-filer", "test-seaweedfs-admin"):+ vols, mounts = workload_mounts(out, wl)+ if vols is None:+ failed.append(f"filerWrite=true: workload {wl} not found")+ continue+ if "security-config" not in vols or "security-config" not in mounts:+ failed.append(f"filerWrite=true: {wl} does not mount security-config (IAM gRPC would still fail)")+ else:+ print(f"✓ filerWrite=true: {wl} mounts security-config")+ cert_vols = {v for v in vols if v.endswith("-cert")}+ if cert_vols:+ failed.append(f"filerWrite=true: {wl} unexpectedly has cert volumes {sorted(cert_vols)}")++ # Case 4: enableSecurity=true must still render the full toml+ # with both [jwt.signing] and [grpc.*]. Guards against the+ # decoupling change accidentally regressing the mTLS path.+ out = render({"global.seaweedfs.enableSecurity": "true"})+ cm = configmap(out, "test-seaweedfs-security-config")+ if cm is None:+ failed.append("enableSecurity=true: security ConfigMap missing")+ else:+ toml = cm["data"]["security.toml"]+ missing = [s for s in ("[jwt.signing]", "[grpc.master]") if s not in toml]+ if missing:+ failed.append(f"enableSecurity=true: security.toml missing {missing}")+ else:+ print("✓ enableSecurity=true: security.toml has [jwt.signing] + [grpc.*] preserved")++ # Case 5: helper must tolerate explicit nulls (gemini-code-assist+ # PR review). securityConfig=null was the parens-pattern crash+ # the helper review caught.+ for null_path in ("global.seaweedfs.securityConfig",+ "global.seaweedfs.securityConfig.jwtSigning"):+ try:+ out = render({null_path: "null"})+ except subprocess.CalledProcessError as e:+ failed.append(f"{null_path}=null: render failed: {e.output[:200] if e.output else e}")+ continue+ if configmap(out, "test-seaweedfs-security-config") is not None:+ failed.append(f"{null_path}=null: should not render configmap")+ else:+ print(f"✓ {null_path}=null: render tolerates explicit null")++ if failed:+ print("\nFAIL:", file=sys.stderr)+ for f in failed:+ print(f" - {f}", file=sys.stderr)+ sys.exit(1)+ PYEOF+ echo "✓ IAM gRPC decoupling tests passed"+echo "=== Testing with monitoring enabled ==="helm template test $CHART_DIR \--set global.seaweedfs.monitoring.enabled=true \diff --git a/k8s/charts/seaweedfs/Chart.yaml b/k8s/charts/seaweedfs/Chart.yamlindex 82cc0bde0d..2da5c50465 100644--- a/k8s/charts/seaweedfs/Chart.yaml+++ b/k8s/charts/seaweedfs/Chart.yaml@@ -3,4 +3,4 @@ description: SeaweedFSname: seaweedfsappVersion: "4.25"# Dev note: Trigger a helm chart release by `git tag -a helm-<version>`-version: 4.25.0+version: 4.25.1diff --git a/k8s/charts/seaweedfs/templates/admin/admin-statefulset.yaml b/k8s/charts/seaweedfs/templates/admin/admin-statefulset.yamlindex 88c170a9de..63955f7968 100644--- a/k8s/charts/seaweedfs/templates/admin/admin-statefulset.yaml+++ b/k8s/charts/seaweedfs/templates/admin/admin-statefulset.yaml@@ -180,11 +180,13 @@ spec:- name: admin-logsmountPath: /logs{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -275,10 +277,12 @@ spec:persistentVolumeClaim:claimName: {{ .Values.admin.logs.claimName }}{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --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.yamlindex 3b4d7a4052..b0d1fc784a 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@@ -330,11 +330,13 @@ spec:mountPath: /etc/seaweedfs/master.tomlsubPath: master.tomlreadOnly: true- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configmountPath: /etc/seaweedfs/security.tomlsubPath: security.tomlreadOnly: true+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certmountPath: /usr/local/share/ca-certificates/ca/readOnly: true@@ -461,10 +463,12 @@ spec:- name: master-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-master-config- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/cosi/cosi-deployment.yaml b/k8s/charts/seaweedfs/templates/cosi/cosi-deployment.yamlindex ffeccd2a30..aefc9d369f 100644--- a/k8s/charts/seaweedfs/templates/cosi/cosi-deployment.yaml+++ b/k8s/charts/seaweedfs/templates/cosi/cosi-deployment.yaml@@ -117,11 +117,13 @@ spec:name: config-usersreadOnly: true{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -179,10 +181,12 @@ spec:secretName: {{ include "seaweedfs.fullname" . }}-s3-secret{{- end }}{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml b/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yamlindex 89e8666c30..691d1cf4fe 100644--- a/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml+++ b/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml@@ -234,11 +234,13 @@ spec:mountPath: /etc/seaweedfs/notification.tomlsubPath: notification.toml{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -274,7 +276,8 @@ spec:name: swfs-s3-tls{{- end }}{{- end }}- {{- $isJwtEnabled := or .Values.global.seaweedfs.securityConfig.jwtSigning.filerWrite .Values.global.seaweedfs.securityConfig.jwtSigning.filerRead }}+ {{- $jwt := (.Values.global.seaweedfs.securityConfig).jwtSigning | default dict }}+ {{- $isJwtEnabled := or $jwt.filerWrite $jwt.filerRead }}{{- if .Values.filer.readinessProbe.enabled }}readinessProbe:{{- if or $isJwtEnabled .Values.filer.readinessProbe.tcpSocket }}@@ -368,10 +371,12 @@ spec:configMap:name: {{ include "seaweedfs.fullname" . }}-notification-config{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml b/k8s/charts/seaweedfs/templates/master/master-statefulset.yamlindex 536928125b..21e2bada5f 100644--- a/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml+++ b/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml@@ -188,11 +188,13 @@ spec:readOnly: truemountPath: /etc/seaweedfs/master.tomlsubPath: master.toml- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -287,10 +289,12 @@ spec:- name: master-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-master-config- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml b/k8s/charts/seaweedfs/templates/s3/s3-deployment.yamlindex 0fe5374b3d..db231fc965 100644--- a/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml+++ b/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml@@ -156,11 +156,13 @@ spec:name: config-usersreadOnly: true{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -249,10 +251,12 @@ spec:- name: logsemptyDir: {}{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/sftp/sftp-deployment.yaml b/k8s/charts/seaweedfs/templates/sftp/sftp-deployment.yamlindex 356fc7dbea..46bb322070 100644--- a/k8s/charts/seaweedfs/templates/sftp/sftp-deployment.yaml+++ b/k8s/charts/seaweedfs/templates/sftp/sftp-deployment.yaml@@ -176,11 +176,13 @@ spec:- mountPath: /etc/sw/sshname: config-sshreadOnly: true- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -264,10 +266,12 @@ spec:- name: logsemptyDir: {}{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl b/k8s/charts/seaweedfs/templates/shared/_helpers.tplindex 0576b1487f..1fa92a0c11 100644--- a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl+++ b/k8s/charts/seaweedfs/templates/shared/_helpers.tpl@@ -332,6 +332,16 @@ Create the name of the service account to use{{- .Values.global.seaweedfs.serviceAccountName | default "seaweedfs" -}}{{- end -}}+{{/* True when security.toml should be rendered and mounted. volumeWrite is+ excluded since it defaults to true. */}}+{{- define "seaweedfs.securityConfigEnabled" -}}+{{- $sec := (.Values.global.seaweedfs).securityConfig | default dict -}}+{{- $jwt := $sec.jwtSigning | default dict -}}+{{- if or .Values.global.seaweedfs.enableSecurity $jwt.volumeRead $jwt.filerWrite $jwt.filerRead -}}+true+{{- end -}}+{{- end -}}+{{/* S3 TLS cert/key arguments, using custom secret if s3.tlsSecret is set */}}{{- define "seaweedfs.s3.tlsArgs" -}}{{- $prefix := .prefix -}}diff --git a/k8s/charts/seaweedfs/templates/shared/security-configmap.yaml b/k8s/charts/seaweedfs/templates/shared/security-configmap.yamlindex 667ed8533d..8b9486e136 100644--- a/k8s/charts/seaweedfs/templates/shared/security-configmap.yaml+++ b/k8s/charts/seaweedfs/templates/shared/security-configmap.yaml@@ -1,5 +1,5 @@{{- include "seaweedfs.compat" . -}}-{{- if .Values.global.seaweedfs.enableSecurity }}+{{- if include "seaweedfs.securityConfigEnabled" . }}apiVersion: v1kind: ConfigMapmetadata:@@ -55,6 +55,7 @@ data:key = "{{ dig "jwt" "filer_signing" "read" "key" (randAlphaNum 10 | b64enc) $securityConfig }}"{{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}# all grpc tls authentications are mutual# the values for the following ca, cert, and key are paths to the PERM files.[grpc]@@ -94,4 +95,5 @@ data:[https.volume]cert = ""key = ""+ {{- end }}{{- end }}diff --git a/k8s/charts/seaweedfs/templates/volume/volume-statefulset.yaml b/k8s/charts/seaweedfs/templates/volume/volume-statefulset.yamlindex 231f28ce12..4b70d7f71b 100644--- a/k8s/charts/seaweedfs/templates/volume/volume-statefulset.yaml+++ b/k8s/charts/seaweedfs/templates/volume/volume-statefulset.yaml@@ -211,11 +211,13 @@ spec:- name: idxmountPath: "/idx/"{{- end }}- {{- if $.Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" $ }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if $.Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -333,10 +335,12 @@ spec:emptyDir: {}{{- end }}{{- end }}- {{- if $.Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" $ }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" $ }}-security-config+ {{- end }}+ {{- if $.Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" $ }}-ca-certdiff --git a/k8s/charts/seaweedfs/templates/worker/worker-deployment.yaml b/k8s/charts/seaweedfs/templates/worker/worker-deployment.yamlindex bf49095df6..1b9d80099d 100644--- a/k8s/charts/seaweedfs/templates/worker/worker-deployment.yaml+++ b/k8s/charts/seaweedfs/templates/worker/worker-deployment.yaml@@ -149,11 +149,13 @@ spec:- name: worker-logsmountPath: /logs{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configreadOnly: truemountPath: /etc/seaweedfs/security.tomlsubPath: security.toml+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certreadOnly: truemountPath: /usr/local/share/ca-certificates/ca/@@ -252,10 +254,12 @@ spec:persistentVolumeClaim:claimName: {{ .Values.worker.logs.claimName }}{{- end }}- {{- if .Values.global.seaweedfs.enableSecurity }}+ {{- if include "seaweedfs.securityConfigEnabled" . }}- name: security-configconfigMap:name: {{ include "seaweedfs.fullname" . }}-security-config+ {{- end }}+ {{- if .Values.global.seaweedfs.enableSecurity }}- name: ca-certsecret:secretName: {{ include "seaweedfs.fullname" . }}-ca-certdiff --git a/k8s/charts/seaweedfs/values.yaml b/k8s/charts/seaweedfs/values.yamlindex c54fb81e6c..4b76c408be 100644--- a/k8s/charts/seaweedfs/values.yaml+++ b/k8s/charts/seaweedfs/values.yaml@@ -18,6 +18,8 @@ global:loggingLevel: 1enableSecurity: falsemasterServer: null+ # filerWrite: true mounts security.toml on filer + admin without needing+ # enableSecurity (mTLS); required for the Admin UI Users tab.securityConfig:jwtSigning:volumeWrite: true