From a7ff84415e8de2d723f7697b320be5178a5cb79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Wed, 18 Oct 2023 18:40:55 +0200 Subject: [PATCH] fix --- apps/dbgate/index.yaml | 118 +++++++++--------- .../{application.tf => presentation.tf} | 31 +++-- modules/service/providers.tf | 8 ++ {apps/dbgate => modules/service}/svc.tf | 8 +- modules/service/variables.tf | 20 +++ 5 files changed, 112 insertions(+), 73 deletions(-) rename apps/dbgate/{application.tf => presentation.tf} (88%) create mode 100644 modules/service/providers.tf rename {apps/dbgate => modules/service}/svc.tf (67%) create mode 100644 modules/service/variables.tf diff --git a/apps/dbgate/index.yaml b/apps/dbgate/index.yaml index 5d395de..5d7f020 100644 --- a/apps/dbgate/index.yaml +++ b/apps/dbgate/index.yaml @@ -6,12 +6,17 @@ metadata: name: dbgate description: null options: - app-group: - default: dev + ingress-class: + default: traefik examples: - - dev + - traefik type: string - mongo: + domain-name: + default: your_company.com + examples: + - your_company.com + type: string + maria: default: [] examples: - [] @@ -40,6 +45,26 @@ options: type: string type: object type: array + domain: + default: your-company + examples: + - your-company + type: string + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + type: string + use-oauth: + default: false + examples: + - false + type: boolean + app-group: + default: dev + examples: + - dev + type: string images: default: dbgate: @@ -79,22 +104,7 @@ options: type: string type: object type: object - issuer: - default: letsencrypt-prod - examples: - - letsencrypt-prod - type: string - use-oauth: - default: false - examples: - - false - type: boolean - sub-domain: - default: dbgate - examples: - - dbgate - type: string - maria: + mongo: default: [] examples: - [] @@ -123,42 +133,10 @@ options: type: string type: object type: array - domain: - default: your-company + sub-domain: + default: dbgate examples: - - your-company - type: string - 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 - ingress-class: - default: traefik - examples: - - traefik + - dbgate type: string pg: default: [] @@ -189,11 +167,33 @@ options: type: string type: object type: array - domain-name: - default: your_company.com + storage: + default: + accessMode: ReadWriteOnce + size: 1Gi + type: Filesystem examples: - - your_company.com - type: string + - 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/apps/dbgate/application.tf b/apps/dbgate/presentation.tf similarity index 88% rename from apps/dbgate/application.tf rename to apps/dbgate/presentation.tf index 797ee5b..1420bd8 100644 --- a/apps/dbgate/application.tf +++ b/apps/dbgate/presentation.tf @@ -14,18 +14,19 @@ locals { } } - -provider "restapi" { - uri = "http://authentik.${var.domain}-auth.svc/api/v3/" - headers = local.request_headers - create_method = "PATCH" - update_method = "PATCH" - destroy_method = "PATCH" - write_returns_object = true - id_attribute = "name" +module "service" { + source = "/dist/modules/service" + component = var.component + instance = var.instance + namespace = var.namespace + labels = local.common-labels + target = "http" + port = local.service.port.number + providers = { + kubectl = kubectl + } } - module "ingress" { source = "/dist/modules/ingress" component = var.component @@ -71,6 +72,16 @@ module "oauth2" { } } +provider "restapi" { + uri = "http://authentik.${var.domain}-auth.svc/api/v3/" + headers = local.request_headers + create_method = "PATCH" + update_method = "PATCH" + destroy_method = "PATCH" + write_returns_object = true + id_attribute = "name" +} + module "forward" { count = var.use-oauth?0:1 source = "/dist/modules/forward" diff --git a/modules/service/providers.tf b/modules/service/providers.tf new file mode 100644 index 0000000..45aaada --- /dev/null +++ b/modules/service/providers.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + kubectl = { + source = "gavinbunney/kubectl" + version = "~> 1.14.0" + } + } +} diff --git a/apps/dbgate/svc.tf b/modules/service/svc.tf similarity index 67% rename from apps/dbgate/svc.tf rename to modules/service/svc.tf index c73fa48..b31a287 100644 --- a/apps/dbgate/svc.tf +++ b/modules/service/svc.tf @@ -5,14 +5,14 @@ resource "kubectl_manifest" "service" { metadata: name: "${var.component}-${var.instance}" namespace: "${var.namespace}" - labels: ${jsonencode(local.common-labels)} + labels: ${jsonencode(var.labels)} spec: type: ClusterIP ports: - name: http - port: 80 + port: ${var.port} protocol: TCP - targetPort: http - selector: ${jsonencode(local.common-labels)} + targetPort: ${var.target} + selector: ${jsonencode(var.labels)} EOF } diff --git a/modules/service/variables.tf b/modules/service/variables.tf new file mode 100644 index 0000000..8d7daa9 --- /dev/null +++ b/modules/service/variables.tf @@ -0,0 +1,20 @@ +variable "component" { + type = string +} +variable "instance" { + type = string +} +variable "namespace" { + type = string +} +variable "labels" { + type = map(string) +} +variable "port" { + type = number + default = 80 +} +variable "target" { + type = string + default = "http" +}