Sergiusz Bazanski | 6494696 | 2020-02-02 17:15:55 +0100 | [diff] [blame] | 1 | local mirko = import "../../kube/mirko.libsonnet"; |
| 2 | local kube = import "../../kube/kube.libsonnet"; |
| 3 | local postgres = import "../../kube/postgres.libsonnet"; |
| 4 | |
| 5 | { |
| 6 | local cfg = self.cfg, |
| 7 | cfg:: { |
| 8 | # Manually built from code.hackerspace.pl/q3k/ldap-web-public. |
| 9 | image: "frab/frab@sha256:30051f5153c4f02a8a1bee4b306bd696e2b018f2b13d16bd9c681fc1d633de3e", |
| 10 | storageClassName: error "storageClassName must be set!", |
| 11 | webFQDN: error "webFQDN must be set!", |
| 12 | |
| 13 | secret: { |
| 14 | secretKeyBase: error "secretKeyBase must be set!", |
| 15 | smtpPassword: error "smtpPassword must be set!", |
| 16 | }, |
| 17 | |
| 18 | smtp: { |
| 19 | server: "mail.hackerspace.pl", |
| 20 | from: "frab@hackerspace.pl", |
| 21 | username: "frab", |
| 22 | }, |
| 23 | }, |
| 24 | |
| 25 | component(cfg, env): mirko.Component(env, "frab") { |
| 26 | local frab = self, |
| 27 | cfg+: { |
| 28 | image: cfg.image, |
| 29 | volumes+: { |
| 30 | public: kube.PersistentVolumeClaimVolume(frab.volumePublic), |
| 31 | }, |
| 32 | |
| 33 | pgpass:: { secretKeyRef: { name: frab.makeName("-postgres"), key: "postgres_password", } }, |
| 34 | |
| 35 | container: frab.Container("main") { |
| 36 | volumeMounts_+: { |
| 37 | public: { mountPath: "/home/frab/app/public", }, |
| 38 | }, |
| 39 | // order matters (for POSTGRES_PASS substitution), we don't use env_ |
| 40 | env: [ |
| 41 | { name: "TZ", value: "Europe/Warsaw" }, |
| 42 | { name: "POSTGRES_PASS", valueFrom: frab.cfg.pgpass }, |
| 43 | { name: "DATABASE_URL", value: "postgresql://frab:$(POSTGRES_PASS)@%s/frab" % [frab.postgres.svc.host] }, |
| 44 | { name: "SECRET_KEY_BASE", valueFrom: kube.SecretKeyRef(frab.secret, "secretKeyBase") }, |
| 45 | { name: "FROM_EMAIL", value: cfg.smtp.from }, |
| 46 | { name: "SMTP_ADDRESS", value: cfg.smtp.server }, |
| 47 | { name: "SMTP_USERNAME", value: cfg.smtp.username }, |
| 48 | { name: "SMTP_PASSWORD", valueFrom: kube.SecretKeyRef(frab.secret, "smtpPassword") }, |
| 49 | { name: "SMTP_PORT", value: "587" }, |
| 50 | { name: "SMTP_NOTLS", value: "false" }, |
| 51 | ], |
| 52 | resources: { |
| 53 | // thicc RoR |
| 54 | requests: { |
| 55 | cpu: "100m", |
| 56 | memory: "512Mi", |
| 57 | }, |
| 58 | limits: { |
| 59 | cpu: "1", |
| 60 | memory: "1Gi", |
| 61 | }, |
| 62 | }, |
| 63 | }, |
| 64 | ports+: { |
| 65 | publicHTTP: { |
| 66 | web: { |
| 67 | port: 3000, |
| 68 | dns: cfg.webFQDN, |
| 69 | }, |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | |
| 74 | secret: kube.Secret(frab.makeName("-secret")) { |
| 75 | metadata+: frab.metadata, |
| 76 | data: cfg.secret, |
| 77 | }, |
| 78 | |
| 79 | postgres: postgres { |
| 80 | cfg+: { |
| 81 | namespace: frab.metadata.namespace, |
Sergiusz Bazanski | e95c0e2 | 2020-02-15 12:40:25 +0100 | [diff] [blame] | 82 | appName: "frab", |
Sergiusz Bazanski | 6494696 | 2020-02-02 17:15:55 +0100 | [diff] [blame] | 83 | storageClassName: cfg.storageClassName, |
| 84 | prefix: frab.makeName("-postgres") + "-", |
| 85 | database: "frab", |
| 86 | username: "frab", |
| 87 | password: frab.cfg.pgpass, |
| 88 | }, |
| 89 | }, |
| 90 | |
| 91 | volumePublic: kube.PersistentVolumeClaim(frab.makeName("-public")) { |
| 92 | metadata+: frab.metadata, |
| 93 | spec+: { |
| 94 | storageClassName: cfg.storageClassName, |
| 95 | accessModes: ["ReadWriteOnce"], |
| 96 | resources: { |
| 97 | requests: { |
| 98 | storage: "5Gi", |
| 99 | }, |
| 100 | }, |
| 101 | }, |
| 102 | }, |
| 103 | }, |
| 104 | } |