mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
helm: reload S3 identities with a SIGHUP sidecar instead of restarting (#12945)
* helm: reload S3 identities with a SIGHUP sidecar instead of restarting The chart restarts the filer and S3 pods when the content of existingConfigSecret changes, so every identity change briefly takes S3 down, completely so with a single filer. SeaweedFS reloads the identities file on SIGHUP. filer.s3.configReloader and s3.configReloader, off by default, add an s3-config-reloader sidecar that sends SIGHUP to SeaweedFS when kubelet updates the mounted file, turn on shareProcessNamespace, and stop hashing the existing Secret into checksum/s3config. The sidecar uses the component's image and container security context, so it runs as the same user as SeaweedFS, and it logs a warning when it cannot signal it. * helm: address review of the S3 config reloader - Default the configReloader map to dict, so a release upgraded with --reuse-values from a chart without it still renders. - With the reloader and existingConfigSecret, leave checksum/s3config off the pod, so values of the Secret the chart generates cannot restart it. - README: the restart comes from the next Helm upgrade, the timing holds for the kubelet's default settings, and a reload re-creates the KMS providers, which replaces the in-memory keys of the local provider. * helm: describe Secret propagation as eventually consistent Kubernetes gives no bound on when a Secret volume is updated, so the README gives typical delays instead, and says a revoked identity keeps working until then.
This commit is contained in:
1 parent
fe816eaac8
commit
85fcde9b0d
6 files changed
+180
-2
No files matched your search
@@ -162,6 +162,50 @@ jobs:
|
||||
done
|
||||
echo "shareProcessNamespace renders correctly"
|
||||
|
||||
echo "=== Testing the S3 config reloader ==="
|
||||
for workload in filer.s3:templates/filer/filer-statefulset.yaml s3:templates/s3/s3-deployment.yaml; do
|
||||
prefix=${workload%%:*}
|
||||
template=${workload#*:}
|
||||
component=${prefix%%.*}
|
||||
reloader_args=(--set "$prefix.enabled=true" --set "$prefix.enableAuth=true"
|
||||
--set "$prefix.existingConfigSecret=s3-identities"
|
||||
--set "$component.containerSecurityContext.enabled=true"
|
||||
--set "$component.containerSecurityContext.runAsUser=1000")
|
||||
helm template test $CHART_DIR --show-only "$template" "${reloader_args[@]}" > /tmp/reloader-off.yaml
|
||||
test "$(grep -c 's3-config-reloader\|shareProcessNamespace' /tmp/reloader-off.yaml)" -eq 0
|
||||
helm template test $CHART_DIR --show-only "$template" "${reloader_args[@]}" \
|
||||
--set "$prefix.configReloader.enabled=true" \
|
||||
--set "$prefix.configReloader.resources.limits.memory=32Mi" > /tmp/reloader-on.yaml
|
||||
python3 - /tmp/reloader-off.yaml /tmp/reloader-on.yaml <<'PYEOF'
|
||||
import sys, yaml
|
||||
off, on = (yaml.safe_load(open(path)) for path in sys.argv[1:])
|
||||
pod = on["spec"]["template"]["spec"]
|
||||
main = pod["containers"][0]
|
||||
reloader = next(c for c in pod["containers"] if c["name"] == "s3-config-reloader")
|
||||
assert pod["shareProcessNamespace"] is True
|
||||
assert reloader["image"] == main["image"]
|
||||
# It must run as the same user as SeaweedFS to signal it.
|
||||
assert reloader["securityContext"] == main["securityContext"], reloader.get("securityContext")
|
||||
assert {"name": "config-users", "mountPath": "/etc/sw", "readOnly": True} in reloader["volumeMounts"]
|
||||
assert reloader["resources"] == {"limits": {"memory": "32Mi"}}
|
||||
# Without the reloader, the checksum hashes the existing Secret, so a change to it restarts the pod.
|
||||
# With it, nothing may: not the Secret, and not the values of the Secret the chart generates.
|
||||
annotations = lambda d: d["spec"]["template"]["metadata"].get("annotations") or {}
|
||||
assert "checksum/s3config" in annotations(off)
|
||||
assert "checksum/s3config" not in annotations(on), annotations(on)
|
||||
PYEOF
|
||||
# A release from a chart without configReloader, upgraded with --reuse-values, has no such map.
|
||||
helm template test $CHART_DIR --show-only "$template" "${reloader_args[@]}" \
|
||||
--set "$prefix.configReloader=null" > /tmp/reloader-old-values.yaml
|
||||
test "$(grep -c 's3-config-reloader' /tmp/reloader-old-values.yaml)" -eq 0
|
||||
if helm template test $CHART_DIR --show-only "$template" \
|
||||
--set "$prefix.enabled=true" --set "$prefix.configReloader.enabled=true" > /tmp/reloader-noauth.yaml 2>&1; then
|
||||
echo "FAIL: $prefix.configReloader rendered without $prefix.enableAuth"; exit 1
|
||||
fi
|
||||
grep -q "configReloader.enabled needs" /tmp/reloader-noauth.yaml
|
||||
done
|
||||
echo "S3 config reloader renders correctly"
|
||||
|
||||
echo "=== Testing the S3 config checksum is stable across renders ==="
|
||||
# s3-secret.yaml keeps its generated keys with lookup. Hashing the rendered
|
||||
# Secret drew new keys for the checksum whenever lookup found nothing (on
|
||||
|
||||
Reference in new issue
Block a user