From 0c1ee921743fdeeaf96de1e25ad53835081813b8 Mon Sep 17 00:00:00 2001 From: Lenny Consuegra Date: Wed, 31 Jan 2024 14:43:38 +0100 Subject: [PATCH] feat: add a subdomain variable --- aks/main.tf | 1 + eks/main.tf | 1 + kind/main.tf | 1 + locals.tf | 14 +++++++------- sks/main.tf | 1 + variables.tf | 6 ++++++ 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/aks/main.tf b/aks/main.tf index d6d332c2..63954da9 100644 --- a/aks/main.tf +++ b/aks/main.tf @@ -61,6 +61,7 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain + subdomain = var.subdomain argocd_project = var.argocd_project argocd_labels = var.argocd_labels destination_cluster = var.destination_cluster diff --git a/eks/main.tf b/eks/main.tf index 1d29690d..385fd282 100644 --- a/eks/main.tf +++ b/eks/main.tf @@ -3,6 +3,7 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain + subdomain = var.subdomain argocd_project = var.argocd_project argocd_labels = var.argocd_labels destination_cluster = var.destination_cluster diff --git a/kind/main.tf b/kind/main.tf index 1d29690d..385fd282 100644 --- a/kind/main.tf +++ b/kind/main.tf @@ -3,6 +3,7 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain + subdomain = var.subdomain argocd_project = var.argocd_project argocd_labels = var.argocd_labels destination_cluster = var.destination_cluster diff --git a/locals.tf b/locals.tf index f0aa3b50..a6f7b609 100644 --- a/locals.tf +++ b/locals.tf @@ -34,7 +34,7 @@ locals { resources = local.thanos.compactor_resources persistence = { # The Access Mode needs to be set as ReadWriteOnce because AWS Elastic Block storage does not support other - # modes (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes). + # modes (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes). # Since the compactor is the only pod accessing this volume, there should be no issue to have this as # ReadWriteOnce (https://stackoverflow.com/a/57799347). accessModes = [ @@ -88,7 +88,7 @@ locals { hostname = "" extraRules = [ { - host = "thanos-bucketweb.apps.${var.base_domain}" + host = "thanos-bucketweb.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}" http = { paths = [ { @@ -129,7 +129,7 @@ locals { extraTls = [{ secretName = "thanos-bucketweb-tls" hosts = [ - "thanos-bucketweb.apps.${var.base_domain}", + "thanos-bucketweb.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}", "${local.thanos.bucketweb_domain}" ] }] @@ -179,7 +179,7 @@ locals { hostname = "" extraRules = [ { - host = "thanos-query.apps.${var.base_domain}" + host = "thanos-query.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}" http = { paths = [ { @@ -220,7 +220,7 @@ locals { extraTls = [{ secretName = "thanos-query-tls" hosts = [ - "thanos-query.apps.${var.base_domain}", + "thanos-query.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}", "${local.thanos.query_domain}" ] }] @@ -231,8 +231,8 @@ locals { }] thanos_defaults = { - query_domain = "thanos-query.apps.${var.cluster_name}.${var.base_domain}" - bucketweb_domain = "thanos-bucketweb.apps.${var.cluster_name}.${var.base_domain}" + query_domain = "thanos-query.${trimprefix("${var.subdomain}.${var.cluster_name}", ".")}.${var.base_domain}" + bucketweb_domain = "thanos-bucketweb.${trimprefix("${var.subdomain}.${var.cluster_name}", ".")}.${var.base_domain}" # TODO Create proper Terraform variables for these values instead of bundling everything inside of these locals diff --git a/sks/main.tf b/sks/main.tf index 1d29690d..385fd282 100644 --- a/sks/main.tf +++ b/sks/main.tf @@ -3,6 +3,7 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain + subdomain = var.subdomain argocd_project = var.argocd_project argocd_labels = var.argocd_labels destination_cluster = var.destination_cluster diff --git a/variables.tf b/variables.tf index 44a4bacb..982c5a74 100644 --- a/variables.tf +++ b/variables.tf @@ -12,6 +12,12 @@ variable "base_domain" { type = string } +variable "subdomain" { + description = "Sub domain of the cluster. Value used for the ingress' URL of the application." + type = string + default = "apps" +} + variable "argocd_project" { description = "Name of the Argo CD AppProject where the Application should be created. If not set, the Application will be created in a new AppProject only for this Application." type = string