From 5c85edb3bdea6e7f516baaf88fdc1aef0940721a Mon Sep 17 00:00:00 2001 From: Michael Barroco Date: Wed, 3 Jan 2024 16:38:55 +0100 Subject: [PATCH] [terraform-helm] Generate helm configuration from terraform --- .../terraform-commons-dss/main.tf | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/deploy/infrastructure/dependencies/terraform-commons-dss/main.tf b/deploy/infrastructure/dependencies/terraform-commons-dss/main.tf index 10523890c..680f57fe5 100644 --- a/deploy/infrastructure/dependencies/terraform-commons-dss/main.tf +++ b/deploy/infrastructure/dependencies/terraform-commons-dss/main.tf @@ -65,4 +65,68 @@ resource "local_file" "get_credentials" { get_credentials_cmd = var.kubernetes_get_credentials_cmd }) filename = "${local.workspace_location}/get-credentials.sh" -} \ No newline at end of file +} + +resource "local_file" "helm_chart_values" { + filename = "${local.workspace_location}/helm_values.yml" + content = yamlencode({ + cockroachdb = { + fullnameOverride = "dss-cockroachdb" + + conf = { + join = var.crdb_external_nodes + cluster-name = "dss-aws-1" + single-node = false + locality = "zone=${var.crdb_locality}" + } + + statefulset = { + args = [ + "--locality-advertise-addr=zone=${var.crdb_locality}@$(hostname -f)", + "--advertise-addr=$${HOSTNAME##*-}.${var.crdb_hostname_suffix}" + ] + } + + storage = { + persistentVolume = { + storageClass = var.kubernetes_storage_class + } + } + } + + loadBalancers = { + cockroachdbNodes = [ + for ip in var.crdb_internal_nodes[*].ip : + { + ip = ip + subnet = var.workload_subnet + } + ] + + dssGateway = { + ip = var.ip_gateway + subnet = var.workload_subnet + certName = var.gateway_cert_name + } + } + + dss = { + image = local.image + + conf = { + pubKeys = [ + "/test-certs/auth2.pem" + ] + jwksEndpoint = var.authorization.jwks != null ? var.authorization.jwks.endpoint : "" + jwksKeyIds = var.authorization.jwks != null ? [var.authorization.jwks.key_id] : [] + hostname = var.app_hostname + enableScd = var.enable_scd + } + } + + global = { + cloudProvider = var.kubernetes_cloud_provider_name + } + }) +} +