From 5baf51a9f2084960c935e8cbfc043c43b05cd73f Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 4 Dec 2024 09:22:55 +0000 Subject: [PATCH] change the variable type to make it automatic with the image name --- module.tf | 14 +++--- variables.auto.tfvars | 100 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 10 deletions(-) diff --git a/module.tf b/module.tf index f84ab6b..78d9d7e 100644 --- a/module.tf +++ b/module.tf @@ -35,9 +35,11 @@ variable "kubernetes" { liveness_tcp_socket = optional(number) liveness_http_get = optional(string) liveness_http_get_path = optional(string) - database = optional(map(object({ - image = optional(string) - }))) + database = optional(map(string)) +# database = optional(map(object({ +# image = optional(string, "docker.io/library/postgres:latest") +# })), null) + redis = optional(map(string)) enabled = optional(bool, true) requirements = optional(map(string), { limits-cpu = "800m" @@ -327,7 +329,9 @@ resource "kubernetes_deployment_v1" "automatic" { resource "kubernetes_deployment_v1" "database-automatic" { - for_each = { for key, value in var.kubernetes : key => value if value.enabled == true } + for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true } + + metadata { namespace = coalesce(each.value.namespace, each.key) name = "${coalesce(each.value.namespace, each.key)}-db" @@ -358,7 +362,7 @@ resource "kubernetes_deployment_v1" "database-automatic" { spec { container { - image = "docker.io/library/postgres:14" + image = try(each.value.database.image, "docker.io/library/postgres:latest") name = "${coalesce(each.value.name, each.key)}-db" port { diff --git a/variables.auto.tfvars b/variables.auto.tfvars index d634c5d..945bab6 100644 --- a/variables.auto.tfvars +++ b/variables.auto.tfvars @@ -26,11 +26,10 @@ kubernetes = { namespace = "onitama" image = "ghcr.io/jackadamson/onitama:latest" service_port = 8080 - database = { -# username = "username" -# database = "database" -# password = "password" + redis = { + image = "hello" } + database = {} requirements = { limits-cpu = "50m" limits-memory = "50Mi" @@ -103,11 +102,15 @@ kubernetes = { } } + nginx = { - enabled = false + enabled = true namespace = "testnginx" #image = "localhost:31795/django-python" image = "nginx:latest" + database = { + # "image" = "mysql:latest" + } #pvc_size = "10Mi" # mount_path = "/code" # service_port = 80 @@ -310,6 +313,93 @@ kubernetes = { } } } + + paper = { + enabled = false + namespace = "paper" + image = "ghcr.io/paperless-ngx/paperless-ngx:latest" + service_port = 8000 + database = {} + requirements = { + limits-cpu = "50m" + limits-memory = "50Mi" + requests-cpu = "25m" + requests-memory = "25Mi" + } + environment = { + POSTGRES_DB = { + value_from = { + secret_key_ref = { + name = "mysecret" + key = "POSTGRES_DB" + } + } + } + POSTGRES_USER = { + value_from = { + secret_key_ref = { + name = "mysecret" + key = "POSTGRES_USER" + } + } + } + POSTGRES_PASSWORD = { + value_from = { + secret_key_ref = { + name = "mysecret" + key = "POSTGRES_PASSWORD" + } + } + } + PAPERLESS_URL = { + value = "https://paper.tryton.geeraert.eu" + } + PAPERLESS_DBHOST = { + value_from = { + secret_key_ref = { + name = "mysecret" + key = "POSTGRES_DB" + } + } + } + + PAPERLESS_ADMIN_USER = { + value = "admin" + } + PAPERLESS_ADMIN_PASSWORD = { + value = "admin" + } + + PAPERLESS_OCR_USER_ARGS = { + value = "{'invalidate_digital_signatures': true}" + } + } + pvc = { + paperless-data = { + name = "paperless-data" + pvc_size = "2Mi" + mount_path = "/usr/src/paperless/data" + } + media = { + name = "media" + pvc_size = "2Mi" + mount_path = "/usr/src/paperless/media" + } + export = { + name = "export" + pvc_size = "2Mi" + mount_path = "/usr/src/paperless/export" + } + consume = { + name = "consume" + pvc_size = "2Mi" + mount_path = "/usr/src/paperless/consume" + } + } + } + + + }