From ec901f92df06de947f9cf2037e4519ee230ff412 Mon Sep 17 00:00:00 2001 From: "pierre.geeraert" Date: Mon, 12 Oct 2026 16:53:38 +0100 Subject: [PATCH] reformat --- infrastructure/deployment.tf | 25 ++++------- infrastructure/module.tf | 8 ++++ infrastructure/secrets.tf | 10 ++--- infrastructure/storage.tf | 87 ------------------------------------ 4 files changed, 22 insertions(+), 108 deletions(-) diff --git a/infrastructure/deployment.tf b/infrastructure/deployment.tf index 5577dfe..872128f 100644 --- a/infrastructure/deployment.tf +++ b/infrastructure/deployment.tf @@ -87,7 +87,7 @@ resource "kubernetes_deployment_v1" "automatic" { for_each = each.value.pvc != null ? each.value.pvc : {} content { mount_path = volume_mount.value.mount_path - name = "${volume_mount.value.name}-pvc" + name = "${volume_mount.key}-volume" sub_path = volume_mount.value.sub_path != null ? volume_mount.value.sub_path : "" } } @@ -230,33 +230,27 @@ resource "kubernetes_deployment_v1" "automatic" { dynamic "volume" { for_each = each.value.pvc != null ? each.value.pvc : {} content { - name = "${volume.value.name}-pvc" - - dynamic "persistent_volume_claim" { - for_each = volume.value.pvc ? [1] : [] - content { - claim_name = "${volume.value.name}-pvc" - } - } + name = "${volume.key}-volume" dynamic "config_map" { for_each = volume.value.config_map ? [1] : [] content { - name = volume.value.name + name = volume.key } } dynamic "host_path" { - for_each = volume.value.host_path != null ? [1] : [] + for_each = volume.value.host_path != null || (!(volume.value.config_map) && !(volume.value.secret)) ? [1] : [] content { - path = volume.value.host_path + path = coalesce(volume.value.host_path, join("/", [var.storage_path.main_storage, coalesce(each.value.namespace, each.value.connected_namespace, each.key), volume.key])) + } } dynamic "secret" { for_each = volume.value.secret ? [1] : [] content { - secret_name = volume.value.name + secret_name = volume.key } } @@ -267,8 +261,8 @@ resource "kubernetes_deployment_v1" "automatic" { content { name = "${each.key}-db-backup" - persistent_volume_claim { - claim_name = "${each.key}-db-backup" + host_path { + path = join("/", [var.storage_path.fast_access, "Backup", coalesce(each.value.namespace, each.value.connected_namespace, each.key), "${each.key}-db-backup"]) } } } @@ -276,5 +270,4 @@ resource "kubernetes_deployment_v1" "automatic" { } } } - depends_on = [kubernetes_persistent_volume_claim_v1.automatic-pvc] } diff --git a/infrastructure/module.tf b/infrastructure/module.tf index 3e8c13b..8926b28 100644 --- a/infrastructure/module.tf +++ b/infrastructure/module.tf @@ -106,6 +106,14 @@ variable "database_backup_info" { } } +variable "storage_path" { + type = map(string) + default = { + main_storage = "/data/kubernetes", + fast_access = "/ssd" + } +} + locals { pvc_list = flatten([ for key, value in var.kubernetes : [ diff --git a/infrastructure/secrets.tf b/infrastructure/secrets.tf index 00a1d08..ecadc30 100644 --- a/infrastructure/secrets.tf +++ b/infrastructure/secrets.tf @@ -100,7 +100,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_username" { project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd" lifecycle { ignore_changes = [ - value,key + value, key ] } } @@ -115,7 +115,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_password" { avoid_ambiguous = true lifecycle { ignore_changes = [ - value,key + value, key ] } } @@ -127,7 +127,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_host" { value = try(each.value.database.host, "${each.key}-db-svc.${coalesce(each.value.namespace, each.value.connected_namespace, each.key)}.svc") lifecycle { ignore_changes = [ - value,key + value, key ] } } @@ -139,7 +139,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_port" { value = try(each.value.database.port, 5432) lifecycle { ignore_changes = [ - value,key + value, key ] } } @@ -151,7 +151,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_name" { value = try(each.value.database.name, each.key) lifecycle { ignore_changes = [ - value,key + value, key ] } } diff --git a/infrastructure/storage.tf b/infrastructure/storage.tf index 174194b..e69de29 100644 --- a/infrastructure/storage.tf +++ b/infrastructure/storage.tf @@ -1,87 +0,0 @@ - - -resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc" { - for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) if value.pvc && value.existing_pvc != true } - metadata { - namespace = coalesce(each.value.namespace, each.key) - name = "${each.value.name}-pvc" - labels = { - deployment_method = "Terraform" - } - annotations = { - fileType = try(each.value.annotations_fileType, "file") - } - - } - - spec { - access_modes = ["ReadWriteMany"] - storage_class_name = each.value.storage_class_name - resources { - requests = { - storage = each.value.pvc_size - } - } - } -} -resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-database" { - for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true && !(try(value.database.shunt, false)) } - metadata { - namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) - name = "${each.key}-db-pvc" - labels = { - deployment_method = "Terraform" - } - } - spec { - access_modes = ["ReadWriteMany"] - storage_class_name = "nfs-storage-intelligent" - resources { - requests = { - storage = "1Gi" - } - } - } -} - -resource "kubernetes_persistent_volume_claim_v1" "backup-pvc-database" { - for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true } - metadata { - namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) - name = "${each.key}-db-backup" - labels = { - deployment_method = "Terraform" - } - annotations = { - fileType = "Backup" } - } - spec { - access_modes = ["ReadWriteMany"] - storage_class_name = "nfs-storage-fastaccess" - resources { - requests = { - storage = "1Gi" - } - } - } -} - -resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-redis" { - for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true } - metadata { - namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) - name = "${each.key}-redis-pvc" - labels = { - deployment_method = "Terraform" - } - } - spec { - access_modes = ["ReadWriteMany"] - storage_class_name = "nfs-storage-intelligent" - resources { - requests = { - storage = "1Gi" - } - } - } -}