add files before tuching bitwarden

This commit is contained in:
2025-11-24 19:28:18 +00:00
parent 652710a98a
commit ad69271f01
2 changed files with 665 additions and 75 deletions
+47 -19
View File
@@ -12,14 +12,16 @@ variable "kubernetes" {
name = optional(string)
image = string
pvc = optional(map(object({
name = string
pvc = optional(bool, false)
config_map = optional(bool, false)
secret = optional(bool, false)
host_path = optional(string)
pvc_size = optional(string)
storage_class_name = optional(string, "nfs-storage-intelligent")
mount_path = string
name = string
pvc = optional(bool, false)
config_map = optional(bool, false)
secret = optional(bool, false)
host_path = optional(string)
pvc_size = optional(string)
storage_class_name = optional(string, "nfs-storage-intelligent")
annotations_fileType = optional(string)
existing_pvc = optional(bool, false)
mount_path = string
})))
environment = optional(map(object({
name = optional(string)
@@ -38,6 +40,7 @@ variable "kubernetes" {
service_port = optional(list(number))
service_type = optional(string, "ClusterIP")
service_name = optional(string)
domain_name = optional(string)
liveness_tcp_socket = optional(number)
liveness_http_get = optional(string)
liveness_http_get_path = optional(string)
@@ -65,13 +68,15 @@ 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
storage_class_name = pvc.storage_class_name
namespace = coalesce(value.namespace, value.connected_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
annotations_fileType = pvc.annotations_fileType
existing_pvc = pvc.existing_pvc
namespace = coalesce(value.namespace, value.connected_namespace, key)
}] if value.enabled == true && value.pvc != null
])
}
@@ -128,14 +133,19 @@ resource "kubernetes_manifest" "manifest" {
resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) if value.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
@@ -542,9 +552,8 @@ resource "kubernetes_deployment_v1" "database-automatic" {
name = "${each.key}-db-pvc"
}
command = try([each.value.database.command],[])
#command = [try(each.value.database.command,"")]
dynamic "env" {
for_each = each.value.environment != null ? each.value.environment : {}
@@ -742,3 +751,22 @@ resource "kubernetes_deployment_v1" "redis-automatic" {
}
}
}
resource "kubernetes_config_map" "automatic-configmap" {
metadata {
name = "extra-sites-terraform"
namespace = "reverse-proxy"
annotations = {
"reloader.stakater.com/match" : "true",
}
}
data = {
for key, value in var.kubernetes :
"${value.domain_name}.conf" => templatefile("nginx_config.tftpl", {
name_site = value.domain_name
name_service = "${key}-svc.${coalesce(value.namespace, value.connected_namespace, key)}.svc:${value.service_port.0}"
}) if value.domain_name != null && value.enabled == true
}
}