feat(matrix-synapse): Gateway-API as an alternative to the Ingress
Group 3 of the #114 sweep. TWO HTTPRoutes - and the shape is not the one the issue described. #114 says this chart renders its Ingresses in a LOOP OVER SEVERAL APPS. It does not; that is freesailarr. It renders ONE Ingress object with TWO HOST rules: the homeserver on ingress.domain at "/", and the delegation nginx on matrix.delegation.serverUrl at "/.well-known/matrix". An HTTPRoute's spec.hostnames applies to the WHOLE object, so two hostnames that want different paths and different backends have to be two objects. That is the only faithful translation, not a stylistic choice. httpRoute.delegation.hostnames deliberately does NOT fall back to httpRoute.hostnames. The server name is what REMOTE homeservers resolve and is a different thing from the homeserver's own hostname; the migration order - homeserver host first, server name last - depends on telling them apart, and a chart-global hostname list covering both would erase the distinction. httpRoute.delegation.parentRefs falls back to httpRoute.parentRefs, which matters because the server name is usually an apex domain behind a different Gateway. ONE THING THIS MODE IMPROVES, and it is the awkward part of Matrix delegation. Under ingress-nginx two Ingress objects cannot both claim one hostname - the admission webhook rejects the second - which is why the delegation rule has to live inside this chart's single Ingress object even though the apex domain usually belongs to a website. HTTPRoutes attached to the same listener for the same hostname are merged by the implementation, longest match winning, so the /.well-known/matrix route can sit beside whatever owns that apex. WHAT THIS MODE DROPS, MEASURED ON THE LIVE OBJECT ON 2026-10-12 - and ONE OF THE TWO IS NOT WHAT IT LOOKS LIKE. The live Ingress carried, all of it operator-supplied through ingress.annotations (this chart sets none of it): nginx.ingress.kubernetes.io/proxy-body-size: 50m nginx.org/client-max-body-size: 50m nginx.ingress.kubernetes.io/configuration-snippet: | more_set_headers "X-Forwarded-For $remote_addr"; more_set_headers "X-Forwarded-Proto $scheme"; more_set_headers "Host $host:$server_port"; 1. THE BODY SIZE IS THE REAL LOSS. Synapse's media repository takes uploads; its own ceiling is max_upload_size in homeserver.yaml, which this chart cannot see because the whole config arrives from 1Password. The effective limit is the smaller of the two, and in this mode the proxy half becomes the GATEWAY'S default - neither number anyone can point at is necessarily the one that decides. No counterpart in the Gateway API, so per decision 2 of #114 it is documented, not rebuilt. nginx.org/client-max-body-size is the same limit spelled for NGINX Inc's controller, a hedge across both implementations, and it goes for the same reason. (#114's own measured table did not list matrix-synapse under proxy-body-size at all; the live object has it.) 2. THE SNIPPET IS NOT LOAD-BEARING, which took checking rather than assuming. It looks like what Synapse's x_forwarded setting depends on - client IP for rate limiting, and federation. It is not: more_set_headers is the headers-more module's OUTPUT-header directive ("Replaces (if any) or adds (if not any) the specified output headers"), the request-side directive being more_set_input_headers. So those three headers are added to the RESPONSE TO THE CLIENT; Synapse never sees them, and what it reads with x_forwarded: true is the REQUEST's X-Forwarded-For, which ingress-nginx supplies itself. The Gateway API's ResponseHeaderModifier could not rebuild it anyway (it knows no nginx variables), and should not: NOTES.txt says in as many words not to re-create it and not to read its absence as the cause of a rate-limiting or federation problem. Stated as what it is - a reading of the directive's documented semantics. Nothing here observed a Synapse instance with and without the snippet. NOTES.txt now asks $published (ingress.enabled OR httpRoute.enabled) wherever it used to ask ingress.enabled - the server-name/serverUrl mismatch warning, the "clients work fine" aside and the scaled-to-zero paragraph were all really asking whether anything publishes the release. Minor: additive, defaults unchanged. Empty helm template diff against origin/main with ci/matrix-synapse/test-values.yaml. Part of #114
This commit is contained in:
1 parent
9625d8b182
commit
e54cfe5fdd
6 files changed
+569
-17
No files matched your search
@@ -1,5 +1,29 @@
|
||||
{{- /*
|
||||
NOTHING IN CI READS THIS FILE. `helm template` does not emit notes and no
|
||||
workflow or script under ci/ reads it, so every claim below carries
|
||||
review-only assurance - it is checked by being read, not by a stage. A
|
||||
rendering ERROR here does fail `helm template`, which is all the pipeline can
|
||||
see of it.
|
||||
*/ -}}
|
||||
{{- $replicas := include "matrix-synapse.replicas" (dict "scaleDown" .Values.scaleDown "replicas" .Values.matrix.replicas) -}}
|
||||
{{- $delegation := .Values.matrix.delegation | default dict -}}
|
||||
{{- $httpRoute := .Values.httpRoute | default dict -}}
|
||||
{{- $httpRouteDelegation := $httpRoute.delegation | default dict -}}
|
||||
{{- /*
|
||||
"Published" rather than "has an Ingress": the two modes are alternatives, and
|
||||
every paragraph below that used to ask ingress.enabled was really asking
|
||||
whether anything publishes this release. Gitea #114, and the sure.publishedOverTls
|
||||
/ freesailarr.published shape.
|
||||
*/ -}}
|
||||
{{- $published := or .Values.ingress.enabled $httpRoute.enabled -}}
|
||||
{{- $hostnames := $httpRoute.hostnames | default list -}}
|
||||
{{- if not $hostnames -}}
|
||||
{{- $hostnames = list .Values.ingress.domain -}}
|
||||
{{- end -}}
|
||||
{{- $delegationHostnames := $httpRouteDelegation.hostnames | default list -}}
|
||||
{{- if not $delegationHostnames -}}
|
||||
{{- $delegationHostnames = list $delegation.serverUrl -}}
|
||||
{{- end -}}
|
||||
{{- $delegationReplicas := include "matrix-synapse.replicas" (dict "scaleDown" .Values.scaleDown "replicas" $delegation.replicas) -}}
|
||||
{{- $res := fromYaml (include "matrix-synapse.effectiveResources" .Values.matrix.resources) -}}
|
||||
{{- $eph := index ($res.limits | default dict) "ephemeral-storage" | default "the computed ephemeral-storage limit" -}}
|
||||
@@ -14,7 +38,7 @@ Matrix Synapse {{ .Chart.AppVersion }} — release {{ .Release.Name }} in namesp
|
||||
|
||||
{{- if .Values.ingress.enabled }}
|
||||
|
||||
ACCESS
|
||||
ACCESS — INGRESS MODE (ingress.enabled: true, httpRoute.enabled: false)
|
||||
https://{{ .Values.ingress.domain }}
|
||||
|
||||
That host carries the whole client and federation API: the Ingress sends "/"
|
||||
@@ -24,11 +48,96 @@ ACCESS
|
||||
shows a warning and federation fails. Follow it with
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} get certificate tls-{{ .Release.Name }}-{{ .Chart.Name }}-ingress
|
||||
{{- else if $httpRoute.enabled }}
|
||||
|
||||
ACCESS — GATEWAY MODE (httpRoute.enabled: true, ingress.enabled: false)
|
||||
{{- range $hostnames }}
|
||||
https://{{ . }}
|
||||
{{- end }}
|
||||
|
||||
That host carries the whole client and federation API: the HTTPRoute sends
|
||||
"/" on it to the Synapse Service, which forwards port 80 to the container's
|
||||
8008.
|
||||
|
||||
THIS RELEASE RENDERS {{ if $delegation.enabled }}TWO HTTPRoutes{{ else }}ONE HTTPRoute{{ end }} AND NOTHING ELSE of the routing
|
||||
path — no Gateway, no class, no Certificate, no policy object.
|
||||
|
||||
{{ .Release.Name }}-{{ .Chart.Name }}-httproute {{ join ", " $hostnames }}
|
||||
{{- if $delegation.enabled }}
|
||||
{{ .Release.Name }}-{{ .Chart.Name }}-delegation-httproute {{ join ", " $delegationHostnames }}
|
||||
{{- end }}
|
||||
|
||||
Three things therefore belong to the cluster, and if any is missing the
|
||||
hostname does not answer — which for Matrix means federation is down, not
|
||||
just the web client:
|
||||
|
||||
1. The Gateway-API CRDs. Without them this install would have failed, so
|
||||
they are present — nothing to check.
|
||||
2. The Gateway(s) named in parentRefs
|
||||
{{- range $httpRoute.parentRefs }}
|
||||
{{ .name }}{{ if .namespace }} in namespace {{ .namespace }}{{ end }}{{ if .sectionName }}, listener {{ .sectionName }}{{ end }} (homeserver)
|
||||
{{- end }}
|
||||
{{- if $delegation.enabled }}
|
||||
{{- range ($httpRouteDelegation.parentRefs | default $httpRoute.parentRefs) }}
|
||||
{{ .name }}{{ if .namespace }} in namespace {{ .namespace }}{{ end }}{{ if .sectionName }}, listener {{ .sectionName }}{{ end }} (delegation)
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
must exist AND their listeners must allow routes from this namespace
|
||||
({{ .Release.Namespace }}) in allowedRoutes. A rejected attachment is visible only
|
||||
in the route's status:
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} get httproute {{ .Release.Name }}-{{ .Chart.Name }}-httproute -o yaml
|
||||
|
||||
Read status.parents[].conditions — "Accepted: True" and
|
||||
"ResolvedRefs: True" is what a working attachment looks like. An empty
|
||||
status means no controller has looked at the route at all.
|
||||
3. {{ if $delegation.enabled }}The TLS certificates — one per hostname, on the Gateway's listeners,
|
||||
or one wildcard listener covering both{{ else }}The TLS certificate for the hostname, on the Gateway's listener{{ end }}.
|
||||
ingress.clusterIssuer is NOT used in this mode and is not required: the
|
||||
chart renders no Certificate here, so there is no
|
||||
tls-{{ .Release.Name }}-{{ .Chart.Name }}-ingress secret{{ if $delegation.enabled }} and no
|
||||
tls-{{ .Release.Name }}-{{ .Chart.Name }}-delegation secret{{ end }} and nothing for
|
||||
cert-manager to do for this release. MATRIX FEDERATION IS HTTPS-ONLY,
|
||||
so a listener without a valid certificate for these names is a
|
||||
federation outage that no probe in this release can see.
|
||||
|
||||
THE UPLOAD LIMIT IS NOT ENFORCED BY ANYTHING THIS CHART RENDERS.
|
||||
|
||||
In Ingress mode an operator sets
|
||||
nginx.ingress.kubernetes.io/proxy-body-size through ingress.annotations —
|
||||
this installation runs with 50m — because Synapse's media repository takes
|
||||
uploads and nginx's default of 1m rejects nearly all of them. IN THIS MODE
|
||||
THAT IS GONE: the Gateway API has no body-size field, it is implementation
|
||||
policy rather than routing, and this chart renders no policy object on
|
||||
purpose (it would bind the chart to one Gateway implementation).
|
||||
|
||||
The ceiling in force is the smaller of max_upload_size in your
|
||||
homeserver.yaml — which this chart cannot see, it comes from 1Password —
|
||||
and whatever the GATEWAY enforces. Neither number anyone can point at is
|
||||
necessarily the one that decides. Set the Gateway's half, in your
|
||||
implementation's own object, to match max_upload_size, BEFORE you point DNS
|
||||
at it.
|
||||
|
||||
AND ONE THING NOT TO RE-CREATE. The live Ingress also carries a
|
||||
configuration-snippet of three more_set_headers directives
|
||||
(X-Forwarded-For $remote_addr, X-Forwarded-Proto $scheme, Host). It LOOKS
|
||||
like what Synapse's x_forwarded setting depends on. It is not:
|
||||
more_set_headers is the headers-more module's OUTPUT-header directive, so
|
||||
those three headers go on the RESPONSE TO THE CLIENT and Synapse never sees
|
||||
them. What Synapse reads with x_forwarded: true is the REQUEST's
|
||||
X-Forwarded-For, which the proxy supplies by itself. Do not spend effort
|
||||
rebuilding this at the Gateway, and do not read its absence as the cause of
|
||||
a rate-limiting or federation problem. (This is a reading of the directive's
|
||||
documented semantics; nothing here A/B-tested a Synapse instance.)
|
||||
|
||||
ingress.annotations is inert in this mode in general: the Gateway API has no
|
||||
annotation channel for controller behaviour.
|
||||
{{- else }}
|
||||
|
||||
ACCESS — NO INGRESS
|
||||
ingress.enabled is false, so this release has no Ingress and no certificate;
|
||||
ingress.clusterIssuer is not needed.
|
||||
ACCESS — NEITHER INGRESS NOR HTTPROUTE
|
||||
ingress.enabled and httpRoute.enabled are both false, so this release has no
|
||||
Ingress, no HTTPRoute and no certificate; ingress.clusterIssuer is not
|
||||
needed.
|
||||
{{- if $delegation.enabled }}
|
||||
ingress.domain still is: the delegation nginx renders it into the
|
||||
/.well-known/matrix/* documents, so it stays the host every other Matrix
|
||||
@@ -56,10 +165,10 @@ DELEGATION — TWO HOSTNAMES THAT ARE NOT INTERCHANGEABLE
|
||||
→ {"m.server": "{{ .Values.ingress.domain }}:443"}
|
||||
/.well-known/matrix/client
|
||||
→ {"m.homeserver": {"base_url": "https://{{ .Values.ingress.domain }}"}}
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- if $published }}
|
||||
|
||||
The Ingress publishes them on a SECOND host. Read that split carefully,
|
||||
because the chart cannot check it for you:
|
||||
{{ if $httpRoute.enabled }}A SECOND HTTPRoute publishes{{ else }}The Ingress publishes{{ end }} them on a SECOND host. Read that split
|
||||
carefully, because the chart cannot check it for you:
|
||||
|
||||
matrix.delegation.serverUrl ({{ $delegation.serverUrl }})
|
||||
is the DELEGATING host — the domain in every user ID (@user:{{ $delegation.serverUrl }}).
|
||||
@@ -69,18 +178,36 @@ DELEGATION — TWO HOSTNAMES THAT ARE NOT INTERCHANGEABLE
|
||||
is where Synapse actually answers. It appears inside the documents
|
||||
above and needs no relation to the server name.
|
||||
|
||||
Only the path /.well-known/matrix is routed to nginx on {{ $delegation.serverUrl }};
|
||||
everything else on that host is not served by this release. Both hosts need
|
||||
Only the path /.well-known/matrix is routed to nginx on {{ join ", " $delegationHostnames }};
|
||||
everything else on that host is not served by this release.
|
||||
{{- if $httpRoute.enabled }}
|
||||
|
||||
AND THAT CO-EXISTENCE IS EASIER HERE THAN IT WAS. The server name is usually
|
||||
an apex domain that already serves a website, and under ingress-nginx two
|
||||
Ingress objects cannot both claim one hostname — the admission webhook
|
||||
rejects the second — which is why the delegation rule had to sit inside this
|
||||
chart's single Ingress object. HTTPRoutes attached to the same listener for
|
||||
the same hostname are MERGED by the implementation, longest match winning,
|
||||
so this route may sit beside whatever owns that apex without either side
|
||||
knowing about the other.
|
||||
|
||||
Both hosts need a certificate ON THE GATEWAY'S LISTENERS — this chart renders
|
||||
none in this mode — and a listener without a valid certificate for the server
|
||||
name is a federation outage, not a cosmetic problem.
|
||||
{{- else }}
|
||||
Both hosts need
|
||||
a certificate — the second one is tls-{{ .Release.Name }}-{{ .Chart.Name }}-delegation — and
|
||||
cert-manager only issues it once {{ $delegation.serverUrl }} resolves to this cluster.
|
||||
A pending certificate there is a federation outage, not a cosmetic problem.
|
||||
{{- end }}
|
||||
|
||||
Check what is actually being served, from outside the cluster:
|
||||
|
||||
curl -s https://{{ $delegation.serverUrl }}/.well-known/matrix/server
|
||||
curl -s https://{{ first $delegationHostnames }}/.well-known/matrix/server
|
||||
{{- else }}
|
||||
|
||||
Nothing publishes them, though: ingress.enabled is false, so the documents
|
||||
Nothing publishes them, though: ingress.enabled and httpRoute.enabled are
|
||||
both false, so the documents
|
||||
exist only on the in-cluster Service {{ .Release.Name }}-{{ .Chart.Name }}-delegation-service, and
|
||||
matrix.delegation.serverUrl ({{ $delegation.serverUrl }}) is rendered into no object of this
|
||||
release. Whatever terminates TLS in front of the cluster has to route
|
||||
@@ -101,7 +228,7 @@ NO DELEGATION IN THIS RELEASE — FEDERATION LIKELY DOES NOT WORK
|
||||
8448 anywhere: the container publishes 8008 only, and the Service maps port
|
||||
80 onto it. Unless the delegation is served by something else (a static
|
||||
.well-known on the server-name host, or an SRV record), federation stays
|
||||
broken{{ if .Values.ingress.enabled }} while clients on {{ .Values.ingress.domain }} work fine{{ end }}.
|
||||
broken{{ if $published }} while clients on {{ first $hostnames }} work fine{{ end }}.
|
||||
Setting matrix.delegation.enabled to true and matrix.delegation.serverUrl
|
||||
to the server name lets this chart serve it.
|
||||
{{- end }}
|
||||
@@ -120,7 +247,11 @@ SCALED TO ZERO
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
The PVC, the Secret and the Services stay in place, so no data is lost{{ if .Values.ingress.enabled }} and
|
||||
the certificates are not re-issued{{ end }}. Set it back and upgrade again to
|
||||
the certificates are not re-issued{{ else if $httpRoute.enabled }} and the
|
||||
HTTPRoutes stay in place, so the hostnames keep pointing at Services with no
|
||||
endpoints — the Gateway answers with an error of its own rather than with
|
||||
nothing, and remote homeservers see a failing .well-known instead of an
|
||||
unresolvable name{{ end }}. Set it back and upgrade again to
|
||||
return.
|
||||
{{- end }}
|
||||
|
||||
@@ -190,7 +321,7 @@ THE SERVER NAME IS DECIDED ONCE, AND NOT BY matrix.serverName
|
||||
a different name is a new server with a new database, not an upgrade. Decide
|
||||
it before the first start — together with matrix.delegation.serverUrl, which
|
||||
has to match it.
|
||||
{{- if and .Values.ingress.enabled $delegation.enabled .Values.matrix.serverName $delegation.serverUrl }}
|
||||
{{- if and $published $delegation.enabled .Values.matrix.serverName $delegation.serverUrl }}
|
||||
{{- if ne (printf "%v" .Values.matrix.serverName) (printf "%v" $delegation.serverUrl) }}
|
||||
|
||||
MISMATCH IN THIS RELEASE: matrix.serverName is "{{ .Values.matrix.serverName }}" but the
|
||||
|
||||
Reference in new issue
Block a user