From 7ea6e4167a560b4ba5a89e56c25f2c06f794159c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Fri, 20 Oct 2023 12:08:53 +0200 Subject: [PATCH] fix --- apps/dbgate/configs.tf | 18 +- apps/dbgate/index.yaml | 174 +++++++++-------- meta/domain-devspaces/apps.tf | 11 ++ meta/domain-devspaces/index.yaml | 308 ++++++++++++++++--------------- meta/domain/index.yaml | 214 ++++++++++----------- meta/domain/installs.tf | 24 ++- 6 files changed, 408 insertions(+), 341 deletions(-) diff --git a/apps/dbgate/configs.tf b/apps/dbgate/configs.tf index 8fbb600..ac93adf 100644 --- a/apps/dbgate/configs.tf +++ b/apps/dbgate/configs.tf @@ -1,6 +1,6 @@ locals { pg_vars = merge([for pg in var.pg: { - join("_",["LABEL_pg", pg.namespace, pg.name, pg.dbname]) = join(" | ",["pg", pg.namespace, pg.name, pg.dbname]) + join("_",["LABEL_pg", pg.namespace, pg.name, pg.dbname]) = join(" | ",[pg.namespace, pg.name, pg.dbname]) join("_",["ENGINE_pg", pg.namespace, pg.name, pg.dbname]) = "postgres@dbgate-plugin-postgres" join("_",["SERVER_pg", pg.namespace, pg.name, pg.dbname]) = join(".",["${pg.name}-rw", pg.namespace, "svc"]) join("_",["PORT_pg", pg.namespace, pg.name, pg.dbname]) = "5432" @@ -13,7 +13,7 @@ locals { pg_conns = [for pg in var.pg: join("_",["pg", pg.namespace, pg.name, pg.dbname])] maria_vars = merge([for m in var.maria: { - join("_",["LABEL_maria", m.namespace, m.name]) = join(" | ",["maria", m.namespace, m.name]) + join("_",["LABEL_maria", m.namespace, m.name]) = join(" | ",[m.namespace, m.name]) join("_",["ENGINE_maria", m.namespace, m.name]) = "mysql@dbgate-plugin-mysql" join("_",["SERVER_maria", m.namespace, m.name]) = join(".",["${m.name}-svc", m.namespace, "svc"]) join("_",["PORT_maria", m.namespace, m.name]) = "3306" @@ -25,6 +25,14 @@ locals { }]...) maria_conns = [for m in var.maria: join("_",["maria", m.namespace, m.name])] + redis_vars = merge([for m in var.redis: { + join("_",["LABEL_redis", m.namespace, m.name]) = join(" | ",[m.namespace, m.name]) + join("_",["ENGINE_redis", m.namespace, m.name]) = "redis@dbgate-plugin-redis" + join("_",["SERVER_redis", m.namespace, m.name]) = join(".",[m.name, m.namespace, "svc"]) + join("_",["PORT_redis", m.namespace, m.name]) = "6379" + }]...) + redis_conns = [for m in var.maria: join("_",["redis", m.namespace, m.name])] + mongo_vars = merge([for m in var.mongo: { join("_",["LABEL_mongo", m.namespace, m.name]) = join(" | ",["mongo", m.namespace, m.name]) join("_",["ENGINE_mongo", m.namespace, m.name]) = "mongo@dbgate-plugin-mongo" @@ -41,9 +49,9 @@ locals { "OAUTH_LOGIN_FIELD" = "nickname" "OAUTH_SCOPE" = "email" } - connections = join(",",concat(local.pg_conns, local.maria_conns, local.mongo_conns)) - connection_vars = merge(local.pg_vars, local.maria_vars, local.mongo_vars) - connection_secrets = merge(local.pg_secrets,local.mongo_secrets) + connections = join(",", concat(local.pg_conns, local.maria_conns, local.mongo_conns, local.redis_conns)) + connection_vars = merge(local.pg_vars, local.maria_vars, local.mongo_vars, local.redis_conns) + connection_secrets = merge(local.pg_secrets, local.mongo_secrets) } resource "kubectl_manifest" "dbgate-config" { diff --git a/apps/dbgate/index.yaml b/apps/dbgate/index.yaml index 2a881f2..55fee9f 100644 --- a/apps/dbgate/index.yaml +++ b/apps/dbgate/index.yaml @@ -6,6 +6,16 @@ metadata: name: dbgate description: null options: + use-oauth: + default: false + examples: + - false + type: boolean + domain: + default: your-company + examples: + - your-company + type: string maria: default: [] examples: @@ -35,16 +45,40 @@ options: type: string type: object type: array - app-group: - default: dev + ingress-class: + default: traefik examples: - - dev + - traefik type: string - issuer: - default: letsencrypt-prod + mongo: + default: [] examples: - - letsencrypt-prod - type: string + - [] + items: + properties: + dbname: + default: '' + type: string + name: + default: '' + type: string + namespace: + default: '' + type: string + secret: + properties: + key: + default: '' + type: string + name: + default: '' + type: string + type: object + username: + default: '' + type: string + type: object + type: array images: default: dbgate: @@ -84,47 +118,39 @@ options: type: string type: object type: object - storage: - default: - accessMode: ReadWriteOnce - size: 1Gi - type: Filesystem - examples: - - accessMode: ReadWriteOnce - size: 1Gi - type: Filesystem - properties: - accessMode: - default: ReadWriteOnce - enum: - - ReadWriteOnce - - ReadOnlyMany - - ReadWriteMany - type: string - size: - default: 1Gi - type: string - type: - default: Filesystem - enum: - - Filesystem - - Block - type: string - type: object - domain-name: - default: your_company.com - examples: - - your_company.com - type: string sub-domain: default: dbgate examples: - dbgate type: string - domain: - default: your-company + issuer: + default: letsencrypt-prod examples: - - your-company + - letsencrypt-prod + type: string + redis: + default: [] + examples: + - [] + items: + properties: + name: + default: '' + type: string + namespace: + default: '' + type: string + type: object + type: array + domain-name: + default: your_company.com + examples: + - your_company.com + type: string + app-group: + default: dev + examples: + - dev type: string pg: default: [] @@ -155,45 +181,33 @@ options: type: string type: object type: array - mongo: - default: [] + storage: + default: + accessMode: ReadWriteOnce + size: 1Gi + type: Filesystem examples: - - [] - items: - properties: - dbname: - default: '' - type: string - name: - default: '' - type: string - namespace: - default: '' - type: string - secret: - properties: - key: - default: '' - type: string - name: - default: '' - type: string - type: object - username: - default: '' - type: string - type: object - type: array - ingress-class: - default: traefik - examples: - - traefik - type: string - use-oauth: - default: false - examples: - - false - type: boolean + - accessMode: ReadWriteOnce + size: 1Gi + type: Filesystem + properties: + accessMode: + default: ReadWriteOnce + enum: + - ReadWriteOnce + - ReadOnlyMany + - ReadWriteMany + type: string + size: + default: 1Gi + type: string + type: + default: Filesystem + enum: + - Filesystem + - Block + type: string + type: object dependencies: - dist: null category: share diff --git a/meta/domain-devspaces/apps.tf b/meta/domain-devspaces/apps.tf index 23606de..07897ec 100644 --- a/meta/domain-devspaces/apps.tf +++ b/meta/domain-devspaces/apps.tf @@ -99,6 +99,17 @@ locals { } if ds.engine=="mongo"]])]), var.external-mongos ) + "redis" = concat( + flatten([for ds in local.sorted-datasets: { + "name" = "${ds.name}-dataset-redis" + "namespace" = ds.namespace + } if ds.engine=="mongo"]), + flatten([for org in local.sorted-organisations: flatten([for stage in lookup(org, "stages", []): [for ds in org.datasets: { + "name" = "${ds.name}-dataset-redis" + "namespace" = "${var.domain}-${org.name}-${stage.name}" + } if ds.engine=="mongo"]])]), + var.external-redis + ) }, { for k, v in var.apps.dbgate : k => v if k!="enable" }) } diff --git a/meta/domain-devspaces/index.yaml b/meta/domain-devspaces/index.yaml index b5272fd..5ac15d5 100644 --- a/meta/domain-devspaces/index.yaml +++ b/meta/domain-devspaces/index.yaml @@ -6,95 +6,7 @@ metadata: name: domain-devspaces description: null options: - domain-name: - default: your_company.com - examples: - - your_company.com - type: string - images: - default: - codeserver: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.15 - examples: - - codeserver: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.15 - properties: - codeserver: - default: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.15 - properties: - pullPolicy: - default: IfNotPresent - enum: - - Always - - Never - - IfNotPresent - type: string - registry: - default: docker.io - type: string - repository: - default: sebt3/code-server - type: string - tag: - default: 4.15 - type: number - type: object - type: object - distributions: - default: - core: core - domain: domain - examples: - - core: core - domain: domain - properties: - core: - default: core - type: string - domain: - default: domain - type: string - type: object - external-pgs: - default: [] - examples: - - [] - items: - properties: - dbname: - default: '' - type: string - name: - default: '' - type: string - namespace: - default: '' - type: string - secret: - properties: - key: - default: '' - type: string - name: - default: '' - type: string - type: object - username: - default: '' - type: string - type: object - type: array - external-marias: + stations: default: [] examples: - [] @@ -103,21 +15,11 @@ options: name: default: '' type: string - namespace: - default: '' - type: string - secret: - properties: - key: - default: '' - type: string - name: - default: '' - type: string - type: object - username: - default: '' - type: string + organisations: + default: [] + items: + type: string + type: array type: object type: array organisations: @@ -161,41 +63,40 @@ options: type: array type: object type: array - storage-classes: - default: - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' + domain-name: + default: your_company.com examples: - - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - properties: - BlockReadWriteMany: - default: '' - type: string - BlockReadWriteOnce: - default: '' - type: string - FilesystemReadWriteMany: - default: '' - type: string - FilesystemReadWriteOnce: - default: '' - type: string - type: object - domain: - default: your-company - examples: - - your-company + - your_company.com type: string - issuer: - default: letsencrypt-prod + external-pgs: + default: [] examples: - - letsencrypt-prod - type: string + - [] + items: + properties: + dbname: + default: '' + type: string + name: + default: '' + type: string + namespace: + default: '' + type: string + secret: + properties: + key: + default: '' + type: string + name: + default: '' + type: string + type: object + username: + default: '' + type: string + type: object + type: array stations-sub-domain: default: code examples: @@ -231,7 +132,7 @@ options: default: backup-settings type: string type: object - stations: + external-marias: default: [] examples: - [] @@ -240,11 +141,21 @@ options: name: default: '' type: string - organisations: - default: [] - items: - type: string - type: array + namespace: + default: '' + type: string + secret: + properties: + key: + default: '' + type: string + name: + default: '' + type: string + type: object + username: + default: '' + type: string type: object type: array external-mongos: @@ -276,11 +187,119 @@ options: type: string type: object type: array + distributions: + default: + core: core + domain: domain + examples: + - core: core + domain: domain + properties: + core: + default: core + type: string + domain: + default: domain + type: string + type: object + external-redis: + default: [] + examples: + - [] + items: + properties: + name: + default: '' + type: string + namespace: + default: '' + type: string + type: object + type: array + images: + default: + codeserver: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.15 + examples: + - codeserver: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.15 + properties: + codeserver: + default: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.15 + properties: + pullPolicy: + default: IfNotPresent + enum: + - Always + - Never + - IfNotPresent + type: string + registry: + default: docker.io + type: string + repository: + default: sebt3/code-server + type: string + tag: + default: 4.15 + type: number + type: object + type: object + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + type: string + domain: + default: your-company + examples: + - your-company + type: string ingress-class: default: traefik examples: - traefik type: string + app-group: + default: dev + examples: + - dev + type: string + storage-classes: + default: + BlockReadWriteMany: '' + BlockReadWriteOnce: '' + FilesystemReadWriteMany: '' + FilesystemReadWriteOnce: '' + examples: + - BlockReadWriteMany: '' + BlockReadWriteOnce: '' + FilesystemReadWriteMany: '' + FilesystemReadWriteOnce: '' + properties: + BlockReadWriteMany: + default: '' + type: string + BlockReadWriteOnce: + default: '' + type: string + FilesystemReadWriteMany: + default: '' + type: string + FilesystemReadWriteOnce: + default: '' + type: string + type: object apps: default: dbgate: @@ -334,11 +353,6 @@ options: type: boolean type: object type: object - app-group: - default: dev - examples: - - dev - type: string dependencies: [] providers: kubernetes: true diff --git a/meta/domain/index.yaml b/meta/domain/index.yaml index 17905bd..04198a9 100644 --- a/meta/domain/index.yaml +++ b/meta/domain/index.yaml @@ -6,43 +6,65 @@ metadata: name: domain description: null options: - auth: + apps: default: - enable: true + enable: false + nextcloud: + enable: true examples: - - enable: true + - enable: false + nextcloud: + enable: true properties: enable: - default: true + default: false type: boolean + nextcloud: + default: + enable: true + properties: + enable: + default: true + type: boolean + type: object type: object ingress-class: default: traefik examples: - traefik type: string - infra: + domain-name: + default: your_company.com + examples: + - your_company.com + type: string + ci: default: enable: false - traefik: - enable: false + gitea: + enable: true examples: - enable: false - traefik: - enable: false + gitea: + enable: true properties: enable: default: false type: boolean - traefik: + gitea: default: - enable: false + enable: true properties: enable: - default: false + default: true type: boolean type: object type: object + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + type: string erp: default: dolibarr: @@ -65,36 +87,16 @@ options: default: false type: boolean type: object - distributions: + auth: default: - core: core - domain: domain + enable: true examples: - - core: core - domain: domain - properties: - core: - default: core - type: string - domain: - default: domain - type: string - type: object - devspaces: - default: - enable: false - examples: - - enable: false + - enable: true properties: enable: - default: false + default: true type: boolean type: object - domain-name: - default: your_company.com - examples: - - your_company.com - type: string backups: default: enable: false @@ -125,6 +127,75 @@ options: default: backup-settings type: string type: object + infra: + default: + enable: false + traefik: + enable: false + examples: + - enable: false + traefik: + enable: false + properties: + enable: + default: false + type: boolean + traefik: + default: + enable: false + properties: + enable: + default: false + type: boolean + type: object + type: object + devspaces: + default: + enable: false + examples: + - enable: false + properties: + enable: + default: false + type: boolean + type: object + distributions: + default: + core: core + domain: domain + examples: + - core: core + domain: domain + properties: + core: + default: core + type: string + domain: + default: domain + type: string + type: object + mail: + default: + enable: false + wildduck: + enable: true + examples: + - enable: false + wildduck: + enable: true + properties: + enable: + default: false + type: boolean + wildduck: + default: + enable: true + properties: + enable: + default: true + type: boolean + type: object + type: object storage-classes: default: BlockReadWriteMany: '' @@ -150,77 +221,6 @@ options: default: '' type: string type: object - issuer: - default: letsencrypt-prod - examples: - - letsencrypt-prod - type: string - apps: - default: - enable: false - nextcloud: - enable: true - examples: - - enable: false - nextcloud: - enable: true - properties: - enable: - default: false - type: boolean - nextcloud: - default: - enable: true - properties: - enable: - default: true - type: boolean - type: object - type: object - mail: - default: - enable: false - wildduck: - enable: true - examples: - - enable: false - wildduck: - enable: true - properties: - enable: - default: false - type: boolean - wildduck: - default: - enable: true - properties: - enable: - default: true - type: boolean - type: object - type: object - ci: - default: - enable: false - gitea: - enable: true - examples: - - enable: false - gitea: - enable: true - properties: - enable: - default: false - type: boolean - gitea: - default: - enable: true - properties: - enable: - default: true - type: boolean - type: object - type: object dependencies: [] providers: kubernetes: null diff --git a/meta/domain/installs.tf b/meta/domain/installs.tf index 4f6eb0e..39d589f 100644 --- a/meta/domain/installs.tf +++ b/meta/domain/installs.tf @@ -81,7 +81,27 @@ locals { "name" = "gitea-gitea-pg-app" "key" = "password" } - }]:[]) + }]:[], lookup(var.devspaces, "external-pgs", [])) + external-mongos = concat(var.mail.enable&&var.mail.wildduck.enable?[{ + "name" = "wildduck-wildduck-mongo" + "dbname" = "wildduck" + "username" = "wildduck" + "namespace" = "${var.namespace}-mail" + "secret" = { + "name" = "wildduck-wildduck-mongo" + "key" = "password" + } + }]:[], lookup(var.devspaces, "external-mongos", [])) + external-redis = concat(var.mail.enable&&var.mail.wildduck.enable?[{ + "name" = "wildduck-wildduck-redis" + "namespace" = "${var.namespace}-mail" + }]:[], var.erp.enable&&var.erp.dolibarr.enable?[{ + "name" = "dolibarr-dolibarr-redis" + "namespace" = "${var.namespace}-erp" + }]:[], var.apps.enable&&var.apps.nextcloud.enable?[{ + "name" = "nextcloud-nextcloud-redis" + "namespace" = "${var.namespace}-files" + }]:[], lookup(var.devspaces, "external-redis", [])) } } @@ -194,6 +214,6 @@ resource "kubectl_manifest" "devspaces" { distrib: "${var.distributions.domain}" category: "meta" component: "domain-devspaces" - options: ${jsonencode(merge(local.global, local.devspaces-custom, local.devspaces))} + options: ${jsonencode(merge(local.global, local.devspaces, local.devspaces-custom))} EOF }