find a way by refactoring pvc

This commit is contained in:
2024-12-11 21:33:02 +00:00
parent 283d841739
commit 3458dd3dc6
2 changed files with 148 additions and 79 deletions
+12 -4
View File
@@ -13,11 +13,13 @@ variable "kubernetes" {
image = string
pvc = optional(map(object({
name = string
pvc = optional(bool)
configmap = optional(bool)
pvc_size = string
mount_path = string
# database = optional(bool,false)
})))
secret = optional(map(string))
#secret = optional(map(string))
environment = optional(map(object({
name = optional(string)
value = optional(string)
@@ -380,12 +382,18 @@ resource "kubernetes_deployment_v1" "automatic" {
dynamic "volume" {
for_each = each.value.pvc != null ? each.value.pvc : {}
for_each = each.value.pvc != null ? each.value.pvc : {}
content {
name = "${volume.value.name}-pvc"
persistent_volume_claim {
claim_name = "${volume.value.name}-pvc"
dynamic "persistent_volume_claim" {
for_each = volume.value.pvc ? [1] : []
content {
claim_name = "${volume.value.name}-pvc"
}
}
}
}