From 6dc1f5427dc91a3cec8541b2dfae69a6531185b8 Mon Sep 17 00:00:00 2001 From: pierre Date: Fri, 4 Apr 2025 09:27:29 +0100 Subject: [PATCH] enable variable storageclass --- README.md | 2 ++ module.tf | 28 +++++++++++++++------------- variables.auto.tfvars | 17 +++++++++-------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index dbd7946..479c706 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Boolean to specify if it is a hostpath [Example](https://gitea.tryton.geeraert.eu/pi-ux-ce/Terraform_kube#volume-as-hostpath) #### pvc_size = optional(string) #### mount_path = string +#### storage_class_name = optional(string, "nfs-storage-intelligent") +This is the storage class, by default it will use nfs-storage-intelligent but it can be changed to something more suitable ### environment = optional(map(object({ ### name = optional(string) ### value = optional(string) diff --git a/module.tf b/module.tf index f448143..078369b 100644 --- a/module.tf +++ b/module.tf @@ -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 diff --git a/variables.auto.tfvars b/variables.auto.tfvars index e5f3225..4dbf255 100644 --- a/variables.auto.tfvars +++ b/variables.auto.tfvars @@ -133,7 +133,7 @@ kubernetes = { stash = { - enabled = false +# enabled = false name = "stash" image = "stashapp/stash:latest" service_port = 9999 @@ -156,17 +156,18 @@ kubernetes = { } } requirements = { - limits-cpu = "100m" - limits-memory = "300Mi" + limits-cpu = "1000m" + limits-memory = "3000Mi" requests-cpu = "50m" requests-memory = "150Mi" } pvc = { data = { - name = "data" - pvc_size = "100Mi" - pvc = true - mount_path = "/data" + name = "data" + pvc_size = "100Mi" + pvc = true + mount_path = "/data" + storage_class_name = "nfs-storage-fastaccess" } metadata = { name = "metadata" @@ -468,7 +469,7 @@ kubernetes = { next = { - # enabled = false + enabled = false namespace = "next" replicas = 01 image = "nextcloud:29.0.3-apache"