This commit is contained in:
pierre.geeraert
2026-10-14 16:13:11 +01:00
parent 7321c766f4
commit c0c0c8e309
6 changed files with 79 additions and 71 deletions
+15 -15
View File
@@ -1,6 +1,6 @@
variable "kubernetes_input" {
type = map(object({
name = optional(string)
name = optional(string)
environment = optional(map(object({
name = optional(string)
value = optional(string)
@@ -11,11 +11,11 @@ variable "kubernetes_input" {
})
}))
})))
replicas = optional(number, 1)
namespace = optional(string)
connected_namespace = optional(string, "")
redis = optional(map(string))
enabled = optional(bool, true)
replicas = optional(number, 1)
namespace = optional(string)
connected_namespace = optional(string, "")
redis = optional(map(string))
enabled = optional(bool, true)
}))
}
@@ -28,12 +28,12 @@ variable "storage_path" {
}
resource "kubernetes_deployment_v1" "redis-automatic" {
for_each = {for key, value in var.kubernetes_input : key => value if value.redis != null && value.enabled == true}
for_each = { for key, value in var.kubernetes_input : key => value if value.redis != null && value.enabled == true }
metadata {
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
name = "${coalesce(each.value.name, each.key)}-redis"
name = "${coalesce(each.value.name, each.key)}-redis"
labels = {
app = each.key
deployment_method = "Terraform"
@@ -62,7 +62,7 @@ resource "kubernetes_deployment_v1" "redis-automatic" {
spec {
container {
image = try(each.value.redis.image, "docker.io/library/redis:7")
name = "${coalesce(each.value.name, each.key)}-redis"
name = "${coalesce(each.value.name, each.key)}-redis"
port {
container_port = 6379
@@ -97,13 +97,13 @@ resource "kubernetes_deployment_v1" "redis-automatic" {
}
}
volume {
name = "${each.key}-redis-volume"
host_path {
path = try(each.value.redis.host_path, join("/", [var.storage_path.main_storage, coalesce(each.value.namespace, each.value.connected_namespace, each.key), join("-", [each.key, "redis"])]))
}
volume {
name = "${each.key}-redis-volume"
host_path {
path = try(each.value.redis.host_path, join("/", [var.storage_path.main_storage, coalesce(each.value.namespace, each.value.connected_namespace, each.key), join("-", [each.key, "redis"])]))
}
}
}
}
}
}
}