From d985a1931ab1313cb00fe22fdf35a38ee32076a8 Mon Sep 17 00:00:00 2001 From: andrea rota Date: Mon, 4 Apr 2022 19:17:46 +0100 Subject: [PATCH 1/6] add k8s_storage module with initial storage class for Azure Files CSI over NFS --- infrastructure/kubernetes/main.tf | 8 +++++++ .../kubernetes/modules/storage/main.tf | 11 ++++++++++ .../kubernetes/modules/storage/variable.tf | 19 +++++++++++++++++ .../kubernetes/modules/storage/versions.tf | 21 +++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 infrastructure/kubernetes/modules/storage/main.tf create mode 100644 infrastructure/kubernetes/modules/storage/variable.tf create mode 100644 infrastructure/kubernetes/modules/storage/versions.tf diff --git a/infrastructure/kubernetes/main.tf b/infrastructure/kubernetes/main.tf index 53230c26bb..58aa32cb0f 100644 --- a/infrastructure/kubernetes/main.tf +++ b/infrastructure/kubernetes/main.tf @@ -59,6 +59,14 @@ module "cert_manager" { email = var.cert_email } +module "k8s_storage" { + source = "./modules/storage" + k8s_host = local.k8s_host + k8s_client_certificate = local.k8s_client_certificate + k8s_client_key = local.k8s_client_key + k8s_cluster_ca_certificate = local.k8s_cluster_ca_certificate +} + #### # Production #### diff --git a/infrastructure/kubernetes/modules/storage/main.tf b/infrastructure/kubernetes/modules/storage/main.tf new file mode 100644 index 0000000000..d17b01f3f4 --- /dev/null +++ b/infrastructure/kubernetes/modules/storage/main.tf @@ -0,0 +1,11 @@ +resource "kubernetes_storage_class" "azurefile_csi_nfs" { + metadata { + name = "azurefile-csi-nfs" + } + storage_provisioner = "file.csi.azure.com" + reclaim_policy = "Delete" + parameters = { + protocol = "nfs" + } + mount_options = ["nconnect=8"] +} diff --git a/infrastructure/kubernetes/modules/storage/variable.tf b/infrastructure/kubernetes/modules/storage/variable.tf new file mode 100644 index 0000000000..1c9dff75e8 --- /dev/null +++ b/infrastructure/kubernetes/modules/storage/variable.tf @@ -0,0 +1,19 @@ +variable "k8s_host" { + description = "Hostname of the k8s cluster" + type = string +} + +variable "k8s_client_certificate" { + description = "Client certificate for the k8s cluster" + type = string +} + +variable "k8s_client_key" { + description = "Client key for the k8s cluster" + type = string +} + +variable "k8s_cluster_ca_certificate" { + description = "Cluster CA certificate for the k8s cluster" + type = string +} diff --git a/infrastructure/kubernetes/modules/storage/versions.tf b/infrastructure/kubernetes/modules/storage/versions.tf new file mode 100644 index 0000000000..deb9e3ee86 --- /dev/null +++ b/infrastructure/kubernetes/modules/storage/versions.tf @@ -0,0 +1,21 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "2.92.0" + } + + kubernetes = { + source = "hashicorp/kubernetes" + version = "~> 2.8.0" + } + } + required_version = "1.1.3" +} + +provider "kubernetes" { + host = var.k8s_host + client_certificate = var.k8s_client_certificate + client_key = var.k8s_client_key + cluster_ca_certificate = var.k8s_cluster_ca_certificate +} From 0fd409ee847ee469d38849aaad0b94ca84d11f55 Mon Sep 17 00:00:00 2001 From: andrea rota Date: Mon, 4 Apr 2022 21:04:34 +0100 Subject: [PATCH 2/6] add persistent volume claims --- infrastructure/kubernetes/main.tf | 16 ++++++++++++++++ infrastructure/kubernetes/modules/api/main.tf | 13 +++++++++++++ .../kubernetes/modules/api/variable.tf | 15 +++++++++++++++ .../kubernetes/modules/geoprocessing/main.tf | 12 ++++++++++++ .../modules/geoprocessing/variable.tf | 15 +++++++++++++++ .../kubernetes/modules/storage/main.tf | 19 ++++++++++++++++++- .../kubernetes/modules/storage/variable.tf | 5 +++++ 7 files changed, 94 insertions(+), 1 deletion(-) diff --git a/infrastructure/kubernetes/main.tf b/infrastructure/kubernetes/main.tf index 58aa32cb0f..1f53cfada4 100644 --- a/infrastructure/kubernetes/main.tf +++ b/infrastructure/kubernetes/main.tf @@ -39,6 +39,9 @@ locals { k8s_client_certificate = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.client_certificate) k8s_client_key = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.client_key) k8s_cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.cluster_ca_certificate) + backend_storage_class = "azurefile-csi-nfs" + backend_storage_size = "100Gi" + backend_storage_pvc = "backend-shared-spatial-data-storage" } module "k8s_namespaces" { @@ -65,6 +68,7 @@ module "k8s_storage" { k8s_client_certificate = local.k8s_client_certificate k8s_client_key = local.k8s_client_key k8s_cluster_ca_certificate = local.k8s_cluster_ca_certificate + backend_storage_class = local.backend_storage_class } #### @@ -115,6 +119,9 @@ module "api_production" { application_base_url = "https://${var.domain}" network_cors_origins = "https://${var.domain}" http_logging_morgan_format = "" + backend_storage_class = local.backend_storage_class + backend_storage_pvc = local.backend_storage_pvc + backend_storage_size = local.backend_storage_size } module "geoprocessing_production" { @@ -126,6 +133,9 @@ module "geoprocessing_production" { namespace = "production" image = "marxan.azurecr.io/marxan-geoprocessing:production" deployment_name = "geoprocessing" + backend_storage_class = local.backend_storage_class + backend_storage_pvc = local.backend_storage_pvc + backend_storage_size = local.backend_storage_size } module "client_production" { @@ -231,6 +241,9 @@ module "api_staging" { application_base_url = "https://staging.${var.domain}" network_cors_origins = "https://staging.${var.domain}" http_logging_morgan_format = "short" + backend_storage_class = local.backend_storage_class + backend_storage_pvc = local.backend_storage_pvc + backend_storage_size = local.backend_storage_size } module "geoprocessing_staging" { @@ -243,6 +256,9 @@ module "geoprocessing_staging" { image = "marxan.azurecr.io/marxan-geoprocessing:staging" deployment_name = "geoprocessing" cleanup_temporary_folders = "false" + backend_storage_class = local.backend_storage_class + backend_storage_pvc = local.backend_storage_pvc + backend_storage_size = local.backend_storage_size } module "client_staging" { diff --git a/infrastructure/kubernetes/modules/api/main.tf b/infrastructure/kubernetes/modules/api/main.tf index 4c4e6af1f1..bbd2b6afb9 100644 --- a/infrastructure/kubernetes/modules/api/main.tf +++ b/infrastructure/kubernetes/modules/api/main.tf @@ -53,6 +53,14 @@ resource "kubernetes_deployment" "api_deployment" { } } + volume { + name = "shared-spatial-data-storage" + persistent_volume_claim { + # @debt use var + claim_name = "backend-shared-spatial-data-storage" + } + } + container { image = var.image image_pull_policy = "Always" @@ -60,6 +68,11 @@ resource "kubernetes_deployment" "api_deployment" { args = ["start"] + volume_mount { + mount_path = "/tmp/storage" + name = "shared-spatial-data-storage" + } + env { name = "API_POSTGRES_HOST" value_from { diff --git a/infrastructure/kubernetes/modules/api/variable.tf b/infrastructure/kubernetes/modules/api/variable.tf index 7dcbfdfbbc..ef80935a56 100644 --- a/infrastructure/kubernetes/modules/api/variable.tf +++ b/infrastructure/kubernetes/modules/api/variable.tf @@ -48,3 +48,18 @@ variable "http_logging_morgan_format" { type = string description = "Value for the BACKEND_HTTP_LOGGING_MORGAN_FORMAT env var" } + +variable "backend_storage_class" { + type = string + description = "Name of the storage class to use for backend storage" +} + +variable "backend_storage_pvc" { + type = string + description = "Name of the PVC to use for backend storage" +} + +variable "backend_storage_size" { + type = string + description = "Size of the PVC to use for backend storage" +} diff --git a/infrastructure/kubernetes/modules/geoprocessing/main.tf b/infrastructure/kubernetes/modules/geoprocessing/main.tf index 898ef7dd47..252af29cb4 100644 --- a/infrastructure/kubernetes/modules/geoprocessing/main.tf +++ b/infrastructure/kubernetes/modules/geoprocessing/main.tf @@ -53,6 +53,14 @@ resource "kubernetes_deployment" "geoprocessing_deployment" { } } + volume { + name = "shared-spatial-data-storage" + persistent_volume_claim { + # @debt use var + claim_name = "backend-shared-spatial-data-storage" + } + } + container { image = var.image image_pull_policy = "Always" @@ -60,6 +68,10 @@ resource "kubernetes_deployment" "geoprocessing_deployment" { args = ["start"] + volume_mount { + mount_path = "/tmp/storage" + name = "shared-spatial-data-storage" + } env { name = "API_POSTGRES_HOST" diff --git a/infrastructure/kubernetes/modules/geoprocessing/variable.tf b/infrastructure/kubernetes/modules/geoprocessing/variable.tf index 1604ac74e9..6bfd568960 100644 --- a/infrastructure/kubernetes/modules/geoprocessing/variable.tf +++ b/infrastructure/kubernetes/modules/geoprocessing/variable.tf @@ -38,3 +38,18 @@ variable "cleanup_temporary_folders" { default = true description = "Whether to cleanup temporary folders (should only be false temporarily and for diagnostic purposes)" } + +variable "backend_storage_class" { + type = string + description = "Name of the storage class to use for backend storage" +} + +variable "backend_storage_pvc" { + type = string + description = "Name of the PVC to use for backend storage" +} + +variable "backend_storage_size" { + type = string + description = "Size of the PVC to use for backend storage" +} diff --git a/infrastructure/kubernetes/modules/storage/main.tf b/infrastructure/kubernetes/modules/storage/main.tf index d17b01f3f4..d6389346bc 100644 --- a/infrastructure/kubernetes/modules/storage/main.tf +++ b/infrastructure/kubernetes/modules/storage/main.tf @@ -1,6 +1,6 @@ resource "kubernetes_storage_class" "azurefile_csi_nfs" { metadata { - name = "azurefile-csi-nfs" + name = var.backend_storage_class } storage_provisioner = "file.csi.azure.com" reclaim_policy = "Delete" @@ -9,3 +9,20 @@ resource "kubernetes_storage_class" "azurefile_csi_nfs" { } mount_options = ["nconnect=8"] } + +resource "kubernetes_persistent_volume_claim" "backend_shared_spatial_data_storage" { + metadata { + # @debt use var + name = "backend-shared-spatial-data-storage" + namespace = var.namespace + } + spec { + access_modes = ["ReadWriteMany"] + storage_class_name = var.backend_storage_class + resources { + requests = { + storage = var.backend_storage_size + } + } + } +} diff --git a/infrastructure/kubernetes/modules/storage/variable.tf b/infrastructure/kubernetes/modules/storage/variable.tf index 1c9dff75e8..66407fbcb8 100644 --- a/infrastructure/kubernetes/modules/storage/variable.tf +++ b/infrastructure/kubernetes/modules/storage/variable.tf @@ -17,3 +17,8 @@ variable "k8s_cluster_ca_certificate" { description = "Cluster CA certificate for the k8s cluster" type = string } + +variable "backend_storage_class" { + description = "Storage class for backend storage" + type = string +} From 0c921b3de53ac78f211c753181a2111dca53f7c5 Mon Sep 17 00:00:00 2001 From: andrea rota Date: Wed, 6 Apr 2022 20:52:21 +0100 Subject: [PATCH 3/6] move pvc resource --- .../kubernetes/modules/storage/main.tf | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/infrastructure/kubernetes/modules/storage/main.tf b/infrastructure/kubernetes/modules/storage/main.tf index d6389346bc..7ccc0bad0f 100644 --- a/infrastructure/kubernetes/modules/storage/main.tf +++ b/infrastructure/kubernetes/modules/storage/main.tf @@ -9,20 +9,3 @@ resource "kubernetes_storage_class" "azurefile_csi_nfs" { } mount_options = ["nconnect=8"] } - -resource "kubernetes_persistent_volume_claim" "backend_shared_spatial_data_storage" { - metadata { - # @debt use var - name = "backend-shared-spatial-data-storage" - namespace = var.namespace - } - spec { - access_modes = ["ReadWriteMany"] - storage_class_name = var.backend_storage_class - resources { - requests = { - storage = var.backend_storage_size - } - } - } -} From b41a5bc08178dbb3eb775d67e44c040cf1b2ac3e Mon Sep 17 00:00:00 2001 From: andrea rota Date: Thu, 7 Apr 2022 11:04:12 +0100 Subject: [PATCH 4/6] move PVC to its own module --- infrastructure/kubernetes/main.tf | 42 +++++++++++++------ infrastructure/kubernetes/modules/api/main.tf | 3 +- .../kubernetes/modules/api/variable.tf | 12 +----- .../kubernetes/modules/geoprocessing/main.tf | 3 +- .../modules/geoprocessing/variable.tf | 12 +----- .../kubernetes/modules/key_vault/variable.tf | 1 - 6 files changed, 33 insertions(+), 40 deletions(-) diff --git a/infrastructure/kubernetes/main.tf b/infrastructure/kubernetes/main.tf index 1f53cfada4..cb135942c7 100644 --- a/infrastructure/kubernetes/main.tf +++ b/infrastructure/kubernetes/main.tf @@ -41,7 +41,7 @@ locals { k8s_cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.cluster_ca_certificate) backend_storage_class = "azurefile-csi-nfs" backend_storage_size = "100Gi" - backend_storage_pvc = "backend-shared-spatial-data-storage" + backend_storage_pvc_name = "backend-shared-spatial-data-storage" } module "k8s_namespaces" { @@ -107,6 +107,18 @@ module "k8s_geoprocessing_database_production" { key_vault_id = module.key_vault_production.key_vault_id } +module "backend_storage_pvc_production" { + source = "./modules/volumes" + k8s_host = local.k8s_host + k8s_client_certificate = local.k8s_client_certificate + k8s_client_key = local.k8s_client_key + k8s_cluster_ca_certificate = local.k8s_cluster_ca_certificate + namespace = "production" + backend_storage_class = local.backend_storage_class + backend_storage_pvc_name = local.backend_storage_pvc_name + backend_storage_size = local.backend_storage_size +} + module "api_production" { source = "./modules/api" k8s_host = local.k8s_host @@ -119,9 +131,7 @@ module "api_production" { application_base_url = "https://${var.domain}" network_cors_origins = "https://${var.domain}" http_logging_morgan_format = "" - backend_storage_class = local.backend_storage_class - backend_storage_pvc = local.backend_storage_pvc - backend_storage_size = local.backend_storage_size + backend_storage_pvc_name = local.backend_storage_pvc_name } module "geoprocessing_production" { @@ -133,9 +143,7 @@ module "geoprocessing_production" { namespace = "production" image = "marxan.azurecr.io/marxan-geoprocessing:production" deployment_name = "geoprocessing" - backend_storage_class = local.backend_storage_class - backend_storage_pvc = local.backend_storage_pvc - backend_storage_size = local.backend_storage_size + backend_storage_pvc_name = local.backend_storage_pvc_name } module "client_production" { @@ -229,6 +237,18 @@ module "k8s_geoprocessing_database_staging" { key_vault_id = module.key_vault_staging.key_vault_id } +module "backend_storage_pvc_staging" { + source = "./modules/volumes" + k8s_host = local.k8s_host + k8s_client_certificate = local.k8s_client_certificate + k8s_client_key = local.k8s_client_key + k8s_cluster_ca_certificate = local.k8s_cluster_ca_certificate + namespace = "staging" + backend_storage_class = local.backend_storage_class + backend_storage_pvc_name = local.backend_storage_pvc_name + backend_storage_size = local.backend_storage_size +} + module "api_staging" { source = "./modules/api" k8s_host = local.k8s_host @@ -241,9 +261,7 @@ module "api_staging" { application_base_url = "https://staging.${var.domain}" network_cors_origins = "https://staging.${var.domain}" http_logging_morgan_format = "short" - backend_storage_class = local.backend_storage_class - backend_storage_pvc = local.backend_storage_pvc - backend_storage_size = local.backend_storage_size + backend_storage_pvc_name = local.backend_storage_pvc_name } module "geoprocessing_staging" { @@ -256,9 +274,7 @@ module "geoprocessing_staging" { image = "marxan.azurecr.io/marxan-geoprocessing:staging" deployment_name = "geoprocessing" cleanup_temporary_folders = "false" - backend_storage_class = local.backend_storage_class - backend_storage_pvc = local.backend_storage_pvc - backend_storage_size = local.backend_storage_size + backend_storage_pvc_name = local.backend_storage_pvc_name } module "client_staging" { diff --git a/infrastructure/kubernetes/modules/api/main.tf b/infrastructure/kubernetes/modules/api/main.tf index bbd2b6afb9..9d43d577b1 100644 --- a/infrastructure/kubernetes/modules/api/main.tf +++ b/infrastructure/kubernetes/modules/api/main.tf @@ -56,8 +56,7 @@ resource "kubernetes_deployment" "api_deployment" { volume { name = "shared-spatial-data-storage" persistent_volume_claim { - # @debt use var - claim_name = "backend-shared-spatial-data-storage" + claim_name = var.backend_storage_pvc_name } } diff --git a/infrastructure/kubernetes/modules/api/variable.tf b/infrastructure/kubernetes/modules/api/variable.tf index ef80935a56..53a4fe2325 100644 --- a/infrastructure/kubernetes/modules/api/variable.tf +++ b/infrastructure/kubernetes/modules/api/variable.tf @@ -49,17 +49,7 @@ variable "http_logging_morgan_format" { description = "Value for the BACKEND_HTTP_LOGGING_MORGAN_FORMAT env var" } -variable "backend_storage_class" { - type = string - description = "Name of the storage class to use for backend storage" -} - -variable "backend_storage_pvc" { +variable "backend_storage_pvc_name" { type = string description = "Name of the PVC to use for backend storage" } - -variable "backend_storage_size" { - type = string - description = "Size of the PVC to use for backend storage" -} diff --git a/infrastructure/kubernetes/modules/geoprocessing/main.tf b/infrastructure/kubernetes/modules/geoprocessing/main.tf index 252af29cb4..a2730a6098 100644 --- a/infrastructure/kubernetes/modules/geoprocessing/main.tf +++ b/infrastructure/kubernetes/modules/geoprocessing/main.tf @@ -56,8 +56,7 @@ resource "kubernetes_deployment" "geoprocessing_deployment" { volume { name = "shared-spatial-data-storage" persistent_volume_claim { - # @debt use var - claim_name = "backend-shared-spatial-data-storage" + claim_name = var.backend_storage_pvc_name } } diff --git a/infrastructure/kubernetes/modules/geoprocessing/variable.tf b/infrastructure/kubernetes/modules/geoprocessing/variable.tf index 6bfd568960..47d8a6409a 100644 --- a/infrastructure/kubernetes/modules/geoprocessing/variable.tf +++ b/infrastructure/kubernetes/modules/geoprocessing/variable.tf @@ -39,17 +39,7 @@ variable "cleanup_temporary_folders" { description = "Whether to cleanup temporary folders (should only be false temporarily and for diagnostic purposes)" } -variable "backend_storage_class" { - type = string - description = "Name of the storage class to use for backend storage" -} - -variable "backend_storage_pvc" { +variable "backend_storage_pvc_name" { type = string description = "Name of the PVC to use for backend storage" } - -variable "backend_storage_size" { - type = string - description = "Size of the PVC to use for backend storage" -} diff --git a/infrastructure/kubernetes/modules/key_vault/variable.tf b/infrastructure/kubernetes/modules/key_vault/variable.tf index 4cdcc09b67..b62d47a8cb 100644 --- a/infrastructure/kubernetes/modules/key_vault/variable.tf +++ b/infrastructure/kubernetes/modules/key_vault/variable.tf @@ -7,7 +7,6 @@ variable "resource_group" { description = "The Azure resource group where the module will create its resources" } - variable "namespace" { description = "The k8s namespace in which to deploy resources" } From 9253cdc8fac4cc5adc78ac3e59a232ef7f7d248a Mon Sep 17 00:00:00 2001 From: andrea rota Date: Thu, 7 Apr 2022 13:46:00 +0100 Subject: [PATCH 5/6] add volumes module --- .../kubernetes/modules/volumes/main.tf | 15 ++++++++ .../kubernetes/modules/volumes/variable.tf | 38 +++++++++++++++++++ .../kubernetes/modules/volumes/versions.tf | 21 ++++++++++ 3 files changed, 74 insertions(+) create mode 100644 infrastructure/kubernetes/modules/volumes/main.tf create mode 100644 infrastructure/kubernetes/modules/volumes/variable.tf create mode 100644 infrastructure/kubernetes/modules/volumes/versions.tf diff --git a/infrastructure/kubernetes/modules/volumes/main.tf b/infrastructure/kubernetes/modules/volumes/main.tf new file mode 100644 index 0000000000..40907ab634 --- /dev/null +++ b/infrastructure/kubernetes/modules/volumes/main.tf @@ -0,0 +1,15 @@ +resource "kubernetes_persistent_volume_claim" "backend_shared_spatial_data_storage" { + metadata { + name = var.backend_storage_pvc_name + namespace = var.namespace + } + spec { + access_modes = ["ReadWriteMany"] + storage_class_name = var.backend_storage_class + resources { + requests = { + storage = var.backend_storage_size + } + } + } +} diff --git a/infrastructure/kubernetes/modules/volumes/variable.tf b/infrastructure/kubernetes/modules/volumes/variable.tf new file mode 100644 index 0000000000..34a769f827 --- /dev/null +++ b/infrastructure/kubernetes/modules/volumes/variable.tf @@ -0,0 +1,38 @@ +variable "k8s_host" { + description = "Hostname of the k8s cluster" + type = string +} + +variable "k8s_client_certificate" { + description = "Client certificate for the k8s cluster" + type = string +} + +variable "k8s_client_key" { + description = "Client key for the k8s cluster" + type = string +} + +variable "k8s_cluster_ca_certificate" { + description = "Cluster CA certificate for the k8s cluster" + type = string +} + +variable "namespace" { + description = "The k8s namespace in which to deploy resources" +} + +variable "backend_storage_class" { + description = "Storage class for backend storage" + type = string +} + +variable "backend_storage_size" { + type = string + description = "Size of the PVC to use for backend storage" +} + +variable "backend_storage_pvc_name" { + type = string + description = "Name of the PVC to use for backend storage" +} diff --git a/infrastructure/kubernetes/modules/volumes/versions.tf b/infrastructure/kubernetes/modules/volumes/versions.tf new file mode 100644 index 0000000000..deb9e3ee86 --- /dev/null +++ b/infrastructure/kubernetes/modules/volumes/versions.tf @@ -0,0 +1,21 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "2.92.0" + } + + kubernetes = { + source = "hashicorp/kubernetes" + version = "~> 2.8.0" + } + } + required_version = "1.1.3" +} + +provider "kubernetes" { + host = var.k8s_host + client_certificate = var.k8s_client_certificate + client_key = var.k8s_client_key + cluster_ca_certificate = var.k8s_cluster_ca_certificate +} From 3a5a58aa617e42593c0cc12424693cbd00b0089b Mon Sep 17 00:00:00 2001 From: andrea rota Date: Thu, 7 Apr 2022 13:56:23 +0100 Subject: [PATCH 6/6] use a var for backend storage size --- infrastructure/kubernetes/main.tf | 5 ++--- infrastructure/kubernetes/variables.tf | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/infrastructure/kubernetes/main.tf b/infrastructure/kubernetes/main.tf index cb135942c7..505725bd0f 100644 --- a/infrastructure/kubernetes/main.tf +++ b/infrastructure/kubernetes/main.tf @@ -40,7 +40,6 @@ locals { k8s_client_key = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.client_key) k8s_cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.k8s_cluster.kube_config.0.cluster_ca_certificate) backend_storage_class = "azurefile-csi-nfs" - backend_storage_size = "100Gi" backend_storage_pvc_name = "backend-shared-spatial-data-storage" } @@ -116,7 +115,7 @@ module "backend_storage_pvc_production" { namespace = "production" backend_storage_class = local.backend_storage_class backend_storage_pvc_name = local.backend_storage_pvc_name - backend_storage_size = local.backend_storage_size + backend_storage_size = var.backend_storage_size } module "api_production" { @@ -246,7 +245,7 @@ module "backend_storage_pvc_staging" { namespace = "staging" backend_storage_class = local.backend_storage_class backend_storage_pvc_name = local.backend_storage_pvc_name - backend_storage_size = local.backend_storage_size + backend_storage_size = var.backend_storage_size } module "api_staging" { diff --git a/infrastructure/kubernetes/variables.tf b/infrastructure/kubernetes/variables.tf index 382eacc2ea..a0fd6a7d4c 100644 --- a/infrastructure/kubernetes/variables.tf +++ b/infrastructure/kubernetes/variables.tf @@ -29,3 +29,9 @@ variable "sparkpost_api_key" { type = string description = "The API key for Sparkpost" } + +variable "backend_storage_size" { + type = string + default = "100Gi" + description = "Size of the backend storage claim" +}