blob: 1b6800bea8de40b31abd7f9f4f04549003416b7c [file] [log] [blame]
Serge Bazanski5e695e82021-03-07 14:29:40 +00001// Production deployment of oodviewer.q3k.me.
2//
3// See README.md for more information.
4
Radek Pietruszewskif5844312023-10-27 22:41:18 +02005local kube = import "../../kube/hscloud.libsonnet";
Serge Bazanski5e695e82021-03-07 14:29:40 +00006
7{
8 local top = self,
9 local cfg = self.cfg,
radex99ed6a72023-11-24 11:42:55 +010010 local ns = kube.Namespace("oodviewer-prod"),
Serge Bazanski5e695e82021-03-07 14:29:40 +000011
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 Bazanski25c53fc2021-03-16 21:28:48 +010019 image: "registry.k0.hswaw.net/q3k/oodviewer:315532800-5cd20075113e74d0a69f501c74db766cba597662",
Serge Bazanski5e695e82021-03-07 14:29:40 +000020 domain: "oodviewer.q3k.me",
21 },
22
radex99ed6a72023-11-24 11:42:55 +010023 secret: ns.Contain(kube.Secret("oodviewer")) {
Serge Bazanski5e695e82021-03-07 14:29:40 +000024 data_: {
25 "postgres": cfg.postgresConnectionString,
26 },
27 },
28
radex99ed6a72023-11-24 11:42:55 +010029 deploy: ns.Contain(kube.Deployment("oodviewer")) {
Serge Bazanski5e695e82021-03-07 14:29:40 +000030 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
radex99ed6a72023-11-24 11:42:55 +010059 service: ns.Contain(kube.Service("oodviewer")) {
radex8b8f3872023-11-24 11:09:46 +010060 target:: top.deploy,
Serge Bazanski5e695e82021-03-07 14:29:40 +000061 },
62
radex99ed6a72023-11-24 11:42:55 +010063 ingress: ns.Contain(kube.SimpleIngress("oodviewer")) {
Radek Pietruszewskif5844312023-10-27 22:41:18 +020064 hosts:: [cfg.domain],
radexd45584a2023-11-24 12:51:57 +010065 target:: top.service,
Radek Pietruszewskif5844312023-10-27 22:41:18 +020066 },
Serge Bazanski5e695e82021-03-07 14:29:40 +000067}