reformat
This commit is contained in:
@@ -87,7 +87,7 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
for_each = each.value.pvc != null ? each.value.pvc : {}
|
for_each = each.value.pvc != null ? each.value.pvc : {}
|
||||||
content {
|
content {
|
||||||
mount_path = volume_mount.value.mount_path
|
mount_path = volume_mount.value.mount_path
|
||||||
name = "${volume_mount.value.name}-pvc"
|
name = "${volume_mount.key}-volume"
|
||||||
sub_path = volume_mount.value.sub_path != null ? volume_mount.value.sub_path : ""
|
sub_path = volume_mount.value.sub_path != null ? volume_mount.value.sub_path : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,33 +230,27 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
dynamic "volume" {
|
dynamic "volume" {
|
||||||
for_each = each.value.pvc != null ? each.value.pvc : {}
|
for_each = each.value.pvc != null ? each.value.pvc : {}
|
||||||
content {
|
content {
|
||||||
name = "${volume.value.name}-pvc"
|
name = "${volume.key}-volume"
|
||||||
|
|
||||||
dynamic "persistent_volume_claim" {
|
|
||||||
for_each = volume.value.pvc ? [1] : []
|
|
||||||
content {
|
|
||||||
claim_name = "${volume.value.name}-pvc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamic "config_map" {
|
dynamic "config_map" {
|
||||||
for_each = volume.value.config_map ? [1] : []
|
for_each = volume.value.config_map ? [1] : []
|
||||||
content {
|
content {
|
||||||
name = volume.value.name
|
name = volume.key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic "host_path" {
|
dynamic "host_path" {
|
||||||
for_each = volume.value.host_path != null ? [1] : []
|
for_each = volume.value.host_path != null || (!(volume.value.config_map) && !(volume.value.secret)) ? [1] : []
|
||||||
content {
|
content {
|
||||||
path = volume.value.host_path
|
path = coalesce(volume.value.host_path, join("/", [var.storage_path.main_storage, coalesce(each.value.namespace, each.value.connected_namespace, each.key), volume.key]))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic "secret" {
|
dynamic "secret" {
|
||||||
for_each = volume.value.secret ? [1] : []
|
for_each = volume.value.secret ? [1] : []
|
||||||
content {
|
content {
|
||||||
secret_name = volume.value.name
|
secret_name = volume.key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,8 +261,8 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
content {
|
content {
|
||||||
name = "${each.key}-db-backup"
|
name = "${each.key}-db-backup"
|
||||||
|
|
||||||
persistent_volume_claim {
|
host_path {
|
||||||
claim_name = "${each.key}-db-backup"
|
path = join("/", [var.storage_path.fast_access, "Backup", coalesce(each.value.namespace, each.value.connected_namespace, each.key), "${each.key}-db-backup"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,5 +270,4 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
depends_on = [kubernetes_persistent_volume_claim_v1.automatic-pvc]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,14 @@ variable "database_backup_info" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "storage_path" {
|
||||||
|
type = map(string)
|
||||||
|
default = {
|
||||||
|
main_storage = "/data/kubernetes",
|
||||||
|
fast_access = "/ssd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
pvc_list = flatten([
|
pvc_list = flatten([
|
||||||
for key, value in var.kubernetes : [
|
for key, value in var.kubernetes : [
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_username" {
|
|||||||
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
|
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
value,key
|
value, key
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_password" {
|
|||||||
avoid_ambiguous = true
|
avoid_ambiguous = true
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
value,key
|
value, key
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_host" {
|
|||||||
value = try(each.value.database.host, "${each.key}-db-svc.${coalesce(each.value.namespace, each.value.connected_namespace, each.key)}.svc")
|
value = try(each.value.database.host, "${each.key}-db-svc.${coalesce(each.value.namespace, each.value.connected_namespace, each.key)}.svc")
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
value,key
|
value, key
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_port" {
|
|||||||
value = try(each.value.database.port, 5432)
|
value = try(each.value.database.port, 5432)
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
value,key
|
value, key
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_name" {
|
|||||||
value = try(each.value.database.name, each.key)
|
value = try(each.value.database.name, each.key)
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
value,key
|
value, key
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
resource "kubernetes_persistent_volume_claim_v1" "automatic-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
|
|
||||||
resources {
|
|
||||||
requests = {
|
|
||||||
storage = each.value.pvc_size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-database" {
|
|
||||||
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true && !(try(value.database.shunt, false)) }
|
|
||||||
metadata {
|
|
||||||
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
|
||||||
name = "${each.key}-db-pvc"
|
|
||||||
labels = {
|
|
||||||
deployment_method = "Terraform"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spec {
|
|
||||||
access_modes = ["ReadWriteMany"]
|
|
||||||
storage_class_name = "nfs-storage-intelligent"
|
|
||||||
resources {
|
|
||||||
requests = {
|
|
||||||
storage = "1Gi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "kubernetes_persistent_volume_claim_v1" "backup-pvc-database" {
|
|
||||||
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
|
|
||||||
metadata {
|
|
||||||
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
|
||||||
name = "${each.key}-db-backup"
|
|
||||||
labels = {
|
|
||||||
deployment_method = "Terraform"
|
|
||||||
}
|
|
||||||
annotations = {
|
|
||||||
fileType = "Backup" }
|
|
||||||
}
|
|
||||||
spec {
|
|
||||||
access_modes = ["ReadWriteMany"]
|
|
||||||
storage_class_name = "nfs-storage-fastaccess"
|
|
||||||
resources {
|
|
||||||
requests = {
|
|
||||||
storage = "1Gi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-redis" {
|
|
||||||
for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true }
|
|
||||||
metadata {
|
|
||||||
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
|
||||||
name = "${each.key}-redis-pvc"
|
|
||||||
labels = {
|
|
||||||
deployment_method = "Terraform"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spec {
|
|
||||||
access_modes = ["ReadWriteMany"]
|
|
||||||
storage_class_name = "nfs-storage-intelligent"
|
|
||||||
resources {
|
|
||||||
requests = {
|
|
||||||
storage = "1Gi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user