Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 1 | # Matrix server (synapse). |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 2 | # This needs a secret provisioned, create with: |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 3 | # ns=matrix |
| 4 | # 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) |
| 5 | # kubectl -n $ns create secret generic oauth2-cas-proxy --from-literal=oauth2_secret=... |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 6 | # |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 7 | # After starting, re-create the postgres database (because docker/postgres won't let you set ENCODING): |
| 8 | # postgres=# drop database synapse; |
| 9 | # DROP DATABASE |
| 10 | # postgres=# CREATE DATABASE synapse |
| 11 | # postgres-# ENCODING 'UTF8' |
| 12 | # postgres-# LC_COLLATE='C' |
| 13 | # postgres-# LC_CTYPE='C' |
| 14 | # postgres-# template=template0 |
| 15 | # postgres-# OWNER synapse; |
| 16 | # CREATE DATABASE |
| 17 | # |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 18 | # Sequencing appservices is fun. The appservice needs to run first (for |
| 19 | # instance, via a bootstrap job), and on startup it will spit out a |
| 20 | # registration file. This registration file then needs to be fed to synapse - |
| 21 | # this is done via specialy named secrets (appservice-X-registration, for X key |
| 22 | # in the appservices object). |
| 23 | # |
| 24 | # For appservice-irc instances, you can use this oneliner magic to get the |
| 25 | # registration YAML from logs. |
Piotr Dobrowolski | ee62857 | 2021-01-30 00:14:20 +0100 | [diff] [blame] | 26 | # 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/') |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 27 | # |
| 28 | # For appservice-telegram instances, you can use this oneliner magic: |
| 29 | # 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) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 30 | |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 31 | local kube = import "../../../kube/hscloud.libsonnet"; |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 32 | local postgres = import "../../../kube/postgres.libsonnet"; |
Serge Bazanski | cdba291 | 2020-08-24 19:11:10 +0000 | [diff] [blame] | 33 | |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 34 | { |
| 35 | local app = self, |
| 36 | local cfg = app.cfg, |
| 37 | cfg:: { |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 38 | namespace: error "cfg.namespace must be set", |
| 39 | # webDomain is the domain name at which element will run |
| 40 | webDomain: error "cfg.webDomain must be set", |
| 41 | # serverName is the server part of the MXID this homeserver will cover |
| 42 | serverName: error "cfg.serverName must be set", |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 43 | storageClassName: "waw-hdd-redundant-3", |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 44 | |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 45 | images: { |
Norbert Szulc | a5e8c33 | 2021-07-08 15:10:43 +0200 | [diff] [blame] | 46 | synapse: "matrixdotorg/synapse:v1.37.1", |
Serge Bazanski | d67635d | 2020-12-29 23:25:54 +0100 | [diff] [blame] | 47 | riot: "vectorim/riot-web:v1.7.16", |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 48 | casProxy: "registry.k0.hswaw.net/q3k/oauth2-cas-proxy:0.1.4", |
| 49 | appserviceIRC: "matrixdotorg/matrix-appservice-irc:release-0.17.1", |
Serge Bazanski | c3ca295 | 2021-04-10 11:15:30 +0000 | [diff] [blame] | 50 | # :latest tag on 2021/04/10. |
| 51 | appserviceTelegram: "dock.mau.dev/tulir/mautrix-telegram@sha256:c6e25cb57e1b67027069e8dc2627338df35d156315c004a6f2b34b6aeaa79f77", |
Piotr Dobrowolski | 63244ca | 2021-01-30 00:14:02 +0100 | [diff] [blame] | 52 | wellKnown: "registry.k0.hswaw.net/q3k/wellknown:1611960794-adbf560851a46ad0e58b42f0daad7ef19535687c", |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 53 | }, |
| 54 | |
Norbert Szulc | c67abc2 | 2020-11-08 16:46:56 +0100 | [diff] [blame] | 55 | # Central Authentication Scheme, a single-sign-on system. Note: this flow is now called 'SSO' in Matrix, we keep this name for legacy reasons. |
| 56 | # Refer to https://matrix.org/docs/spec/client_server/r0.6.1#sso-client-login |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 57 | cas: { |
| 58 | # whether to enable the CAS proxy (ie. connect to hswaw sso via OAuth) |
| 59 | enable: false, |
Norbert Szulc | 014c9cd | 2020-11-08 16:44:48 +0100 | [diff] [blame] | 60 | # generate client ID and secret in with your OAuth2 provider, refer to https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/ |
| 61 | oauth2: { |
| 62 | clientID: error "cas.oauth2.clientID must be set", |
| 63 | clientSecret: error "cas.oauth2.clientSecret must be set", |
| 64 | scope: error "cas.oauth2.scope must be set", |
| 65 | authorizeURL: error "cas.oauth2.authorizeURL must be set", |
| 66 | tokenURL: error "cas.oauth2.tokenURL must be set", |
| 67 | userinfoURL: error "cas.oauth2.userinfoURL must be set", |
| 68 | }, |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 69 | }, |
Piotr Dobrowolski | 63244ca | 2021-01-30 00:14:02 +0100 | [diff] [blame] | 70 | |
| 71 | wellKnown: false, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 72 | }, |
| 73 | |
| 74 | metadata(component):: { |
Piotr Dobrowolski | 4b4231d | 2019-05-15 11:41:21 +0200 | [diff] [blame] | 75 | namespace: cfg.namespace, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 76 | labels: { |
| 77 | "app.kubernetes.io/name": "matrix", |
| 78 | "app.kubernetes.io/managed-by": "kubecfg", |
| 79 | "app.kubernetes.io/component": component, |
| 80 | }, |
| 81 | }, |
| 82 | |
Piotr Dobrowolski | 4b4231d | 2019-05-15 11:41:21 +0200 | [diff] [blame] | 83 | namespace: kube.Namespace(cfg.namespace), |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 84 | |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 85 | postgres3: postgres { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 86 | cfg+: { |
| 87 | namespace: cfg.namespace, |
| 88 | appName: "synapse", |
| 89 | database: "synapse", |
| 90 | username: "synapse", |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 91 | prefix: "waw3-", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 92 | password: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 93 | storageClassName: cfg.storageClassName, |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 94 | storageSize: "100Gi", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 95 | }, |
| 96 | }, |
| 97 | |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 98 | dataVolume: kube.PersistentVolumeClaim("synapse-data-waw3") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 99 | metadata+: app.metadata("synapse-data"), |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 100 | storage: "50Gi", |
| 101 | storageClass: cfg.storageClassName, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 102 | }, |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 103 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 104 | // homeserver.yaml that will be used to run synapse (in synapseConfigMap). |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 105 | // This is based off of //app/matrix/lib/synapse/homeserver.yaml with some fields overriden per |
| 106 | // deployment. |
| 107 | // Note this is a templated yaml - {{}}/{%%} style. This templatization is consumed by the Docker |
| 108 | // container startup magic. |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 109 | synapseConfig:: (std.native("parseYaml"))(importstr "synapse/homeserver.yaml")[0] { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 110 | server_name: cfg.serverName, |
| 111 | public_baseurl: "https://%s" % [cfg.webDomain], |
| 112 | signing_key_path: "/data/%s.signing.key" % [cfg.serverName], |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 113 | app_service_config_files: [ |
| 114 | "/appservices/%s/registration.yaml" % [k] |
| 115 | for k in std.objectFields(app.appservices) |
| 116 | ], |
| 117 | } + (if cfg.cas.enable then { |
| 118 | cas_config: { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 119 | enabled: true, |
| 120 | server_url: "https://%s/_cas" % [cfg.webDomain], |
| 121 | service_url: "https://%s" % [cfg.webDomain], |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 122 | }, |
| 123 | } else {}), |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 124 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 125 | synapseConfigMap: kube.ConfigMap("synapse") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 126 | metadata+: app.metadata("synapse"), |
| 127 | data: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 128 | "homeserver.yaml": std.manifestYamlDoc(app.synapseConfig), |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 129 | "log.config": importstr "synapse/log.config", |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 130 | }, |
| 131 | }, |
| 132 | |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 133 | casDeployment: if cfg.cas.enable then kube.Deployment("oauth2-cas-proxy") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 134 | metadata+: app.metadata("oauth2-cas-proxy"), |
| 135 | spec+: { |
| 136 | replicas: 1, |
| 137 | template+: { |
| 138 | spec+: { |
| 139 | containers_: { |
| 140 | proxy: kube.Container("oauth2-cas-proxy") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 141 | image: cfg.images.casProxy, |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 142 | ports_: { |
| 143 | http: { containerPort: 5000 }, |
| 144 | }, |
| 145 | env_: { |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 146 | BASE_URL: "https://%s" % [cfg.webDomain], |
| 147 | SERVICE_URL: "https://%s" % [cfg.webDomain], |
Norbert Szulc | 014c9cd | 2020-11-08 16:44:48 +0100 | [diff] [blame] | 148 | OAUTH2_CLIENT: cfg.cas.oauth2.clientID, |
| 149 | OAUTH2_SECRET: cfg.cas.oauth2.clientSecret, |
| 150 | OAUTH2_SCOPE: cfg.cas.oauth2.scope, |
| 151 | OAUTH2_AUTHORIZE: cfg.cas.oauth2.authorizeURL, |
| 152 | OAUTH2_TOKEN: cfg.cas.oauth2.tokenURL, |
| 153 | OAUTH2_USERINFO: cfg.cas.oauth2.userinfoURL, |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 154 | }, |
| 155 | }, |
| 156 | }, |
| 157 | }, |
| 158 | }, |
| 159 | }, |
| 160 | }, |
| 161 | |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 162 | casSvc: if cfg.cas.enable then kube.Service("oauth2-cas-proxy") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 163 | metadata+: app.metadata("oauth2-cas-proxy"), |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame^] | 164 | target:: app.casDeployment, |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 165 | }, |
| 166 | |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 167 | synapseDeployment: kube.Deployment("synapse") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 168 | metadata+: app.metadata("synapse"), |
| 169 | spec+: { |
| 170 | replicas: 1, |
| 171 | template+: { |
| 172 | spec+: { |
| 173 | volumes_: { |
| 174 | data: kube.PersistentVolumeClaimVolume(app.dataVolume), |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 175 | config: kube.ConfigMapVolume(app.synapseConfigMap), |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 176 | } + { |
| 177 | [k]: { secret: { secretName: "appservice-%s-registration" % [k] } } |
| 178 | for k in std.objectFields(app.appservices) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 179 | }, |
| 180 | containers_: { |
| 181 | web: kube.Container("synapse") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 182 | image: cfg.images.synapse, |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 183 | command: ["/bin/sh", "-c", "/start.py migrate_config && exec /start.py"], |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 184 | ports_: { |
| 185 | http: { containerPort: 8008 }, |
Serge Bazanski | 1230ac3 | 2020-09-12 22:09:46 +0000 | [diff] [blame] | 186 | metrics: { containerPort: 9092 }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 187 | }, |
| 188 | env_: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 189 | SYNAPSE_CONFIG_DIR: "/tmp/config", |
| 190 | SYNAPSE_CONFIG_PATH: "/tmp/config/homeserver.yaml", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 191 | |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 192 | # These values are not used in a template, but |
| 193 | # are required by /start.py migrate_config |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 194 | SYNAPSE_SERVER_NAME: cfg.serverName, |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 195 | SYNAPSE_REPORT_STATS: "no", |
| 196 | |
| 197 | SYNAPSE_MACAROON_SECRET_KEY: { secretKeyRef: { name: "synapse", key: "macaroon_secret_key" } }, |
| 198 | SYNAPSE_REGISTRATION_SHARED_SECRET: { secretKeyRef: { name: "synapse", key: "registration_shared_secret" } }, |
| 199 | POSTGRES_PASSWORD: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 200 | }, |
| 201 | volumeMounts_: { |
| 202 | data: { mountPath: "/data" }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 203 | config: { mountPath: "/conf", }, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 204 | } + { |
| 205 | [k]: { mountPath: "/appservices/%s" % [k] } |
| 206 | for k in std.objectFields(app.appservices) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 207 | }, |
| 208 | }, |
| 209 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 210 | securityContext: { |
| 211 | runAsUser: 991, |
| 212 | runAsGroup: 991, |
| 213 | fsGroup: 991, |
| 214 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 215 | }, |
| 216 | }, |
| 217 | }, |
| 218 | }, |
| 219 | |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 220 | synapseSvc: kube.Service("synapse") { |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 221 | metadata+: app.metadata("synapse"), |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame^] | 222 | target:: app.synapseDeployment, |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 223 | }, |
| 224 | |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 225 | riotConfig:: { |
| 226 | "default_hs_url": "https://%s" % [cfg.webDomain], |
| 227 | "disable_custom_urls": false, |
| 228 | "disable_guests": false, |
| 229 | "disable_login_language_selector": false, |
| 230 | "disable_3pid_login": true, |
| 231 | "brand": "Riot", |
| 232 | "integrations_ui_url": "https://scalar.vector.im/", |
| 233 | "integrations_rest_url": "https://scalar.vector.im/api", |
| 234 | "integrations_jitsi_widget_url": "https://scalar.vector.im/api/widgets/jitsi.html", |
| 235 | |
| 236 | "bug_report_endpoint_url": "https://riot.im/bugreports/submit", |
| 237 | "features": { |
| 238 | "feature_groups": "labs", |
| 239 | "feature_pinning": "labs", |
| 240 | "feature_reactions": "labs" |
| 241 | }, |
| 242 | "default_federate": true, |
| 243 | "default_theme": "light", |
| 244 | "roomDirectory": { |
| 245 | "servers": [ |
| 246 | cfg.serverName, |
| 247 | ] |
| 248 | }, |
| 249 | "welcomeUserId": "@riot-bot:matrix.org", |
| 250 | "enable_presence_by_hs_url": { |
| 251 | "https://matrix.org": false |
| 252 | } |
| 253 | }, |
| 254 | |
| 255 | riotConfigMap: kube.ConfigMap("riot-web-config") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 256 | metadata+: app.metadata("riot-web-config"), |
| 257 | data: { |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 258 | "config.json": std.manifestJsonEx(app.riotConfig, ""), |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 259 | // Standard nginx.conf, made to work when running as unprivileged user. |
| 260 | "nginx.conf": ||| |
| 261 | worker_processes auto; |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 262 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 263 | error_log /tmp/nginx_error.log warn; |
| 264 | pid /tmp/nginx.pid; |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 265 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 266 | events { |
| 267 | worker_connections 1024; |
| 268 | } |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 269 | |
| 270 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 271 | http { |
| 272 | client_body_temp_path /tmp/nginx_client_temp; |
| 273 | proxy_temp_path /tmp/nginx_proxy_temp; |
| 274 | fastcgi_temp_path /tmp/nginx_fastcgi_temp; |
| 275 | uwsgi_temp_path /tmp/nginx_uwsgi_temp; |
| 276 | scgi_temp_path /tmp/nginx_scgi_temp; |
| 277 | |
| 278 | include /etc/nginx/mime.types; |
| 279 | default_type application/octet-stream; |
| 280 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| 281 | '$status $body_bytes_sent "$http_referer" ' |
| 282 | '"$http_user_agent" "$http_x_forwarded_for"'; |
| 283 | access_log /tmp/nginx_access.log main; |
| 284 | sendfile on; |
| 285 | keepalive_timeout 65; |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 286 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 287 | server { |
| 288 | listen 8080; |
| 289 | server_name localhost; |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 290 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 291 | location / { |
| 292 | root /usr/share/nginx/html; |
| 293 | index index.html index.htm; |
| 294 | } |
Radek Pietruszewski | f28cd62 | 2023-11-03 17:30:10 +0100 | [diff] [blame] | 295 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 296 | error_page 500 502 503 504 /50x.html; |
| 297 | location = /50x.html { |
| 298 | root /usr/share/nginx/html; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |||, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 303 | }, |
| 304 | }, |
| 305 | |
| 306 | riotDeployment: kube.Deployment("riot-web") { |
| 307 | metadata+: app.metadata("riot-web"), |
| 308 | spec+: { |
| 309 | replicas: 1, |
| 310 | template+: { |
| 311 | spec+: { |
| 312 | volumes_: { |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 313 | config: kube.ConfigMapVolume(app.riotConfigMap), |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 314 | }, |
| 315 | containers_: { |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 316 | web: kube.Container("riot-web") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 317 | image: cfg.images.riot, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 318 | ports_: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 319 | http: { containerPort: 8080 }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 320 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 321 | volumeMounts: [ |
| 322 | { |
| 323 | name: "config", |
Piotr Dobrowolski | aca7e28 | 2020-03-21 22:14:38 +0100 | [diff] [blame] | 324 | mountPath: "/app/config.json", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 325 | subPath: "config.json", |
| 326 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 327 | { |
| 328 | name: "config", |
| 329 | mountPath: "/etc/nginx/nginx.conf", |
| 330 | subPath: "nginx.conf", |
| 331 | }, |
| 332 | ], |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 333 | }, |
| 334 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 335 | securityContext: { |
| 336 | // nginx:nginx |
| 337 | runAsUser: 101, |
| 338 | runAsGroup: 101, |
| 339 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 340 | }, |
| 341 | }, |
| 342 | }, |
| 343 | }, |
| 344 | |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 345 | riotSvc: kube.Service("riot-web") { |
| 346 | metadata+: app.metadata("riot-web"), |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame^] | 347 | target:: app.riotDeployment, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 348 | }, |
| 349 | |
Piotr Dobrowolski | 63244ca | 2021-01-30 00:14:02 +0100 | [diff] [blame] | 350 | wellKnown: if cfg.wellKnown then { |
| 351 | deployment: kube.Deployment("wellknown") { |
| 352 | metadata+: app.metadata("wellknown"), |
| 353 | spec+: { |
| 354 | replicas: 1, |
| 355 | template+: { |
| 356 | spec+: { |
| 357 | containers_: { |
| 358 | web: kube.Container("wellknown") { |
| 359 | image: cfg.images.wellKnown, |
| 360 | ports_: { |
| 361 | http: { containerPort: 8080 }, |
| 362 | }, |
| 363 | command: ["/app/matrix/wellknown"], |
| 364 | args: ["-hspki_disable", "-domain", cfg.webDomain], |
| 365 | }, |
| 366 | }, |
| 367 | securityContext: { |
| 368 | runAsUser: 101, |
| 369 | runAsGroup: 101, |
| 370 | }, |
| 371 | }, |
| 372 | }, |
| 373 | }, |
| 374 | }, |
| 375 | svc: kube.Service("wellknown") { |
| 376 | metadata+: app.metadata("wellknown"), |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame^] | 377 | target:: app.wellKnown.deployment, |
Piotr Dobrowolski | 63244ca | 2021-01-30 00:14:02 +0100 | [diff] [blame] | 378 | }, |
| 379 | } else {}, |
| 380 | |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 381 | // Any appservice you add here will require an appservice-X-registration |
| 382 | // secret containing a registration.yaml file. Adding something to this |
| 383 | // dictionary will cause Synapse to not start until that secret is |
| 384 | // available - so change things carefully! |
| 385 | // If bootstrapping a new appservice, just keep it out of this dictionary |
| 386 | // until it spits you a registration YAML and you feed that to a secret. |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 387 | appservices: {}, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 388 | |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 389 | ingress: kube.SimpleIngress("matrix") { |
| 390 | hosts:: [cfg.webDomain], |
| 391 | target_service:: app.riotSvc, |
| 392 | metadata+: app.metadata("matrix"), |
| 393 | extra_paths:: [ |
| 394 | { path: "/_matrix", backend: app.synapseSvc.name_port }, |
| 395 | ] + (if cfg.cas.enable then [ |
| 396 | { path: "/_cas", backend: app.casSvc.name_port }, |
| 397 | ] else []) + (if cfg.wellKnown then [ |
| 398 | { path: "/.well-known/matrix", backend: app.wellKnown.svc.name_port }, |
| 399 | ] else []) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 400 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 401 | } |