feat(seaweedfs): backport Gateway API HTTPRoutes for s3 and filer

Moving the platform's tenant ingress to Gateway API needs a route
object for the S3 endpoint and the filer. Upstream added them after
4.48 and first shipped them in 4.49; this package stays on 4.48, so
they arrive here as a patch that `make update` applies until the chart
moves to a release that carries them. Both stay off by default, so the
rendered release is unchanged; nothing is switched to Gateway API by
this change.

Adapted from upstream commit 68af030e381f ("helm: add Gateway API
HTTPRoute for master, volume, filer, s3 and admin"):

- The s3 route's default backend is `<name>-s3` instead of
  componentName, the name s3-service-name.patch gives the Service.
  Upstream's form diverges from the real Service whenever the
  fullname differs from seaweedfs.name, the chart name unless
  nameOverride is set.
- Only the s3 and filer routes and their values blocks are taken; the
  master, volume and admin routes, the README section and the CI
  workflow change are left out.

With security enabled and no httpsPort, the standalone s3 gateway
serves TLS on its main port (s3-tls-main-port.patch), so a Gateway
sending plaintext to the default backend needs a BackendTLSPolicy
alongside the route.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-19 19:30:23 +03:00
1 parent c87fcffb21
commit bdbf1ca810
6 files changed
+514

No files matched your search

+1
View File
@@ -62,6 +62,7 @@ update:
patch --no-backup-if-mismatch -p4 < patches/s3-service-name-consumers.patch
patch --no-backup-if-mismatch -p4 < patches/cluster-scoped-names-per-namespace.patch
patch --forward --no-backup-if-mismatch -p4 < patches/storage-class-string.patch
patch --forward --no-backup-if-mismatch -p4 < patches/httproute-backport.patch
#patch --no-backup-if-mismatch -p4 < patches/retention-policy-delete.yaml
$(MAKE) update-image
@@ -0,0 +1,57 @@
{{- $filerEnabled := or .Values.filer.enabled .Values.allInOne.enabled }}
{{- if and $filerEnabled .Values.filer.httpRoute.enabled }}
{{- $serviceName := ternary (include "seaweedfs.componentName" (list . "all-in-one")) (include "seaweedfs.componentName" (list . "filer")) .Values.allInOne.enabled }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ include "seaweedfs.componentName" (list . "filer") }}
namespace: {{ .Release.Namespace }}
{{- with .Values.filer.httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: filer
{{- with .Values.filer.httpRoute.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.filer.httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.filer.httpRoute.hostnames }}
hostnames:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range .Values.filer.httpRoute.rules | default (list dict) }}
- backendRefs:
{{- with .backendRefs }}
{{- toYaml . | nindent 8 }}
{{- else }}
- group: ""
kind: Service
name: {{ $serviceName }}
namespace: {{ $.Release.Namespace }}
port: {{ $.Values.filer.port }}
weight: 1
{{- end }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .timeouts }}
timeouts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,64 @@
{{- $s3Enabled := or .Values.s3.enabled (and .Values.filer.s3.enabled (not .Values.allInOne.enabled)) (and .Values.allInOne.enabled .Values.allInOne.s3.enabled) }}
{{- if and $s3Enabled .Values.s3.httpRoute.enabled }}
{{- $serviceName := printf "%s-s3" (include "seaweedfs.name" .) }}
{{- $s3Port := .Values.filer.s3.port }}
{{- if and .Values.allInOne.enabled .Values.allInOne.s3.enabled }}
{{- $serviceName = include "seaweedfs.componentName" (list . "all-in-one") }}
{{- $s3Port = .Values.allInOne.s3.port | default .Values.s3.port }}
{{- else if .Values.s3.enabled }}
{{- $s3Port = .Values.s3.port }}
{{- end }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ include "seaweedfs.componentName" (list . "s3") }}
namespace: {{ .Release.Namespace }}
{{- with .Values.s3.httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: s3
{{- with .Values.s3.httpRoute.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.s3.httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.s3.httpRoute.hostnames }}
hostnames:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range .Values.s3.httpRoute.rules | default (list dict) }}
- backendRefs:
{{- with .backendRefs }}
{{- toYaml . | nindent 8 }}
{{- else }}
- group: ""
kind: Service
name: {{ $serviceName }}
namespace: {{ $.Release.Namespace }}
port: {{ $s3Port }}
weight: 1
{{- end }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .timeouts }}
timeouts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -903,6 +903,24 @@ filer:
# requires ingress-nginx to run with --enable-ssl-passthrough.
tls: []
# Gateway API HTTPRoute, an alternative to the ingress above.
httpRoute:
enabled: false
labels: {}
annotations: {}
# Gateways this route attaches to, for example:
# - group: gateway.networking.k8s.io
# kind: Gateway
# name: my-gateway
# namespace: gateway-system
# sectionName: https
parentRefs: []
hostnames: []
# Each rule may set matches, filters, timeouts and backendRefs.
# A rule without backendRefs routes to the filer service.
# An empty list routes all traffic there.
rules: []
# extraEnvVars is a list of extra environment variables to set with the stateful set.
extraEnvironmentVars:
# the WEED_MYSQL_* keys and the db credential secret only render while this is "true"
@@ -1195,6 +1213,27 @@ s3:
annotations: {}
tls: []
# Gateway API HTTPRoute, an alternative to the ingress above.
# With global.seaweedfs.enableSecurity and no httpsPort, the standalone s3
# gateway (s3.enabled) serves TLS on s3.port, so the Gateway also needs a
# BackendTLSPolicy for the s3 Service, which this chart does not render.
httpRoute:
enabled: false
labels: {}
annotations: {}
# Gateways this route attaches to, for example:
# - group: gateway.networking.k8s.io
# kind: Gateway
# name: my-gateway
# namespace: gateway-system
# sectionName: https
parentRefs: []
hostnames: []
# Each rule may set matches, filters, timeouts and backendRefs.
# A rule without backendRefs routes to the s3 service.
# An empty list routes all traffic there.
rules: []
# Service settings
service:
type: ClusterIP
@@ -0,0 +1,204 @@
Backport of the s3 and filer HTTPRoutes from upstream seaweedfs commit
68af030e381f, which no release carried when this patch was written.
Drop this patch and its Makefile line when bumping to the first
seaweedfs release that contains 68af030e381f (expected 4.49 or later):
it creates both templates, so `make update` fails on it once upstream
ships them. Before dropping it, carry over the two deliberate
differences: the s3 route's default backendRef here targets the renamed
`<name>-s3` Service from s3-service-name.patch, where upstream uses
componentName, so that line moves into s3-service-name-consumers.patch;
and the BackendTLSPolicy note on s3.httpRoute, which belongs with
s3-tls-main-port.patch.
Upstream's master, volume and admin routes were not backported.
diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml
new file mode 100644
index 000000000..e655c1c19
--- /dev/null
+++ b/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml
@@ -0,0 +1,57 @@
+{{- $filerEnabled := or .Values.filer.enabled .Values.allInOne.enabled }}
+{{- if and $filerEnabled .Values.filer.httpRoute.enabled }}
+{{- $serviceName := ternary (include "seaweedfs.componentName" (list . "all-in-one")) (include "seaweedfs.componentName" (list . "filer")) .Values.allInOne.enabled }}
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ include "seaweedfs.componentName" (list . "filer") }}
+ namespace: {{ .Release.Namespace }}
+ {{- with .Values.filer.httpRoute.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ labels:
+ app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ app.kubernetes.io/component: filer
+ {{- with .Values.filer.httpRoute.labels }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- with .Values.filer.httpRoute.parentRefs }}
+ parentRefs:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.filer.httpRoute.hostnames }}
+ hostnames:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ rules:
+ {{- range .Values.filer.httpRoute.rules | default (list dict) }}
+ - backendRefs:
+ {{- with .backendRefs }}
+ {{- toYaml . | nindent 8 }}
+ {{- else }}
+ - group: ""
+ kind: Service
+ name: {{ $serviceName }}
+ namespace: {{ $.Release.Namespace }}
+ port: {{ $.Values.filer.port }}
+ weight: 1
+ {{- end }}
+ {{- with .matches }}
+ matches:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .filters }}
+ filters:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .timeouts }}
+ timeouts:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml
new file mode 100644
index 000000000..4d8afee3c
--- /dev/null
+++ b/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml
@@ -0,0 +1,64 @@
+{{- $s3Enabled := or .Values.s3.enabled (and .Values.filer.s3.enabled (not .Values.allInOne.enabled)) (and .Values.allInOne.enabled .Values.allInOne.s3.enabled) }}
+{{- if and $s3Enabled .Values.s3.httpRoute.enabled }}
+{{- $serviceName := printf "%s-s3" (include "seaweedfs.name" .) }}
+{{- $s3Port := .Values.filer.s3.port }}
+{{- if and .Values.allInOne.enabled .Values.allInOne.s3.enabled }}
+{{- $serviceName = include "seaweedfs.componentName" (list . "all-in-one") }}
+{{- $s3Port = .Values.allInOne.s3.port | default .Values.s3.port }}
+{{- else if .Values.s3.enabled }}
+{{- $s3Port = .Values.s3.port }}
+{{- end }}
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ include "seaweedfs.componentName" (list . "s3") }}
+ namespace: {{ .Release.Namespace }}
+ {{- with .Values.s3.httpRoute.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ labels:
+ app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ app.kubernetes.io/component: s3
+ {{- with .Values.s3.httpRoute.labels }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- with .Values.s3.httpRoute.parentRefs }}
+ parentRefs:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.s3.httpRoute.hostnames }}
+ hostnames:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ rules:
+ {{- range .Values.s3.httpRoute.rules | default (list dict) }}
+ - backendRefs:
+ {{- with .backendRefs }}
+ {{- toYaml . | nindent 8 }}
+ {{- else }}
+ - group: ""
+ kind: Service
+ name: {{ $serviceName }}
+ namespace: {{ $.Release.Namespace }}
+ port: {{ $s3Port }}
+ weight: 1
+ {{- end }}
+ {{- with .matches }}
+ matches:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .filters }}
+ filters:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .timeouts }}
+ timeouts:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/packages/system/seaweedfs/charts/seaweedfs/values.yaml b/packages/system/seaweedfs/charts/seaweedfs/values.yaml
index 5b8a8c2e5..3a188323b 100644
--- a/packages/system/seaweedfs/charts/seaweedfs/values.yaml
+++ b/packages/system/seaweedfs/charts/seaweedfs/values.yaml
@@ -903,6 +903,24 @@ filer:
# requires ingress-nginx to run with --enable-ssl-passthrough.
tls: []
+ # Gateway API HTTPRoute, an alternative to the ingress above.
+ httpRoute:
+ enabled: false
+ labels: {}
+ annotations: {}
+ # Gateways this route attaches to, for example:
+ # - group: gateway.networking.k8s.io
+ # kind: Gateway
+ # name: my-gateway
+ # namespace: gateway-system
+ # sectionName: https
+ parentRefs: []
+ hostnames: []
+ # Each rule may set matches, filters, timeouts and backendRefs.
+ # A rule without backendRefs routes to the filer service.
+ # An empty list routes all traffic there.
+ rules: []
+
# extraEnvVars is a list of extra environment variables to set with the stateful set.
extraEnvironmentVars:
# the WEED_MYSQL_* keys and the db credential secret only render while this is "true"
@@ -1195,6 +1213,27 @@ s3:
annotations: {}
tls: []
+ # Gateway API HTTPRoute, an alternative to the ingress above.
+ # With global.seaweedfs.enableSecurity and no httpsPort, the standalone s3
+ # gateway (s3.enabled) serves TLS on s3.port, so the Gateway also needs a
+ # BackendTLSPolicy for the s3 Service, which this chart does not render.
+ httpRoute:
+ enabled: false
+ labels: {}
+ annotations: {}
+ # Gateways this route attaches to, for example:
+ # - group: gateway.networking.k8s.io
+ # kind: Gateway
+ # name: my-gateway
+ # namespace: gateway-system
+ # sectionName: https
+ parentRefs: []
+ hostnames: []
+ # Each rule may set matches, filters, timeouts and backendRefs.
+ # A rule without backendRefs routes to the s3 service.
+ # An empty list routes all traffic there.
+ rules: []
+
# Service settings
service:
type: ClusterIP
@@ -0,0 +1,149 @@
suite: seaweedfs Gateway API HTTPRoutes
# The routes come from patches/httproute-backport.patch. Its s3 route names
# the backend <name>-s3, as s3-service-name.patch names the Service. Upstream
# uses componentName (<fullname>-s3) there, which renders the same name while
# fullnameOverride equals the chart name, so the routing cases override it to
# make upstream's form render a different name and fail.
templates:
- charts/seaweedfs/templates/s3/s3-httproute.yaml
- charts/seaweedfs/templates/s3/s3-service.yaml
- charts/seaweedfs/templates/filer/filer-httproute.yaml
- charts/seaweedfs/templates/filer/filer-service.yaml
release:
name: seaweedfs-system
namespace: cozy-seaweedfs
tests:
- it: renders no s3 route by default
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
asserts:
- hasDocuments:
count: 0
- it: renders no filer route by default
template: charts/seaweedfs/templates/filer/filer-httproute.yaml
asserts:
- hasDocuments:
count: 0
- it: s3 route targets the renamed s3 service on the s3 port
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.filer.s3.port: 8334
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.parentRefs:
- name: gw
namespace: gateway-system
seaweedfs.s3.httpRoute.hostnames:
- s3.example.com
asserts:
- isKind:
of: HTTPRoute
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8333
- equal:
path: spec.parentRefs[0].name
value: gw
- equal:
path: spec.hostnames[0]
value: s3.example.com
- it: the s3 service it targets is the one the chart renders
template: charts/seaweedfs/templates/s3/s3-service.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
asserts:
- equal:
path: metadata.name
value: seaweedfs-s3
- it: s3 route on a filer-embedded gateway targets the renamed service on the filer s3 port
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.enabled: false
seaweedfs.filer.s3.enabled: true
seaweedfs.filer.s3.port: 8334
seaweedfs.s3.httpRoute.enabled: true
asserts:
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8334
- it: filer route targets the filer service on the filer port
template: charts/seaweedfs/templates/filer/filer-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.filer.httpRoute.enabled: true
asserts:
- isKind:
of: HTTPRoute
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-system-filer
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8888
- it: the filer service it targets is the one the chart renders
template: charts/seaweedfs/templates/filer/filer-service.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
asserts:
- equal:
path: metadata.name
value: seaweedfs-system-filer
- it: an s3 rule without backendRefs keeps its matches and routes to the s3 service
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.rules:
- matches:
- path:
type: PathPrefix
value: /bucket
asserts:
- lengthEqual:
path: spec.rules
count: 1
- equal:
path: spec.rules[0].matches[0].path.value
value: /bucket
- equal:
path: spec.rules[0].backendRefs
value:
- group: ""
kind: Service
name: seaweedfs-s3
namespace: cozy-seaweedfs
port: 8333
weight: 1
- it: an empty s3 rule list renders one catch-all rule to the s3 service
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.rules: []
asserts:
- lengthEqual:
path: spec.rules
count: 1
- notExists:
path: spec.rules[0].matches
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3