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 | 3ea979d | 2019-05-23 16:11:52 +0200 | [diff] [blame] | 26 | # kubectl -n matrix create secret generic appservice-irc-freenode-registration --from-file=registration.yaml=<(kubectl logs -n matrix $(kubectl get pods -n matrix --selector=job-name=appservice-irc-freenode-bootstrap --output=jsonpath='{.items[*].metadata.name}') | 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 | |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 31 | local kube = import "../../../kube/kube.libsonnet"; |
| 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: { |
| 46 | synapse: "matrixdotorg/synapse:v1.19.2", |
| 47 | riot: "vectorim/riot-web:v1.7.7", |
| 48 | casProxy: "registry.k0.hswaw.net/q3k/oauth2-cas-proxy:0.1.4", |
| 49 | appserviceIRC: "matrixdotorg/matrix-appservice-irc:release-0.17.1", |
| 50 | # That's v0.8.2 - we just don't trust that host to not re-tag images. |
| 51 | appserviceTelegram: "dock.mau.dev/tulir/mautrix-telegram@sha256:9e68eaa80c9e4a75d9a09ec92dc4898b12d48390e01efa4de40ce882a6f7e330", |
| 52 | }, |
| 53 | |
| 54 | cas: { |
| 55 | # whether to enable the CAS proxy (ie. connect to hswaw sso via OAuth) |
| 56 | enable: false, |
| 57 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 58 | }, |
| 59 | |
| 60 | metadata(component):: { |
Piotr Dobrowolski | 4b4231d | 2019-05-15 11:41:21 +0200 | [diff] [blame] | 61 | namespace: cfg.namespace, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 62 | labels: { |
| 63 | "app.kubernetes.io/name": "matrix", |
| 64 | "app.kubernetes.io/managed-by": "kubecfg", |
| 65 | "app.kubernetes.io/component": component, |
| 66 | }, |
| 67 | }, |
| 68 | |
Piotr Dobrowolski | 4b4231d | 2019-05-15 11:41:21 +0200 | [diff] [blame] | 69 | namespace: kube.Namespace(cfg.namespace), |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 70 | |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 71 | postgres3: postgres { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 72 | cfg+: { |
| 73 | namespace: cfg.namespace, |
| 74 | appName: "synapse", |
| 75 | database: "synapse", |
| 76 | username: "synapse", |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 77 | prefix: "waw3-", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 78 | password: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 79 | storageClassName: cfg.storageClassName, |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 80 | storageSize: "100Gi", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 81 | }, |
| 82 | }, |
| 83 | |
Serge Bazanski | c0c037a | 2020-08-23 01:24:03 +0000 | [diff] [blame] | 84 | dataVolume: kube.PersistentVolumeClaim("synapse-data-waw3") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 85 | metadata+: app.metadata("synapse-data"), |
| 86 | spec+: { |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 87 | storageClassName: cfg.storageClassName, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 88 | accessModes: [ "ReadWriteOnce" ], |
| 89 | resources: { |
| 90 | requests: { |
| 91 | storage: "50Gi", |
| 92 | }, |
| 93 | }, |
| 94 | }, |
| 95 | }, |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 96 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 97 | // homeserver.yaml that will be used to run synapse (in synapseConfigMap). |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 98 | // This is based off of //app/matrix/lib/synapse/homeserver.yaml with some fields overriden per |
| 99 | // deployment. |
| 100 | // Note this is a templated yaml - {{}}/{%%} style. This templatization is consumed by the Docker |
| 101 | // container startup magic. |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 102 | synapseConfig:: (std.native("parseYaml"))(importstr "synapse/homeserver.yaml")[0] { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 103 | server_name: cfg.serverName, |
| 104 | public_baseurl: "https://%s" % [cfg.webDomain], |
| 105 | signing_key_path: "/data/%s.signing.key" % [cfg.serverName], |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 106 | app_service_config_files: [ |
| 107 | "/appservices/%s/registration.yaml" % [k] |
| 108 | for k in std.objectFields(app.appservices) |
| 109 | ], |
| 110 | } + (if cfg.cas.enable then { |
| 111 | cas_config: { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 112 | enabled: true, |
| 113 | server_url: "https://%s/_cas" % [cfg.webDomain], |
| 114 | service_url: "https://%s" % [cfg.webDomain], |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 115 | }, |
| 116 | } else {}), |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 117 | |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 118 | synapseConfigMap: kube.ConfigMap("synapse") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 119 | metadata+: app.metadata("synapse"), |
| 120 | data: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 121 | "homeserver.yaml": std.manifestYamlDoc(app.synapseConfig), |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 122 | "log.config": importstr "synapse/log.config", |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 123 | }, |
| 124 | }, |
| 125 | |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 126 | casDeployment: if cfg.cas.enable then kube.Deployment("oauth2-cas-proxy") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 127 | metadata+: app.metadata("oauth2-cas-proxy"), |
| 128 | spec+: { |
| 129 | replicas: 1, |
| 130 | template+: { |
| 131 | spec+: { |
| 132 | containers_: { |
| 133 | proxy: kube.Container("oauth2-cas-proxy") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 134 | image: cfg.images.casProxy, |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 135 | ports_: { |
| 136 | http: { containerPort: 5000 }, |
| 137 | }, |
| 138 | env_: { |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 139 | BASE_URL: "https://%s" % [cfg.webDomain], |
| 140 | SERVICE_URL: "https://%s" % [cfg.webDomain], |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 141 | OAUTH2_CLIENT: "matrix", |
| 142 | OAUTH2_SECRET: { secretKeyRef: { name: "oauth2-cas-proxy", key: "oauth2_secret" } }, |
| 143 | }, |
| 144 | }, |
| 145 | }, |
| 146 | }, |
| 147 | }, |
| 148 | }, |
| 149 | }, |
| 150 | |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 151 | casSvc: if cfg.cas.enable then kube.Service("oauth2-cas-proxy") { |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 152 | metadata+: app.metadata("oauth2-cas-proxy"), |
| 153 | target_pod:: app.casDeployment.spec.template, |
| 154 | }, |
| 155 | |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 156 | synapseDeployment: kube.Deployment("synapse") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 157 | metadata+: app.metadata("synapse"), |
| 158 | spec+: { |
| 159 | replicas: 1, |
| 160 | template+: { |
| 161 | spec+: { |
| 162 | volumes_: { |
| 163 | data: kube.PersistentVolumeClaimVolume(app.dataVolume), |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 164 | config: kube.ConfigMapVolume(app.synapseConfigMap), |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 165 | } + { |
| 166 | [k]: { secret: { secretName: "appservice-%s-registration" % [k] } } |
| 167 | for k in std.objectFields(app.appservices) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 168 | }, |
| 169 | containers_: { |
| 170 | web: kube.Container("synapse") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 171 | image: cfg.images.synapse, |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 172 | command: ["/bin/sh", "-c", "/start.py migrate_config && exec /start.py"], |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 173 | ports_: { |
| 174 | http: { containerPort: 8008 }, |
Serge Bazanski | 1230ac3 | 2020-09-12 22:09:46 +0000 | [diff] [blame] | 175 | metrics: { containerPort: 9092 }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 176 | }, |
| 177 | env_: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 178 | SYNAPSE_CONFIG_DIR: "/tmp/config", |
| 179 | SYNAPSE_CONFIG_PATH: "/tmp/config/homeserver.yaml", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 180 | |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 181 | # These values are not used in a template, but |
| 182 | # are required by /start.py migrate_config |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 183 | SYNAPSE_SERVER_NAME: cfg.serverName, |
Piotr Dobrowolski | 8ebfc1d | 2020-03-03 21:01:18 +0100 | [diff] [blame] | 184 | SYNAPSE_REPORT_STATS: "no", |
| 185 | |
| 186 | SYNAPSE_MACAROON_SECRET_KEY: { secretKeyRef: { name: "synapse", key: "macaroon_secret_key" } }, |
| 187 | SYNAPSE_REGISTRATION_SHARED_SECRET: { secretKeyRef: { name: "synapse", key: "registration_shared_secret" } }, |
| 188 | POSTGRES_PASSWORD: { secretKeyRef: { name: "synapse", key: "postgres_password" } }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 189 | }, |
| 190 | volumeMounts_: { |
| 191 | data: { mountPath: "/data" }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 192 | config: { mountPath: "/conf", }, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 193 | } + { |
| 194 | [k]: { mountPath: "/appservices/%s" % [k] } |
| 195 | for k in std.objectFields(app.appservices) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 196 | }, |
| 197 | }, |
| 198 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 199 | securityContext: { |
| 200 | runAsUser: 991, |
| 201 | runAsGroup: 991, |
| 202 | fsGroup: 991, |
| 203 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 204 | }, |
| 205 | }, |
| 206 | }, |
| 207 | }, |
| 208 | |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 209 | synapseSvc: kube.Service("synapse") { |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 210 | metadata+: app.metadata("synapse"), |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 211 | target_pod:: app.synapseDeployment.spec.template, |
Piotr Dobrowolski | ffbb47c | 2019-05-16 12:18:39 +0200 | [diff] [blame] | 212 | }, |
| 213 | |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 214 | riotConfig:: { |
| 215 | "default_hs_url": "https://%s" % [cfg.webDomain], |
| 216 | "disable_custom_urls": false, |
| 217 | "disable_guests": false, |
| 218 | "disable_login_language_selector": false, |
| 219 | "disable_3pid_login": true, |
| 220 | "brand": "Riot", |
| 221 | "integrations_ui_url": "https://scalar.vector.im/", |
| 222 | "integrations_rest_url": "https://scalar.vector.im/api", |
| 223 | "integrations_jitsi_widget_url": "https://scalar.vector.im/api/widgets/jitsi.html", |
| 224 | |
| 225 | "bug_report_endpoint_url": "https://riot.im/bugreports/submit", |
| 226 | "features": { |
| 227 | "feature_groups": "labs", |
| 228 | "feature_pinning": "labs", |
| 229 | "feature_reactions": "labs" |
| 230 | }, |
| 231 | "default_federate": true, |
| 232 | "default_theme": "light", |
| 233 | "roomDirectory": { |
| 234 | "servers": [ |
| 235 | cfg.serverName, |
| 236 | ] |
| 237 | }, |
| 238 | "welcomeUserId": "@riot-bot:matrix.org", |
| 239 | "enable_presence_by_hs_url": { |
| 240 | "https://matrix.org": false |
| 241 | } |
| 242 | }, |
| 243 | |
| 244 | riotConfigMap: kube.ConfigMap("riot-web-config") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 245 | metadata+: app.metadata("riot-web-config"), |
| 246 | data: { |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 247 | "config.json": std.manifestJsonEx(app.riotConfig, ""), |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 248 | // Standard nginx.conf, made to work when running as unprivileged user. |
| 249 | "nginx.conf": ||| |
| 250 | worker_processes auto; |
| 251 | |
| 252 | error_log /tmp/nginx_error.log warn; |
| 253 | pid /tmp/nginx.pid; |
| 254 | |
| 255 | events { |
| 256 | worker_connections 1024; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | http { |
| 261 | client_body_temp_path /tmp/nginx_client_temp; |
| 262 | proxy_temp_path /tmp/nginx_proxy_temp; |
| 263 | fastcgi_temp_path /tmp/nginx_fastcgi_temp; |
| 264 | uwsgi_temp_path /tmp/nginx_uwsgi_temp; |
| 265 | scgi_temp_path /tmp/nginx_scgi_temp; |
| 266 | |
| 267 | include /etc/nginx/mime.types; |
| 268 | default_type application/octet-stream; |
| 269 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| 270 | '$status $body_bytes_sent "$http_referer" ' |
| 271 | '"$http_user_agent" "$http_x_forwarded_for"'; |
| 272 | access_log /tmp/nginx_access.log main; |
| 273 | sendfile on; |
| 274 | keepalive_timeout 65; |
| 275 | |
| 276 | server { |
| 277 | listen 8080; |
| 278 | server_name localhost; |
| 279 | |
| 280 | location / { |
| 281 | root /usr/share/nginx/html; |
| 282 | index index.html index.htm; |
| 283 | } |
| 284 | |
| 285 | error_page 500 502 503 504 /50x.html; |
| 286 | location = /50x.html { |
| 287 | root /usr/share/nginx/html; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |||, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 292 | }, |
| 293 | }, |
| 294 | |
| 295 | riotDeployment: kube.Deployment("riot-web") { |
| 296 | metadata+: app.metadata("riot-web"), |
| 297 | spec+: { |
| 298 | replicas: 1, |
| 299 | template+: { |
| 300 | spec+: { |
| 301 | volumes_: { |
Norbert Szulc | 1ef5600 | 2020-11-08 16:13:58 +0100 | [diff] [blame] | 302 | config: kube.ConfigMapVolume(app.riotConfigMap), |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 303 | }, |
| 304 | containers_: { |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 305 | web: kube.Container("riot-web") { |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 306 | image: cfg.images.riot, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 307 | ports_: { |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 308 | http: { containerPort: 8080 }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 309 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 310 | volumeMounts: [ |
| 311 | { |
| 312 | name: "config", |
Piotr Dobrowolski | aca7e28 | 2020-03-21 22:14:38 +0100 | [diff] [blame] | 313 | mountPath: "/app/config.json", |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 314 | subPath: "config.json", |
| 315 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 316 | { |
| 317 | name: "config", |
| 318 | mountPath: "/etc/nginx/nginx.conf", |
| 319 | subPath: "nginx.conf", |
| 320 | }, |
| 321 | ], |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 322 | }, |
| 323 | }, |
Serge Bazanski | 21a9616 | 2020-11-03 23:34:36 +0100 | [diff] [blame] | 324 | securityContext: { |
| 325 | // nginx:nginx |
| 326 | runAsUser: 101, |
| 327 | runAsGroup: 101, |
| 328 | }, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 329 | }, |
| 330 | }, |
| 331 | }, |
| 332 | }, |
| 333 | |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 334 | riotSvc: kube.Service("riot-web") { |
| 335 | metadata+: app.metadata("riot-web"), |
| 336 | target_pod:: app.riotDeployment.spec.template, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 337 | }, |
| 338 | |
Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 339 | // Any appservice you add here will require an appservice-X-registration |
| 340 | // secret containing a registration.yaml file. Adding something to this |
| 341 | // dictionary will cause Synapse to not start until that secret is |
| 342 | // available - so change things carefully! |
| 343 | // If bootstrapping a new appservice, just keep it out of this dictionary |
| 344 | // 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] | 345 | appservices: {}, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 346 | |
| 347 | ingress: kube.Ingress("matrix") { |
| 348 | metadata+: app.metadata("matrix") { |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 349 | annotations+: { |
| 350 | "kubernetes.io/tls-acme": "true", |
| 351 | "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod", |
| 352 | "nginx.ingress.kubernetes.io/proxy-body-size": "0", |
| 353 | }, |
| 354 | }, |
| 355 | spec+: { |
| 356 | tls: [ |
| 357 | { |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 358 | hosts: [cfg.webDomain], |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 359 | secretName: "synapse-tls", |
| 360 | }, |
| 361 | ], |
| 362 | rules: [ |
| 363 | { |
Serge Bazanski | 60076c7 | 2020-11-03 19:17:25 +0100 | [diff] [blame] | 364 | host: cfg.webDomain, |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 365 | http: { |
| 366 | paths: [ |
| 367 | { path: "/", backend: app.riotSvc.name_port }, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 368 | { path: "/_matrix", backend: app.synapseSvc.name_port }, |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 369 | ] + (if cfg.cas.enable then [ |
Piotr Dobrowolski | c39fb04 | 2019-05-17 09:13:56 +0200 | [diff] [blame] | 370 | { path: "/_cas", backend: app.casSvc.name_port }, |
Serge Bazanski | ace32c0 | 2020-11-03 22:04:06 +0100 | [diff] [blame] | 371 | ] else []) |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 372 | }, |
| 373 | } |
| 374 | ], |
| 375 | }, |
| 376 | }, |
Piotr Dobrowolski | fef4c12 | 2019-05-16 21:05:02 +0200 | [diff] [blame] | 377 | |
Piotr Dobrowolski | a222691 | 2019-05-14 18:49:29 +0200 | [diff] [blame] | 378 | } |