enable variable storageclass

This commit is contained in:
2025-04-04 09:27:29 +01:00
parent 8a13ca3967
commit 6dc1f5427d
3 changed files with 26 additions and 21 deletions
+15 -13
View File
@@ -12,12 +12,13 @@ variable "kubernetes" {
name = optional(string)
image = string
pvc = optional(map(object({
name = string
pvc = optional(bool, false)
config_map = optional(bool, false)
host_path = optional(string)
pvc_size = optional(string)
mount_path = string
name = string
pvc = optional(bool, false)
config_map = optional(bool, false)
host_path = optional(string)
pvc_size = optional(string)
storage_class_name = optional(string, "nfs-storage-intelligent")
mount_path = string
})))
environment = optional(map(object({
name = optional(string)
@@ -58,12 +59,13 @@ locals {
pvc_details = flatten([
for key, value in var.kubernetes : [
for index, pvc in value.pvc : {
index = index
pvc = pvc.pvc
name = pvc.name
pvc_size = pvc.pvc_size
mount_path = pvc.mount_path
namespace = coalesce(value.namespace, key)
index = index
pvc = pvc.pvc
name = pvc.name
pvc_size = pvc.pvc_size
mount_path = pvc.mount_path
storage_class_name = pvc.storage_class_name
namespace = coalesce(value.namespace, key)
}] if value.enabled == true && value.pvc != null
])
}
@@ -131,7 +133,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
}
spec {
access_modes = ["ReadWriteMany"]
storage_class_name = "nfs-storage-intelligent"
storage_class_name = each.value.storage_class_name
resources {
requests = {
storage = each.value.pvc_size