| // Production deployment of oodviewer.q3k.me. |
| // |
| // See README.md for more information. |
| |
| local kube = import "../../kube/hscloud.libsonnet"; |
| |
| { |
| local top = self, |
| local cfg = self.cfg, |
| local ns = kube.Namespace("oodviewer-prod"), |
| |
| cfg:: { |
| dbUser: "ood", |
| dbPass: std.split(importstr "secrets/plain/postgres-pass", "\n")[0], |
| dbHost: "hackerspace.pl", |
| dbName: "ood", |
| postgresConnectionString: "postgres://%s:%s@%s/%s?sslmode=disable" % [cfg.dbUser, cfg.dbPass, cfg.dbHost, cfg.dbName], |
| |
| image: "registry.k0.hswaw.net/q3k/oodviewer:315532800-5cd20075113e74d0a69f501c74db766cba597662", |
| domain: "oodviewer.q3k.me", |
| }, |
| |
| secret: ns.Contain(kube.Secret("oodviewer")) { |
| data_: { |
| "postgres": cfg.postgresConnectionString, |
| }, |
| }, |
| |
| deploy: ns.Contain(kube.Deployment("oodviewer")) { |
| spec+: { |
| replicas: 3, |
| template+: { |
| spec+: { |
| containers_: { |
| default: kube.Container("default") { |
| image: cfg.image, |
| command: [ |
| "/hswaw/oodviewer", |
| "-listen", "0.0.0.0:8080", |
| "-postgres", "$(POSTGRES)", |
| ], |
| env_: { |
| POSTGRES: kube.SecretKeyRef(top.secret, "postgres"), |
| }, |
| resources: { |
| requests: { cpu: "0.01", memory: "64M" }, |
| limits: { cpu: "1", memory: "256M" }, |
| }, |
| ports_: { |
| http: { containerPort: 8080 }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| |
| service: ns.Contain(kube.Service("oodviewer")) { |
| target:: top.deploy, |
| }, |
| |
| ingress: ns.Contain(kube.SimpleIngress("oodviewer")) { |
| hosts:: [cfg.domain], |
| target:: top.service, |
| }, |
| } |