diff --git a/module.tf b/module.tf index 392b6ab..3934b57 100644 --- a/module.tf +++ b/module.tf @@ -12,12 +12,8 @@ provider "kubernetes" { variable "kubernetes" { type = map(object({ - #service = string - # pvc_name = optional(string) name = optional(string) image = string - # mount_path = optional(string, "/mount") - # pvc_size = optional(string) pvc = optional(map(object({ name = string pvc_size = string @@ -38,10 +34,6 @@ variable "kubernetes" { requests-memory = "200Mi" }) environment_variables = optional(map(string), { name = "value" }) - # environment_variables = optional(list(object({ - # name = string - # value = string - # }))) })) } @@ -121,7 +113,8 @@ resource "kubernetes_deployment_v1" "automatic" { namespace = coalesce(each.value.namespace, each.key) name = coalesce(each.value.namespace, each.key) labels = { - app = each.key + app = each.key + deployment_method = "Terraform" } } @@ -137,7 +130,8 @@ resource "kubernetes_deployment_v1" "automatic" { template { metadata { labels = { - app = each.key + app = each.key + deployment_method = "Terraform" } } @@ -162,22 +156,6 @@ resource "kubernetes_deployment_v1" "automatic" { } } - ######################################### - ############# working but not goign through every arguments - - - # dynamic "env" { - # for_each = each.value.environment_variables != null ? [""] : [] - # content { - # name = keys(each.value.environment_variables)[0] - # value = values(each.value.environment_variables)[0] - # } - # } - - ####################################### - - - @@ -226,17 +204,17 @@ resource "kubernetes_deployment_v1" "automatic" { } } + dynamic "volume" { - for_each = each.value.pvc != null ? [""] : [] - # for_each = each.value.pvc_size != null ? [""] : [] + for_each = each.value.pvc != null ? each.value.pvc : {} content { - name = "${each.key}-volume" + name = "${volume.value.name}-pvc" persistent_volume_claim { - claim_name = "${each.key}-pvc" + claim_name = "${volume.value.name}-pvc" } } - } + } } }