| local kube = import "../../kube/hscloud.libsonnet"; |
| local postgres = import "../../kube/postgres.libsonnet"; |
| |
| { |
| local top = self, |
| local cfg = top.cfg, |
| |
| cfg:: { |
| namespace: "redmine", |
| image: "registry.k0.hswaw.net/informatic/redmine@sha256:b04d1fd04549424e505722c9feb0b6741a057cb8f0fab68ad3730ecb167417df", |
| domain: error "domain must be set", |
| storageClassName: "waw-hdd-redundant-3", |
| database: { |
| password: { secretKeyRef: { name: "redmine", key: "postgres_password" } }, |
| }, |
| |
| b: { |
| domains: [], |
| image: "registry.k0.hswaw.net/q3k/b:315532800-6cc2f867951e123909b23955cd7bcbcc3ec24f8a", |
| }, |
| |
| storage: { |
| endpoint: error "storage.endpoint must be set", |
| region: error "storage.region must be set", |
| bucket: error "storage.bucket must be set", |
| accessKey: error "storage.accessKey must be set", |
| secretKey: error "storage.secretKey must be set", |
| }, |
| |
| oidc: { |
| server: error "oidc.server must be set", |
| clientID: error "oidc.clientID must be set", |
| clientSecret: error "oidc.clientSecret must be set", |
| }, |
| |
| # Mailing configuration object passed to smtp_settings |
| mailing: { |
| address: error "mailing.address must be set", |
| port: 465, |
| ssl: true, |
| domain: error "mailing.domain must be set", |
| authentication: ":login", |
| user_name: error "mailing.user_name must be set", |
| password: error "mailing.password must be set", |
| }, |
| }, |
| |
| # Generates YAML file while preserving specified ruby-style symbols. |
| # (ie. removes surrounding quotes) |
| rubyYaml(obj, symbols):: std.foldr(function (symbol, str) std.strReplace(str, '"%s"' % symbol, symbol), symbols, std.manifestYamlDoc(obj)), |
| |
| local ns = kube.Namespace(cfg.namespace), |
| |
| postgres: ns.Contain(postgres) { |
| cfg+: { |
| version: "10.4", |
| appName: "redmine", |
| database: "redmine", |
| username: "redmine", |
| password: cfg.database.password, |
| storageClassName: cfg.storageClassName, |
| }, |
| }, |
| |
| deployment: ns.Contain(kube.Deployment("redmine")) { |
| spec+: { |
| replicas: 1, |
| template+: { |
| spec+: { |
| securityContext: { |
| runAsUser: 999, |
| runAsGroup: 999, |
| fsGroup: 999, |
| }, |
| containers_: { |
| web: kube.Container("redmine") { |
| image: cfg.image, |
| args: ['sh', '-c', ||| |
| set -e |
| echo "${X_EXTRA_CONFIGURATION}" > config/configuration.yml |
| exec /docker-entrypoint.sh rails server -b 0.0.0.0 |
| |||], |
| ports_: { |
| http: { containerPort: 3000 }, |
| }, |
| env_: { |
| REDMINE_DB_POSTGRES: top.postgres.svc.host, |
| REDMINE_DB_PORT: top.postgres.svc.port, |
| REDMINE_DB_DATABASE: top.postgres.cfg.database, |
| REDMINE_DB_USERNAME: top.postgres.cfg.username, |
| REDMINE_DB_PASSWORD: top.postgres.cfg.password, |
| |
| REDMINE_SECRET_KEY_BASE: { secretKeyRef: { name: "redmine", key: "secret_key" } }, |
| |
| REDMINE_OIDC_SERVER: cfg.oidc.server, |
| REDMINE_OIDC_CLIENT_ID: cfg.oidc.clientID, |
| REDMINE_OIDC_CLIENT_SECRET: cfg.oidc.clientSecret, |
| REDMINE_OIDC_ADMIN_GROUP: "issues-admin", |
| |
| REDMINE_S3_ENDPOINT: cfg.storage.endpoint, |
| REDMINE_S3_BUCKET: cfg.storage.bucket, |
| REDMINE_S3_ACCESS_KEY_ID: cfg.storage.accessKey, |
| REDMINE_S3_SECRET_ACCESS_KEY: cfg.storage.secretKey, |
| REDMINE_S3_REGION: cfg.storage.region, |
| |
| REDMINE_MAILING_PASSWORD: cfg.mailing.password, |
| X_EXTRA_CONFIGURATION: top.rubyYaml({ |
| production: { |
| email_delivery: { |
| delivery_method: ":smtp", |
| smtp_settings: cfg.mailing { |
| password: "$(REDMINE_MAILING_PASSWORD)", |
| }, |
| } |
| }, |
| }, [":smtp", ":login"]), |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| |
| svc: ns.Contain(kube.Service("redmine")) { |
| target:: top.deployment, |
| }, |
| |
| ingress: ns.Contain(kube.SimpleIngress("redmine")) { |
| hosts:: [cfg.domain], |
| target:: top.svc, |
| }, |
| |
| b: (if std.length(cfg.b.domains) > 0 then { |
| deployment: ns.Contain(kube.Deployment("b")) { |
| spec+: { |
| replicas: 3, |
| template+: { |
| spec+: { |
| containers_: { |
| default: kube.Container("default") { |
| image: "registry.k0.hswaw.net/q3k/b:315532800-6cc2f867951e123909b23955cd7bcbcc3ec24f8a", |
| ports_: { |
| http: { containerPort: 8000 }, |
| }, |
| command: [ |
| "/devtools/issues/b", |
| ], |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| svc: ns.Contain(kube.Service("b")) { |
| target:: top.b.deployment, |
| }, |
| ingress: ns.Contain(kube.SimpleIngress("b")) { |
| hosts:: cfg.b.domains, |
| target:: top.b.svc, |
| }, |
| } else {}), |
| |
| } |