From d318d017f2ec60c39b4d923c0b33253d25584c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Fri, 26 Jan 2024 20:11:20 +0100 Subject: [PATCH] fix --- meta/domain-devspaces/apps.tf | 82 ++++-- meta/domain-devspaces/index.yaml | 487 ++++++++++++++++--------------- 2 files changed, 319 insertions(+), 250 deletions(-) diff --git a/meta/domain-devspaces/apps.tf b/meta/domain-devspaces/apps.tf index e12c350..6ee39b2 100644 --- a/meta/domain-devspaces/apps.tf +++ b/meta/domain-devspaces/apps.tf @@ -1,24 +1,55 @@ locals { annotations = { - "vynil.solidite.fr/meta" = var.component - "vynil.solidite.fr/name" = "${var.domain}-devspaces" - "vynil.solidite.fr/domain" = var.domain_name - "vynil.solidite.fr/issuer" = var.issuer - "vynil.solidite.fr/ingress" = var.ingress_class + "vynil.solidite.fr/meta" = var.component + "vynil.solidite.fr/name" = var.namespace + } + annotations_default = { + "default.vynil.solidite.fr/sso_vynil" = var.sso_vynil + "default.vynil.solidite.fr/domain_name" = var.domain_name + "default.vynil.solidite.fr/timezone" = var.timezone + "default.vynil.solidite.fr/language" = var.language + "default.vynil.solidite.fr/domain" = var.domain + "default.vynil.solidite.fr/issuer" = var.issuer + "default.vynil.solidite.fr/ingress_class" = var.ingress_class + "default.vynil.solidite.fr/app_group" = var.app_group + "default.vynil.solidite.fr/backups.enable" = var.backups.enable + "default.vynil.solidite.fr/backups.use_barman" = var.backups.use_barman + "default.vynil.solidite.fr/backups.endpoint" = var.backups.endpoint + "default.vynil.solidite.fr/backups.secret_name" = var.backups.secret_name + "default.vynil.solidite.fr/backups.key_id_key" = var.backups.key_id_key + "default.vynil.solidite.fr/backups.secret_key" = var.backups.secret_key + "default.vynil.solidite.fr/backups.restic_key" = var.backups.restic_key + "default.vynil.solidite.fr/storage.volume.accessMode" = var.storage.volume.accessMode + "default.vynil.solidite.fr/storage.volume.class" = var.storage.volume.class } global = { - "domain" = var.domain - "domain_name" = var.domain_name - "issuer" = var.issuer - "ingress_class" = var.ingress_class - "backups" = var.backups - "app_group" = var.app_group + "sso_vynil" = var.sso_vynil + "domain_name" = var.domain_name + "timezone" = var.timezone + "language" = var.language + "domain" = var.domain + "issuer" = var.issuer + "ingress_class" = var.ingress_class + "app_group" = var.app_group + } + global-backups = { + "enable" = var.backups.enable + "use_barman" = var.backups.use_barman + "endpoint" = var.backups.endpoint + "secret_name" = var.backups.secret_name + "key_id_key" = var.backups.key_id_key + "secret_key" = var.backups.secret_key + "restic_key" = var.backups.restic_key + } + global-volume = { + "accessMode" = var.storage.volume.accessMode + "class" = var.storage.volume.class } global-apps = merge(local.global, { "domain_name" = "devtools.${var.domain_name}" "app_group" = "dev" }) - okd = merge({ + okd = merge(local.global-apps,{ "namespaces" = concat([ for station in local.sorted-station-names: "${var.domain}-devspaces-${station}" ],flatten([ @@ -27,8 +58,13 @@ locals { ] ]) ) - }, { for k, v in var.apps.okd : k => v if k!="enable" }) - gramo = merge({ + }, { for k, v in var.okd : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.okd, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.okd, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.okd, "storage", {}), "volume", {}), local.global-volume) + }) + }) + gramo = merge(local.global-apps, { "namespaces" = concat([ for station in local.sorted-station-names: "${var.domain}-devspaces-${station}" ],flatten([ @@ -37,8 +73,13 @@ locals { ] ]) ) - }, { for k, v in var.apps.gramo : k => v if k!="enable" }) - dbgate = merge({ + }, { for k, v in var.gramo : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.gramo, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.gramo, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.gramo, "storage", {}), "volume", {}), local.global-volume) + }) + }) + dbgate = merge(local.global-apps, { "pg" = concat( flatten([for ds in local.sorted-datasets: [for db in lookup(ds, "databases", []): { "name" = "${ds.name}-dataset-pg" @@ -139,13 +180,18 @@ locals { } if ds.engine=="mongo"]])]), var.external-redis ) - }, { for k, v in var.apps.dbgate : k => v if k!="enable" }) + }, { for k, v in var.dbgate : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.dbgate, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.dbgate, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.dbgate, "storage", {}), "volume", {}), local.global-volume) + }) + }) } resource "kubernetes_namespace_v1" "apps-ns" { count = (var.apps.dbgate.enable || var.apps.okd.enable || var.apps.gramo.enable) ? 1 : 0 metadata { - annotations = local.annotations + annotations = merge(local.annotations, local.annotations_default) labels = merge(local.common-labels, local.annotations) name = "${var.namespace}-devapps" } diff --git a/meta/domain-devspaces/index.yaml b/meta/domain-devspaces/index.yaml index 45b7b67..1c9ad87 100644 --- a/meta/domain-devspaces/index.yaml +++ b/meta/domain-devspaces/index.yaml @@ -6,12 +6,149 @@ metadata: name: domain-devspaces description: null options: - domain: - default: your-company + haveGitea: + default: false examples: - - your-company + - false + type: boolean + timezone: + default: Europe/Paris + examples: + - Europe/Paris type: string - stations: + storage: + default: + volume: + accessMode: ReadWriteOnce + class: '' + examples: + - volume: + accessMode: ReadWriteOnce + class: '' + properties: + volume: + default: + accessMode: ReadWriteOnce + class: '' + properties: + accessMode: + default: ReadWriteOnce + type: string + class: + default: '' + type: string + type: object + type: object + app_group: + default: dev + examples: + - dev + type: string + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + type: string + organisations: + default: [] + examples: + - [] + items: + properties: + datasets: + default: [] + items: + properties: + databases: + default: [] + items: + properties: + name: + default: db + type: string + type: object + type: array + engine: + default: pg + type: string + name: + default: '' + type: string + type: object + type: array + name: + default: '' + type: string + stages: + default: [] + items: + properties: + name: + default: prod + type: string + type: object + type: array + type: object + type: array + external-mongos: + 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-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: default: [] examples: - [] @@ -20,13 +157,62 @@ 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 + images: + default: + codeserver: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.18 + examples: + - codeserver: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.18 + properties: + codeserver: + default: + pullPolicy: IfNotPresent + registry: docker.io + repository: sebt3/code-server + tag: 4.18 + 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.18 + type: number + type: object + type: object apps: default: dbgate: @@ -113,36 +299,26 @@ options: default: domain type: string type: object - backups: - default: - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings + sso_vynil: + default: true examples: - - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings - properties: - enable: - default: false - type: boolean - endpoint: - default: '' - type: string - key-id-key: - default: s3-id - type: string - secret-key: - default: s3-secret - type: string - secret-name: - default: backup-settings - type: string - type: object + - true + type: boolean + ingress_class: + default: traefik + examples: + - traefik + type: string + language: + default: fr_FR + examples: + - fr_FR + type: string + domain_name: + default: your-company.com + examples: + - your-company.com + type: string external-redis: default: [] examples: @@ -157,171 +333,52 @@ options: type: string type: object type: array - haveGitea: - default: false - examples: - - false - type: boolean - ingress_class: - default: traefik - examples: - - traefik - type: string - organisations: - default: [] - examples: - - [] - items: - properties: - datasets: - default: [] - items: - properties: - databases: - default: [] - items: - properties: - name: - default: db - type: string - type: object - type: array - engine: - default: pg - type: string - name: - default: '' - type: string - type: object - type: array - name: - default: '' - type: string - stages: - default: [] - items: - properties: - name: - default: prod - type: string - type: object - type: array - type: object - type: array - domain_name: - default: your_company.com - examples: - - your_company.com - type: string - storage-classes: + backups: default: - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' + enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false examples: - - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' + - enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false properties: - BlockReadWriteMany: + enable: + default: false + type: boolean + endpoint: default: '' type: string - BlockReadWriteOnce: - default: '' + key_id_key: + default: s3-id type: string - FilesystemReadWriteMany: - default: '' + restic_key: + default: bck-password type: string - FilesystemReadWriteOnce: - default: '' + secret_key: + default: s3-secret type: string + secret_name: + default: backup-settings + type: string + use_barman: + default: false + type: boolean type: object - issuer: - default: letsencrypt-prod - examples: - - letsencrypt-prod - type: string - app_group: - default: dev - examples: - - dev - type: string stations-sub_domain: default: code examples: - code type: string - images: - default: - codeserver: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.18 - examples: - - codeserver: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.18 - properties: - codeserver: - default: - pullPolicy: IfNotPresent - registry: docker.io - repository: sebt3/code-server - tag: 4.18 - 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.18 - type: number - type: object - type: object - external-mongos: - 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: - [] @@ -330,52 +387,18 @@ 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 - external-pgs: - default: [] + domain: + default: your-company 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 + - your-company + type: string dependencies: [] providers: kubernetes: true