Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 1 | // Production deployment of oodviewer.q3k.me. |
| 2 | // |
| 3 | // See README.md for more information. |
| 4 | |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 5 | local kube = import "../../kube/hscloud.libsonnet"; |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 6 | |
| 7 | { |
| 8 | local top = self, |
| 9 | local cfg = self.cfg, |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 10 | local ns = kube.Namespace("oodviewer-prod"), |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 11 | |
| 12 | cfg:: { |
| 13 | dbUser: "ood", |
| 14 | dbPass: std.split(importstr "secrets/plain/postgres-pass", "\n")[0], |
| 15 | dbHost: "hackerspace.pl", |
| 16 | dbName: "ood", |
| 17 | postgresConnectionString: "postgres://%s:%s@%s/%s?sslmode=disable" % [cfg.dbUser, cfg.dbPass, cfg.dbHost, cfg.dbName], |
| 18 | |
Serge Bazanski | 25c53fc | 2021-03-16 21:28:48 +0100 | [diff] [blame] | 19 | image: "registry.k0.hswaw.net/q3k/oodviewer:315532800-5cd20075113e74d0a69f501c74db766cba597662", |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 20 | domain: "oodviewer.q3k.me", |
| 21 | }, |
| 22 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 23 | secret: ns.Contain(kube.Secret("oodviewer")) { |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 24 | data_: { |
| 25 | "postgres": cfg.postgresConnectionString, |
| 26 | }, |
| 27 | }, |
| 28 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 29 | deploy: ns.Contain(kube.Deployment("oodviewer")) { |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 30 | spec+: { |
| 31 | replicas: 3, |
| 32 | template+: { |
| 33 | spec+: { |
| 34 | containers_: { |
| 35 | default: kube.Container("default") { |
| 36 | image: cfg.image, |
| 37 | command: [ |
| 38 | "/hswaw/oodviewer", |
| 39 | "-listen", "0.0.0.0:8080", |
| 40 | "-postgres", "$(POSTGRES)", |
| 41 | ], |
| 42 | env_: { |
| 43 | POSTGRES: kube.SecretKeyRef(top.secret, "postgres"), |
| 44 | }, |
| 45 | resources: { |
| 46 | requests: { cpu: "0.01", memory: "64M" }, |
| 47 | limits: { cpu: "1", memory: "256M" }, |
| 48 | }, |
| 49 | ports_: { |
| 50 | http: { containerPort: 8080 }, |
| 51 | }, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | }, |
| 58 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 59 | service: ns.Contain(kube.Service("oodviewer")) { |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame] | 60 | target:: top.deploy, |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 61 | }, |
| 62 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 63 | ingress: ns.Contain(kube.SimpleIngress("oodviewer")) { |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 64 | hosts:: [cfg.domain], |
radex | d45584a | 2023-11-24 12:51:57 +0100 | [diff] [blame] | 65 | target:: top.service, |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 66 | }, |
Serge Bazanski | 5e695e8 | 2021-03-07 14:29:40 +0000 | [diff] [blame] | 67 | } |