Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 1 | # Matrix server (synapse). |
| 2 | # This needs a secret provisioned, create with: |
| 3 | # ns=matrix |
| 4 | # |
| 5 | # SIGNING_KEY="$(kubectl run -n $ns -i --quiet --restart=Never --rm synapse-generate-config --image=matrixdotorg/synapse:v1.19.2 --env SYNAPSE_SERVER_NAME=dummy --env SYNAPSE_REPORT_STATS=no -o yaml --command -- sh -c '/start.py generate >/dev/null && cat /data/*.signing.key')" |
| 6 | # kubectl -n $ns create secret generic synapse --from-literal=postgres_password=$(pwgen 24 1) --from-literal=macaroon_secret_key=$(pwgen 32 1) --from-literal=registration_shared_secret=$(pwgen 32 1) --from-literal=homeserver_signing_key="$SIGNING_KEY" --from-literal=redis_password=$(pwgen 32 1) --from-literal=worker_replication_secret=$(pwgen 32 1) |
| 7 | # kubectl -n $ns create secret generic oauth2-cas-proxy --from-literal=oauth2_secret=... |
| 8 | # |
| 9 | # When migrating from matrix.libsonnet, instance signing key, redis passwsord |
| 10 | # and worker replication secret need to be added to existing synapse secret: |
| 11 | # |
| 12 | # echo "homeserver_signing_key: $(kubectl -n $ns exec deploy/synapse -- sh -c 'cat /data/*.signing.key' | base64 -w0)" |
| 13 | # echo "redis_password: $(pwgen 32 1 | tr -d '\n' | base64 -w0)" |
| 14 | # echo "worker_replication_secret: $(pwgen 32 1 | tr -d '\n' | base64 -w0)" |
| 15 | # kubectl -n $ns edit secret synapse |
| 16 | # # ...add homeserver_signing_key, redis_password and worker_replication_secret keys |
| 17 | # |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 18 | # Additionally some resources need to be explicitly removed due to |
| 19 | # label/annotations changes: |
| 20 | # kubectl -n $ns delete deployment riot-web oauth2-cas-proxy wellknown synapse |
| 21 | # |
| 22 | # Some service configuration customization fields have been renamed: |
| 23 | # .riotConfig → .riot.config |
| 24 | # .synapseConfig → .synapse.config |
| 25 | # |
Piotr Dobrowolski | fb119aa | 2021-01-31 19:07:32 +0100 | [diff] [blame] | 26 | # When migrating from CAS to OpenID Connect authentication scheme following need |
| 27 | # to be ensured: |
| 28 | # * https://{homeserver}/_synapse/oidc/callback is added to allowed callback URLs list |
| 29 | # * openid scope is enabled for configured client |
| 30 | # |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 31 | # In order to deploy matrix-media-repo as a replacement for synapse built-in |
| 32 | # media workers the following steps need to be carried out: |
| 33 | # |
| 34 | # 1. Generate password and bootstrap extra postgres user |
| 35 | # pwgen 32 1 > secrets/plain/media-repo-$ns-postgres |
| 36 | # echo "create database mediarepo; create user mediarepo with password '$(cat secrets/plain/media-repo-$ns-postgres)'; grant all privileges on database mediarepo to mediarepo;" | kubectl -n $ns exec -it deploy/waw3-postgres psql |
| 37 | # secretstore sync secrets |
| 38 | # |
| 39 | # 2. Fetch Ceph RGW credentials |
| 40 | # kubectl get secrets -n ceph-waw3 rook-ceph-object-user-waw-hdd-redundant-3-object-$ns -o json | jq '.data|map_values(@base64d)' > secrets/plain/media-repo-$ns-ceph.json |
| 41 | # secretstore sync secrets |
| 42 | # |
| 43 | # 3. Create an apropriate bucket using s3cmd |
| 44 | # s3cmd --access_key="$(jq -r '.AccessKey' secrets/plain/media-repo-$ns-ceph.json)" --secret_key="$(jq -r '.SecretKey' secrets/plain/media-repo-$ns-ceph.json)" --host=object.ceph-waw3.hswaw.net --host-bucket=object.ceph-waw3.hswaw.net mb s3://media-repo-$ns |
| 45 | # |
| 46 | # 4. Add relevant configuration overrides in cfg.mediaRepo key for your |
| 47 | # deployment configuration file: |
| 48 | # |
| 49 | # mediaRepo+: { |
| 50 | # enable: true, |
| 51 | # route: false, |
| 52 | # s3+: { |
| 53 | # endpoint: std.strReplace((import "secrets/plain/media-repo-$ns-ceph.json").Endpoint, "http://", ""), |
| 54 | # accessKey: (import "secrets/plain/media-repo-$ns-ceph.json").AccessKey, |
| 55 | # secretKey: (import "secrets/plain/media-repo-$ns-ceph.json").SecretKey, |
| 56 | # bucketName: "media-repo-$ns", |
| 57 | # region: "eu", |
| 58 | # }, |
| 59 | # db+: { |
| 60 | # password: std.strReplace(importstr "secrets/plain/media-repo-$ns-postgres", "\n", ""), |
| 61 | # }, |
| 62 | # }, |
| 63 | # |
| 64 | # 5. Additionally, when migrating from already deployed synapse media worker the |
| 65 | # following command needs to be run in order to import existing media files: |
| 66 | # kubectl -n $ns exec deploy/media-repo -- import_synapse -baseUrl http://synapse-media:8008 -dbHost waw3-postgres -dbPassword "$(kubectl -n $ns get secret synapse -o json | jq -r '.data.postgres_password | @base64d')" -config /config/config.yaml -serverName 'SERVER_NAME' |
| 67 | # |
| 68 | # 6. After migrating data over from native synapse media worker storage traffic |
| 69 | # can be rerouted to matrix-media-repo by switching cfg.mediaRepo.route flag |
| 70 | # to true |
| 71 | # |
| 72 | # 7. Run import step #5 again to make sure no media were left missing in old |
| 73 | # media worker deployment - import operation is indempotent and can be ran |
| 74 | # against a synapse media worker that's not handling user traffic anymore. |
| 75 | # |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 76 | # Sequencing appservices is fun. The appservice needs to run first (for |
| 77 | # instance, via a bootstrap job), and on startup it will spit out a |
| 78 | # registration file. This registration file then needs to be fed to synapse - |
| 79 | # this is done via specialy named secrets (appservice-X-registration, for X key |
| 80 | # in the appservices object). |
| 81 | # |
| 82 | # For appservice-irc instances, you can use this oneliner magic to get the |
| 83 | # registration YAML from logs. |
| 84 | # kubectl -n matrix create secret generic appservice-irc-freenode-registration --from-file=registration.yaml=<(kubectl -n matrix logs job/appservice-irc-freenode-bootstrap | tail -n +4 | sed -r 's/(.*aliases:.*)/ group_id: "+freenode:hackerspace.pl"\n\1/') |
| 85 | # |
| 86 | # For appservice-telegram instances, you can use this oneliner magic: |
| 87 | # kubectl -n matrix create secret generic appservice-telegram-prod-registration --from-file=registration.yaml=<(kubectl -n matrix logs job/appservice-telegram-prod-bootstrap | grep -A 100 SNIPSNIP | grep -v SNIPSNIP) |
| 88 | |
| 89 | local kube = import "../../../kube/kube.libsonnet"; |
| 90 | local postgres = import "../../../kube/postgres.libsonnet"; |
| 91 | local redis = import "../../../kube/redis.libsonnet"; |
| 92 | |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 93 | local riot = import "./riot.libsonnet"; |
| 94 | local cas = import "./cas.libsonnet"; |
| 95 | local wellKnown = import "./wellknown.libsonnet"; |
| 96 | local synapse = import "./synapse.libsonnet"; |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 97 | local mediaRepo = import "./media-repo.libsonnet"; |
Piotr Dobrowolski | 690ed45 | 2022-05-07 11:27:24 +0200 | [diff] [blame] | 98 | local coturn = import "./coturn.libsonnet"; |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 99 | |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 100 | { |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 101 | local top = self, |
| 102 | local cfg = top.cfg, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 103 | cfg:: { |
| 104 | namespace: error "cfg.namespace must be set", |
| 105 | # webDomain is the domain name at which element will run |
| 106 | webDomain: error "cfg.webDomain must be set", |
| 107 | # serverName is the server part of the MXID this homeserver will cover |
| 108 | serverName: error "cfg.serverName must be set", |
| 109 | storageClassName: "waw-hdd-redundant-3", |
| 110 | |
| 111 | images: { |
Piotr Dobrowolski | 926252c | 2023-03-28 23:58:20 +0200 | [diff] [blame] | 112 | synapse: "matrixdotorg/synapse:v1.79.0", |
Piotr Dobrowolski | 1e6ae55 | 2023-03-28 22:39:46 +0200 | [diff] [blame] | 113 | riot: "vectorim/element-web:v1.11.26", |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 114 | casProxy: "registry.k0.hswaw.net/q3k/oauth2-cas-proxy:0.1.4", |
Piotr Dobrowolski | d3c14e5 | 2022-09-27 01:47:02 +0200 | [diff] [blame] | 115 | appserviceIRC: "matrixdotorg/matrix-appservice-irc:release-0.35.1", |
Serge Bazanski | 8eae454 | 2021-05-19 15:42:13 +0000 | [diff] [blame] | 116 | appserviceTelegram: "dock.mau.dev/tulir/mautrix-telegram@sha256:c6e25cb57e1b67027069e8dc2627338df35d156315c004a6f2b34b6aeaa79f77", |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 117 | wellKnown: "registry.k0.hswaw.net/q3k/wellknown:1611960794-adbf560851a46ad0e58b42f0daad7ef19535687c", |
Piotr Dobrowolski | 654dd80 | 2022-09-13 20:48:13 +0200 | [diff] [blame] | 118 | mediaRepo: "turt2live/matrix-media-repo:v1.2.12", |
Piotr Dobrowolski | 690ed45 | 2022-05-07 11:27:24 +0200 | [diff] [blame] | 119 | coturn: "coturn/coturn:4.5.2-r11-alpine", |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 120 | }, |
| 121 | |
| 122 | # OpenID Connect provider configuration. |
| 123 | # Currently only client_secret can be provided as a secretKeyRef. |
| 124 | # |
| 125 | # https://${cfg.webDomain}/_synapse/oidc/callback needs to be set as |
| 126 | # allowed OAuth2/OpenID Connect callback URL |
| 127 | # |
| 128 | # See: https://github.com/matrix-org/synapse/blob/v1.25.0/docs/openid.md |
| 129 | oidc: { |
| 130 | enable: false, |
| 131 | config: { |
| 132 | issuer: error "oidc.config.issuer must be set", |
| 133 | client_id: error "oidc.config.client_id must be set", |
| 134 | client_secret: error "oidc.config.client_secret must be set", |
| 135 | |
| 136 | # Set this to true when migrating from existing CAS deployment |
| 137 | allow_existing_users: false, |
| 138 | user_mapping_provider: { |
| 139 | config: { |
| 140 | localpart_template: '{{ user.sub }}', |
| 141 | display_name_template: '{{ user.sub }}', |
| 142 | }, |
| 143 | }, |
| 144 | |
| 145 | # Extra configuration required when migrating from |
| 146 | # oauth2-cas-proxy bound to https://sso.hackerspace.pl |
| 147 | # user_profile_method: "userinfo_endpoint", |
| 148 | # client_auth_method: "client_secret_post", |
| 149 | }, |
| 150 | }, |
| 151 | |
| 152 | # Central Authentication Scheme, a single-sign-on system. Note: this flow is now called 'SSO' in Matrix, we keep this name for legacy reasons. |
| 153 | # Refer to https://matrix.org/docs/spec/client_server/r0.6.1#sso-client-login |
| 154 | cas: { |
| 155 | # whether to enable the CAS proxy (ie. connect to hswaw sso via OAuth) |
| 156 | enable: false, |
| 157 | # generate client ID and secret in with your OAuth2 provider, refer to https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/ |
| 158 | oauth2: { |
| 159 | clientID: error "cas.oauth2.clientID must be set", |
| 160 | clientSecret: error "cas.oauth2.clientSecret must be set", |
| 161 | scope: error "cas.oauth2.scope must be set", |
| 162 | authorizeURL: error "cas.oauth2.authorizeURL must be set", |
| 163 | tokenURL: error "cas.oauth2.tokenURL must be set", |
| 164 | userinfoURL: error "cas.oauth2.userinfoURL must be set", |
| 165 | }, |
| 166 | }, |
| 167 | |
| 168 | # Serve /.well-known/matrix configuration endpoints required when using |
| 169 | # cfg.webDomain directly as mxid. |
| 170 | wellKnown: false, |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 171 | |
| 172 | # matrix-media-repo S3-based media storage container |
| 173 | mediaRepo: { |
| 174 | enable: false, |
| 175 | |
| 176 | # Route /_matrix/media/ endpoints to matrix-media-repo. Set this |
| 177 | # to true after migrating media files to matrix-media-repo. |
| 178 | route: false, |
| 179 | |
| 180 | s3: { |
| 181 | endpoint: error "mediaRepo.s3.endpoint needs to be set", |
| 182 | accessKey: error "mediaRepo.s3.accessKey needs to be set", |
| 183 | secretKey: error "mediaRepo.s3.secretKey needs to be set", |
| 184 | bucketName: error "mediaRepo.s3.bucketName needs to be set", |
| 185 | region: error "mediaRepo.s3.region needs to be set", |
| 186 | }, |
| 187 | |
| 188 | db: { |
| 189 | username: "mediarepo", |
| 190 | password: error "mediaRepo.db.password needs to be set", |
| 191 | database: "mediarepo", |
| 192 | host: "waw3-postgres", |
Piotr Dobrowolski | ad3cb5c | 2023-03-28 22:39:08 +0200 | [diff] [blame] | 193 | port: 5432, |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 194 | }, |
| 195 | }, |
| 196 | |
| 197 | # List of administrative users MXIDs (used in matrix-media-repo only) |
| 198 | admins: [], |
Piotr Dobrowolski | 690ed45 | 2022-05-07 11:27:24 +0200 | [diff] [blame] | 199 | |
| 200 | # Deploy coturn STUN/TURN server |
| 201 | coturn: { |
| 202 | enable: false, |
| 203 | config: { |
| 204 | domain: error "coturn.config.domain must be set", |
| 205 | |
| 206 | # Default to public domain - this may be adjusted when multiple |
| 207 | # turn servers are deployed. |
| 208 | realm: self.domain, |
| 209 | |
| 210 | # Set this to assigned LoadBalacer IP for correct NAT resolution |
| 211 | loadBalancerIP: null, |
| 212 | |
| 213 | authSecret: { secretKeyRef: { name: "coturn", key: "auth_secret" } }, |
| 214 | }, |
| 215 | }, |
Serge Bazanski | f262868 | 2023-03-26 21:56:09 +0200 | [diff] [blame] | 216 | |
| 217 | postgres: { |
| 218 | # Deploy on-cluster postgres: a postgres instance backed by Ceph. |
| 219 | # Okay for tiny baby synapses, not okay for chonkers. If not |
| 220 | # enabled, bring your own external postgres. |
| 221 | enable: true, |
| 222 | |
| 223 | # If not deploying on-cluster postgres, the following needs to be |
| 224 | # set. |
| 225 | host: error "host must be set with off-cluster postgres", |
| 226 | username: "synapse", |
| 227 | database: "synapse", |
| 228 | port: 5432, |
| 229 | # Default to the same password secret ref that is used for |
| 230 | # on-cluster postgres. |
| 231 | password: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
| 232 | }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 233 | }, |
| 234 | |
Piotr Dobrowolski | fb119aa | 2021-01-31 19:07:32 +0100 | [diff] [blame] | 235 | # DEPRECATED: this needs to be removed in favor of namespace.Contain() in |
| 236 | # modules that depend on this (appservices/instance defintions) |
| 237 | metadata(component):: { |
| 238 | namespace: cfg.namespace, |
| 239 | labels: { |
| 240 | "app.kubernetes.io/name": "matrix", |
| 241 | "app.kubernetes.io/managed-by": "kubecfg", |
| 242 | "app.kubernetes.io/component": component, |
| 243 | }, |
| 244 | }, |
| 245 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 246 | local ns = kube.Namespace(cfg.namespace), |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 247 | |
Serge Bazanski | f262868 | 2023-03-26 21:56:09 +0200 | [diff] [blame] | 248 | postgres3: if cfg.postgres.enable then postgres { |
| 249 | local psql = self, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 250 | cfg+: { |
| 251 | namespace: cfg.namespace, |
| 252 | appName: "synapse", |
| 253 | database: "synapse", |
| 254 | username: "synapse", |
| 255 | prefix: "waw3-", |
| 256 | password: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
| 257 | storageClassName: cfg.storageClassName, |
| 258 | storageSize: "100Gi", |
| 259 | initdbArgs: "--encoding='UTF8' --lc-collate='C' --lc-ctype='C'", |
Piotr Dobrowolski | 529e181 | 2021-02-13 19:44:37 +0100 | [diff] [blame] | 260 | |
Serge Bazanski | f262868 | 2023-03-26 21:56:09 +0200 | [diff] [blame] | 261 | # Doesn't influence postgres instance, but used by synapse |
| 262 | # libsonnet. Do not override. |
| 263 | port: psql.svc.port, |
| 264 | host: psql.svc.host, |
| 265 | |
Piotr Dobrowolski | 529e181 | 2021-02-13 19:44:37 +0100 | [diff] [blame] | 266 | opts: { |
| 267 | max_connections: "300", |
| 268 | shared_buffers: "80MB", |
Bartosz Stebel | 45394bf | 2023-03-01 21:17:25 +0100 | [diff] [blame] | 269 | wal_level: "logical", |
Piotr Dobrowolski | 529e181 | 2021-02-13 19:44:37 +0100 | [diff] [blame] | 270 | }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 271 | }, |
Serge Bazanski | f262868 | 2023-03-26 21:56:09 +0200 | [diff] [blame] | 272 | } else {}, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 273 | |
| 274 | redis: redis { |
| 275 | cfg+: { |
| 276 | namespace: cfg.namespace, |
| 277 | appName: "synapse", |
| 278 | storageClassName: cfg.storageClassName, |
| 279 | password: { secretKeyRef: { name: "synapse", key: "redis_password" } }, |
Piotr Dobrowolski | 529e181 | 2021-02-13 19:44:37 +0100 | [diff] [blame] | 280 | persistence: false, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 281 | }, |
| 282 | }, |
| 283 | |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 284 | riot: riot { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 285 | ns: ns, |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 286 | cfg+: { |
| 287 | webDomain: cfg.webDomain, |
| 288 | serverName: cfg.serverName, |
| 289 | image: cfg.images.riot, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 290 | }, |
| 291 | }, |
| 292 | |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 293 | cas: if cfg.cas.enable && cfg.oidc.enable then error "cfg.cas.enable and cfg.oidc.enable options are exclusive" |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 294 | else if cfg.cas.enable then cas { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 295 | ns: ns, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 296 | cfg+: { |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 297 | image: cfg.images.casProxy, |
| 298 | webDomain: cfg.webDomain, |
| 299 | oauth2: cfg.cas.oauth2, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 300 | }, |
| 301 | }, |
| 302 | |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 303 | wellKnown: if cfg.wellKnown then wellKnown { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 304 | ns: ns, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 305 | cfg+: { |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 306 | image: cfg.images.wellKnown, |
| 307 | webDomain: cfg.webDomain, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 308 | }, |
| 309 | } else {}, |
| 310 | |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 311 | mediaRepo: if cfg.mediaRepo.enable then mediaRepo { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 312 | ns: ns, |
Piotr Dobrowolski | 122d5e5 | 2021-09-10 23:54:34 +0200 | [diff] [blame] | 313 | cfg+: { |
| 314 | image: cfg.images.mediaRepo, |
| 315 | |
| 316 | homeservers: [ |
| 317 | {name: cfg.serverName, csApi: "https://" + cfg.webDomain} |
| 318 | ], |
| 319 | admins: cfg.admins, |
| 320 | |
| 321 | s3: cfg.mediaRepo.s3, |
| 322 | db: cfg.mediaRepo.db, |
| 323 | }, |
| 324 | } else {}, |
| 325 | |
Piotr Dobrowolski | 690ed45 | 2022-05-07 11:27:24 +0200 | [diff] [blame] | 326 | coturn: if cfg.coturn.enable then coturn { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 327 | ns: ns, |
Piotr Dobrowolski | 690ed45 | 2022-05-07 11:27:24 +0200 | [diff] [blame] | 328 | cfg+: { |
| 329 | storageClassName: cfg.storageClassName, |
| 330 | image: cfg.images.coturn, |
| 331 | realm: cfg.coturn.config.realm, |
| 332 | loadBalancerIP: cfg.coturn.config.loadBalancerIP, |
| 333 | authSecret: cfg.coturn.config.authSecret, |
| 334 | }, |
| 335 | } else null, |
| 336 | |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 337 | synapse: synapse { |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 338 | ns: ns, |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 339 | postgres: if cfg.postgres.enable then top.postgres3 else { |
Serge Bazanski | f262868 | 2023-03-26 21:56:09 +0200 | [diff] [blame] | 340 | # If not using on-cluster postgres, pass the config postgres object |
| 341 | # as the postgres object into the synapse lib. It's a bit ugly (we |
| 342 | # should have some common 'config' type instead) but it's good |
| 343 | # enough. |
| 344 | cfg: cfg.postgres, |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 345 | }, redis: top.redis, |
| 346 | appservices: top.appservices, |
| 347 | cfg+: top.cfg { |
| 348 | image: top.cfg.images.synapse, |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 349 | |
| 350 | macaroonSecretKey: { secretKeyRef: { name: "synapse", key: "macaroon_secret_key" } }, |
| 351 | registrationSharedSecret: { secretKeyRef: { name: "synapse", key: "registration_shared_secret" } }, |
| 352 | workerReplicationSecret: { secretKeyRef: { name: "synapse", key: "worker_replication_secret" } }, |
| 353 | }, |
| 354 | }, |
| 355 | |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 356 | // Any appservice you add here will require an appservice-X-registration |
| 357 | // secret containing a registration.yaml file. Adding something to this |
| 358 | // dictionary will cause Synapse to not start until that secret is |
| 359 | // available - so change things carefully! |
| 360 | // If bootstrapping a new appservice, just keep it out of this dictionary |
| 361 | // until it spits you a registration YAML and you feed that to a secret. |
| 362 | appservices: {}, |
| 363 | |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 364 | ingress: top.namespace.Contain(kube.Ingress("matrix")) { |
Piotr Dobrowolski | b67ae48 | 2021-01-31 10:35:38 +0100 | [diff] [blame] | 365 | metadata+: { |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 366 | annotations+: { |
| 367 | "kubernetes.io/tls-acme": "true", |
Piotr Dobrowolski | 7e84106 | 2023-04-23 11:36:15 +0200 | [diff] [blame] | 368 | "cert-manager.io/cluster-issuer": "letsencrypt-prod", |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 369 | "nginx.ingress.kubernetes.io/proxy-body-size": "0", |
| 370 | "nginx.ingress.kubernetes.io/use-regex": "true", |
| 371 | }, |
| 372 | }, |
| 373 | spec+: { |
| 374 | tls: [ |
| 375 | { |
| 376 | hosts: [cfg.webDomain], |
| 377 | secretName: "synapse-tls", |
| 378 | }, |
| 379 | ], |
| 380 | rules: [ |
| 381 | { |
| 382 | host: cfg.webDomain, |
| 383 | http: { |
| 384 | paths: [ |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 385 | { path: path, backend: top.synapse.genericWorker.svc.name_port } |
| 386 | for path in top.synapse.genericWorker.paths |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 387 | ] + [ |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 388 | { path: "/", backend: top.riot.svc.name_port }, |
| 389 | { path: "/_matrix/media/", backend: if cfg.mediaRepo.route then top.mediaRepo.svc.name_port else top.synapse.mediaWorker.svc.name_port }, |
| 390 | { path: "/_matrix/", backend: top.synapse.main.svc.name_port }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 391 | |
| 392 | # Used by OpenID Connect login flow |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 393 | { path: "/_synapse/", backend: top.synapse.main.svc.name_port }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 394 | ] + (if cfg.cas.enable then [ |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 395 | { path: "/_cas", backend: top.cas.svc.name_port }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 396 | ] else []) + (if cfg.wellKnown then [ |
radex | c995c21 | 2023-11-24 12:01:49 +0100 | [diff] [blame^] | 397 | { path: "/.well-known/matrix", backend: top.wellKnown.svc.name_port }, |
Piotr Dobrowolski | 8ec8657 | 2021-01-30 13:06:07 +0100 | [diff] [blame] | 398 | ] else []) |
| 399 | }, |
| 400 | } |
| 401 | ], |
| 402 | }, |
| 403 | }, |
| 404 | } |