Skip to content

Commit

Permalink
feat: add a subdomain variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lconsuegra authored and lentidas committed Feb 20, 2024
1 parent 947e24d commit 2a27233
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions kind/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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 = [
Expand Down Expand Up @@ -127,7 +127,7 @@ locals {
hostname = ""
extraRules = [
{
host = "thanos-bucketweb.apps.${var.base_domain}"
host = "thanos-bucketweb.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}"
http = {
paths = [
{
Expand Down Expand Up @@ -168,7 +168,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}"
]
}]
Expand Down Expand Up @@ -261,7 +261,7 @@ locals {
hostname = ""
extraRules = [
{
host = "thanos-query.apps.${var.base_domain}"
host = "thanos-query.${trimprefix("${var.subdomain}.${var.base_domain}", ".")}"
http = {
paths = [
{
Expand Down Expand Up @@ -302,7 +302,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}"
]
}]
Expand All @@ -316,8 +316,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

Expand Down
1 change: 1 addition & 0 deletions sks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a27233

Please sign in to comment.