Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 1 | local kube = import "../../kube/hscloud.libsonnet"; |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 2 | local postgres = import '../../kube/postgres_v.libsonnet'; |
| 3 | |
| 4 | { |
| 5 | local top = self, |
| 6 | local cfg = top.cfg, |
| 7 | |
| 8 | cfg:: { |
| 9 | name: 'inventory', |
| 10 | namespace: 'inventory', |
| 11 | domain: 'inventory.hackerspace.pl', |
| 12 | |
| 13 | image: 'registry.k0.hswaw.net/palid/spejstore:1694280421', |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 14 | oauthClientId: '82fffb65-0bbd-4d18-becd-0ce0b31373cf', |
| 15 | storageClassName: 'waw-hdd-redundant-3', |
| 16 | |
| 17 | mediaPath: '/var/www/media', |
| 18 | }, |
| 19 | |
radex | 1439fde | 2023-11-24 12:22:22 +0100 | [diff] [blame] | 20 | secretRefs:: { |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 21 | postgres: { secretKeyRef: { name: cfg.name, key: 'postgres_password' } }, |
| 22 | oauth: { secretKeyRef: { name: cfg.name, key: 'oauth_secret' } }, |
| 23 | }, |
| 24 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 25 | local ns = kube.Namespace(cfg.namespace), |
| 26 | |
| 27 | deployment: ns.Contain(kube.Deployment(cfg.name)) { |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 28 | spec+: { |
| 29 | template+: { |
| 30 | spec+: { |
| 31 | volumes_: { |
| 32 | media: kube.PersistentVolumeClaimVolume(top.media), |
| 33 | }, |
| 34 | containers_: { |
| 35 | default: kube.Container('default') { |
| 36 | image: cfg.image, |
| 37 | ports_: { |
| 38 | web: { containerPort: 8000 }, |
| 39 | }, |
| 40 | env_: { |
| 41 | SPEJSTORE_ENV: 'prod', |
radex | 3799174 | 2023-11-24 12:37:37 +0100 | [diff] [blame^] | 42 | SPEJSTORE_DB_NAME: top.postgres.cfg.database, |
| 43 | SPEJSTORE_DB_USER: top.postgres.cfg.username, |
| 44 | SPEJSTORE_DB_PASSWORD: top.postgres.cfg.password, |
| 45 | SPEJSTORE_DB_HOST: top.postgres.svc.host, |
| 46 | SPEJSTORE_DB_PORT: top.postgres.svc.port, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 47 | SPEJSTORE_ALLOWED_HOSTS: cfg.domain, |
| 48 | SPEJSTORE_CLIENT_ID: cfg.oauthClientId, |
radex | 1439fde | 2023-11-24 12:22:22 +0100 | [diff] [blame] | 49 | SPEJSTORE_SECRET: top.secretRefs.oauth, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 50 | SPEJSTORE_MEDIA_ROOT: cfg.mediaPath, |
| 51 | SPEJSTORE_REQUIRE_AUTH: 'true', |
| 52 | SPEJSTORE_LAN_ALLOWED_ADDRESS_SPACE: '185.236.240.5', |
| 53 | }, |
| 54 | volumeMounts_: { |
| 55 | media: { mountPath: cfg.mediaPath }, |
| 56 | }, |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | }, |
| 61 | }, |
| 62 | }, |
| 63 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 64 | media: ns.Contain(kube.PersistentVolumeClaim(cfg.name)) { |
radex | 36964dc | 2023-11-24 11:19:46 +0100 | [diff] [blame] | 65 | storage:: '20Gi', |
| 66 | storageClass:: cfg.storageClassName, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 67 | }, |
| 68 | |
radex | 3799174 | 2023-11-24 12:37:37 +0100 | [diff] [blame^] | 69 | postgres: postgres { |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 70 | cfg+: { |
| 71 | namespace: cfg.namespace, |
| 72 | appName: cfg.name, |
| 73 | storageClassName: cfg.storageClassName, |
| 74 | version: '15.4', |
| 75 | |
radex | 3799174 | 2023-11-24 12:37:37 +0100 | [diff] [blame^] | 76 | database: 'inventory', |
| 77 | username: 'inventory', |
radex | 1439fde | 2023-11-24 12:22:22 +0100 | [diff] [blame] | 78 | password: top.secretRefs.postgres, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 79 | }, |
| 80 | bouncer: {}, |
| 81 | }, |
| 82 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 83 | service: ns.Contain(kube.Service(cfg.name)) { |
radex | 8b8f387 | 2023-11-24 11:09:46 +0100 | [diff] [blame] | 84 | target:: top.deployment, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 85 | }, |
| 86 | |
radex | 99ed6a7 | 2023-11-24 11:42:55 +0100 | [diff] [blame] | 87 | ingress: ns.Contain(kube.SimpleIngress(cfg.name)) { |
Radek Pietruszewski | f584431 | 2023-10-27 22:41:18 +0200 | [diff] [blame] | 88 | hosts:: [cfg.domain], |
| 89 | target_service:: top.service, |
Dariusz Niemczyk | 62b83e0 | 2023-08-13 20:14:15 +0200 | [diff] [blame] | 90 | }, |
| 91 | } |