matrix-rtc: add option to simplify networking configuration

This commit is contained in:
Gaël Goinvic committed 2025-09-15 15:50:27 +02:00
1 parent 758c847ba0
commit 0ceeaa02ca
15 files changed
+165 -24

No files matched your search

@@ -0,0 +1,7 @@
# Copyright 2025 New Vector Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
matrixRTC:
sfu:
manualIP: 198.51.100.2
@@ -0,0 +1,7 @@
# Copyright 2025 New Vector Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
matrixRTC:
sfu:
useStunToDiscoverPublicIP: false
@@ -0,0 +1,32 @@
# Copyright 2024-2025 New Vector Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
#
# source_fragments: matrix-rtc-host-mode.yaml matrix-rtc-manual-ip.yaml matrix-rtc-minimal.yaml
# DO NOT EDIT DIRECTLY. Edit the fragment files to add / modify / remove values
# initSecrets, postgres don't have any required properties to be set and defaults to enabled
deploymentMarkers:
enabled: false
elementWeb:
enabled: false
matrixAuthenticationService:
enabled: false
matrixRTC:
ingress:
host: mrtc.ess.localhost
sfu:
exposedServices:
rtcMuxedUdp:
portType: HostPort
rtcTcp:
portType: HostPort
rtcUdp:
enabled: true
portType: HostPort
hostNetwork: true
manualIP: 198.51.100.2
synapse:
enabled: false
wellKnownDelegation:
enabled: false
@@ -0,0 +1,32 @@
# Copyright 2024-2025 New Vector Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
#
# source_fragments: matrix-rtc-host-mode.yaml matrix-rtc-minimal.yaml matrix-rtc-no-stun.yaml
# DO NOT EDIT DIRECTLY. Edit the fragment files to add / modify / remove values
# initSecrets, postgres don't have any required properties to be set and defaults to enabled
deploymentMarkers:
enabled: false
elementWeb:
enabled: false
matrixAuthenticationService:
enabled: false
matrixRTC:
ingress:
host: mrtc.ess.localhost
sfu:
exposedServices:
rtcMuxedUdp:
portType: HostPort
rtcTcp:
portType: HostPort
rtcUdp:
enabled: true
portType: HostPort
hostNetwork: true
useStunToDiscoverPublicIP: false
synapse:
enabled: false
wellKnownDelegation:
enabled: false
@@ -23,6 +23,16 @@ logging:
# WebRTC configuration
rtc:
use_external_ip: {{ .useStunToDiscoverPublicIP }}
{{- if .manualIP }}
# To workaround https://github.com/livekit/livekit/issues/2088
# Any IP address is acceptable, it doesn't need to be a correct one,
# it just needs to be present to get LiveKit to skip checking all local interfaces
# We assign here a TEST-NET IP which is
# overridden by the NODE_IP env var at runtime
node_ip: 198.51.100.1
{{- end }}
{{- with .exposedServices }}
{{- with .rtcTcp }}
{{- if .enabled }}
@@ -7,9 +7,6 @@ SPDX-License-Identifier: AGPL-3.0-only
{{- $root := .root -}}
{{- with required "matrix-rtc/sfu/config.yaml.tpl missing context" .context -}}
rtc:
use_external_ip: true
# turn server
turn:
enabled: false
@@ -122,6 +122,12 @@
"hostNetwork": {
"type": "boolean"
},
"useStunToDiscoverPublicIP": {
"type": "boolean"
},
"manualIP": {
"type": "string"
},
"additional": {
"$ref": "file://common/additional.json"
},
@@ -43,6 +43,12 @@ replicas: 1
sfu:
enabled: true
# Use STUN to resolve the server public IP
useStunToDiscoverPublicIP: true
# Specify a manual IP address for the server public IP
manualIP: ""
# LiveKit Logging level
logging:
# log level, valid values: debug, info, warn, error
@@ -34,6 +34,16 @@ env: []
{{- $root := .root -}}
{{- with required "element-io.matrix-rtc-sfu.renderConfigOverrideEnv missing context" .context -}}
env:
{{- with .manualIP }}
- name: NODE_IP
value: "{{ . }}"
{{- end }}
{{- if and (not .useStunToDiscoverPublicIP) (not .manualIP) }}
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{- end }}
- name: "LIVEKIT_KEY"
value: "{{ (.livekitAuth).key | default "matrix-rtc" }}"
- name: LIVEKIT_SECRET
+6
View File
@@ -1615,6 +1615,12 @@
"hostNetwork": {
"type": "boolean"
},
"useStunToDiscoverPublicIP": {
"type": "boolean"
},
"manualIP": {
"type": "string"
},
"additional": {
"type": "object",
"additionalProperties": {
+6
View File
@@ -644,6 +644,12 @@ matrixRTC:
sfu:
enabled: true
# Use STUN to resolve the server public IP
useStunToDiscoverPublicIP: true
# Specify a manual IP address for the server public IP
manualIP: ""
# LiveKit Logging level
logging:
# log level, valid values: debug, info, warn, error
+38 -3
View File
@@ -87,7 +87,7 @@ Element Web configuration is written in JSON. The documentation can be found in
To configure Element Web, create a values file with the JSON config to inject as a string under “additional”:
```
```yml
elementWeb:
additional:
user-config.json: |
@@ -100,7 +100,7 @@ elementWeb:
Synapse configuration is written in YAML. The documentation can be found [here](https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html).
```
```yml
synapse:
additional:
user-config.yaml:
@@ -113,7 +113,7 @@ synapse:
Matrix Authentication Service configuration is written in YAML. The documentation can be found [here](https://element-hq.github.io/matrix-authentication-service/reference/configuration.html).
```
```yml
matrixAuthenticationService:
additional:
user-config.yaml:
@@ -121,3 +121,38 @@ matrixAuthenticationService:
# Add your settings below, taking care of the spacing indentation
some: settings
```
### Configuring Matrix RTC
Matrix RTC SFU configuration is written in YAML. The documentation can be found [here](https://docs.livekit.io/home/self-hosting/deployment/).
```yml
matrixRTC:
sfu:
additional:
user-config.yaml:
config: |
# Add your settings below, taking care of the spacing indentation
some: settings
```
#### Networking
Matrix RTC SFU will by default advertise the IP resolved after a STUN Request to the Google STUN Servers.
If you want to disable this behaviour, set `useStunToDiscoverPublicIP` to `false` :
```yml
matrixRTC:
sfu:
useStunToDiscoverPublicIP: false
```
Without STUN, Matrix RTC will advertise the Host IP as the publicly reachable IP. If your host is behind NAT,
you can configured a manual IP address for the server public IP by setting `manualIP`:
```yml
matrixRTC:
sfu:
manualIP: "<your node public IP>"
```
+1
View File
@@ -0,0 +1 @@
MatrixRTC: Add `sfu.useStunToDiscoverPublicIP` and `sfu.manualIP` values to simplify networking configuration.
-18
View File
@@ -25,24 +25,6 @@ async def test_log_level_overrides(values, make_templates):
raise RuntimeError("Could not find config-overrides.yaml")
@pytest.mark.parametrize("values_file", ["matrix-rtc-minimal-values.yaml"])
@pytest.mark.asyncio_cooperative
async def test_external_ip_underrides(values, make_templates):
for template in await make_templates(values):
if (
template["kind"] == "ConfigMap"
and "matrix-rtc-sfu" in template["metadata"]["name"]
and "config-underrides.yaml" in template["data"]
):
log_yaml = yaml.safe_load(template["data"]["config-underrides.yaml"])
use_external_ip = log_yaml["rtc"]["use_external_ip"]
assert type(use_external_ip) is bool
assert use_external_ip
break
else:
raise RuntimeError("Could not find config-underrides.yaml")
async def get_sfu_udp_port_range_services(start_port, end_point, values, make_templates):
values["matrixRTC"]["sfu"]["exposedServices"]["rtcUdp"]["portRange"]["startPort"] = start_port
values["matrixRTC"]["sfu"]["exposedServices"]["rtcUdp"]["portRange"]["endPort"] = end_point
+4
View File
@@ -37,6 +37,8 @@ async def test_sets_extra_env(values, make_templates):
)
for env in container.get("env", []):
if "valueFrom" in env:
continue
assert type(env["value"]) is str, (
f"{template_id(template)} has container {container['name']} "
f"which has an non-string value: {env}"
@@ -96,6 +98,8 @@ async def test_built_in_env_cant_be_overwritten(values, make_templates):
# containers each setting different env vars. We'll have provided a 'from-user' env var override
# for all of those env vars and so 'from-user' will legitimately be present on some containers
if env_var["name"] in env_keys_from_chart:
if "valueFrom" in env_var:
continue
assert env_var["value"] != "from-user", (
f"{template_id(template)}/{container['name']} allowed env var "
f"{env_var['name']} to be overwritten"