Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion terraform/loki/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,27 @@ module "loki_coordinator" {
units = var.coordinator_units
}

module "loki_all" {
source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform"
depends_on = [module.loki_coordinator]
count = var.monolithic ? 1 : 0

app_name = var.all_name
channel = var.channel
constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.all_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints
config = merge({
role-all = true
}, var.all_config)
model_uuid = var.model_uuid
revision = var.worker_revision
storage_directives = var.worker_storage_directives
units = var.all_units
}

module "loki_backend" {
source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform"
depends_on = [module.loki_coordinator]
count = var.monolithic ? 0 : 1

app_name = var.backend_name
channel = var.channel
Expand All @@ -67,6 +85,7 @@ module "loki_backend" {
module "loki_read" {
source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform"
depends_on = [module.loki_coordinator]
count = var.monolithic ? 0 : 1

app_name = var.read_name
channel = var.channel
Expand All @@ -83,6 +102,7 @@ module "loki_read" {
module "loki_write" {
source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform"
depends_on = [module.loki_coordinator]
count = var.monolithic ? 0 : 1

app_name = var.write_name
channel = var.channel
Expand Down Expand Up @@ -112,7 +132,8 @@ resource "juju_integration" "coordinator_to_s3_integrator" {
}

resource "juju_integration" "coordinator_to_backend" {
model_uuid = var.model_uuid
count = var.monolithic ? 0 : 1
model_uuid = var.model_uuidbackend_units

application {
name = module.loki_coordinator.app_name
Expand All @@ -126,6 +147,7 @@ resource "juju_integration" "coordinator_to_backend" {
}

resource "juju_integration" "coordinator_to_read" {
count = var.monolithic ? 0 : 1
model_uuid = var.model_uuid

application {
Expand All @@ -140,6 +162,7 @@ resource "juju_integration" "coordinator_to_read" {
}

resource "juju_integration" "coordinator_to_write" {
count = var.monolithic ? 0 : 1
model_uuid = var.model_uuid

application {
Expand All @@ -152,3 +175,19 @@ resource "juju_integration" "coordinator_to_write" {
endpoint = "loki-cluster"
}
}


resource "juju_integration" "coordinator_to_all" {
count = var.monolithic ? 1 : 0
model_uuid = var.model_uuid

application {
name = module.loki_coordinator.app_name
endpoint = "loki-cluster"
}

application {
name = module.loki_all.app_name
endpoint = "loki-cluster"
}
}
31 changes: 27 additions & 4 deletions terraform/loki/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ variable "anti_affinity" {
default = true
}

variable "monolithic" {
description = "Enable the monolithic deployment mode"
type = bool
default = false
}

# -------------- # S3 object storage --------------

variable "s3_integrator_channel" {
Expand Down Expand Up @@ -46,6 +52,12 @@ variable "s3_endpoint" {

# -------------- # App Names --------------

variable "all_name" {
description = "Name of the Loki app with the all role"
type = string
default = "loki-worker"
}

variable "backend_name" {
description = "Name of the Loki app with the backend role"
type = string
Expand Down Expand Up @@ -186,12 +198,23 @@ variable "s3_integrator_storage_directives" {

# -------------- # Units Per App --------------


variable "all_units" {
description = "Number of Loki worker units with the all role"
type = number
default = 1
validation {
condition = var.all_units >= 1 || var.monolithic == 0
error_message = "The number of units must be greater than or equal to 1."
}
}

variable "backend_units" {
description = "Number of Loki worker units with the backend role"
type = number
default = 1
validation {
condition = var.backend_units >= 1
condition = var.backend_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -201,7 +224,7 @@ variable "read_units" {
type = number
default = 1
validation {
condition = var.read_units >= 1
condition = var.read_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -211,7 +234,7 @@ variable "write_units" {
type = number
default = 1
validation {
condition = var.write_units >= 1
condition = var.write_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -221,7 +244,7 @@ variable "coordinator_units" {
type = number
default = 1
validation {
condition = var.coordinator_units >= 1
condition = var.coordinator_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand Down
44 changes: 44 additions & 0 deletions terraform/mimir/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,30 @@ module "mimir_coordinator" {
units = var.coordinator_units
}


module "mimir_all" {
source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform"
depends_on = [module.mimir_coordinator]
count = var.monolithic ? 1 : 0

app_name = var.all_name
channel = var.channel
constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.backend_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints
config = merge({
role-all = true
}, var.all_config)
model_uuid = var.model_uuid
revision = var.worker_revision
storage_directives = var.worker_storage_directives
units = var.all_units
}


module "mimir_backend" {
source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform"
depends_on = [module.mimir_coordinator]
count = var.monolithic ? 0 : 1


app_name = var.backend_name
channel = var.channel
Expand All @@ -68,6 +89,7 @@ module "mimir_backend" {
module "mimir_read" {
source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform"
depends_on = [module.mimir_coordinator]
count = var.monolithic ? 0 : 1

app_name = var.read_name
channel = var.channel
Expand All @@ -84,6 +106,7 @@ module "mimir_read" {
module "mimir_write" {
source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform"
depends_on = [module.mimir_coordinator]
count = var.monolithic ? 0 : 1

app_name = var.write_name
channel = var.channel
Expand All @@ -101,6 +124,7 @@ module "mimir_write" {

resource "juju_integration" "coordinator_to_s3_integrator" {
model_uuid = var.model_uuid

application {
name = juju_application.s3_integrator.name
endpoint = "s3-credentials"
Expand All @@ -114,6 +138,7 @@ resource "juju_integration" "coordinator_to_s3_integrator" {

resource "juju_integration" "coordinator_to_read" {
model_uuid = var.model_uuid
count = var.monolithic ? 0 : 1

application {
name = module.mimir_coordinator.app_name
Expand All @@ -128,6 +153,7 @@ resource "juju_integration" "coordinator_to_read" {

resource "juju_integration" "coordinator_to_write" {
model_uuid = var.model_uuid
count = var.monolithic ? 0 : 1

application {
name = module.mimir_coordinator.app_name
Expand All @@ -142,6 +168,8 @@ resource "juju_integration" "coordinator_to_write" {

resource "juju_integration" "coordinator_to_backend" {
model_uuid = var.model_uuid
count = var.monolithic ? 0 : 1


application {
name = module.mimir_coordinator.app_name
Expand All @@ -153,3 +181,19 @@ resource "juju_integration" "coordinator_to_backend" {
endpoint = "mimir-cluster"
}
}

resource "juju_integration" "coordinator_to_all" {
model_uuid = var.model_uuid
count = var.monolithic ? 1 : 0


application {
name = module.mimir_coordinator.app_name
endpoint = "mimir-cluster"
}

application {
name = module.mimir_all.app_name
endpoint = "mimir-cluster"
}
}
38 changes: 34 additions & 4 deletions terraform/mimir/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ variable "anti_affinity" {
default = true
}

variable "monolithic" {
description = "Enable the monolithic deployment mode."
type = bool
default = false
}

# -------------- # S3 object storage --------------

variable "s3_integrator_channel" {
Expand Down Expand Up @@ -46,6 +52,13 @@ variable "s3_endpoint" {

# -------------- # App Names --------------


variable "all_name" {
description = "Name of the Mimir all (meta role) app"
type = string
default = "mimir-worker"
}

variable "read_name" {
description = "Name of the Mimir read (meta role) app"
type = string
Expand Down Expand Up @@ -78,6 +91,13 @@ variable "coordinator_config" {
default = {}
}


variable "all_config" {
description = "Map of the all worker configuration options"
type = map(string)
default = {}
}

variable "backend_config" {
description = "Map of the backend worker configuration options"
type = map(string)
Expand Down Expand Up @@ -186,12 +206,22 @@ variable "s3_integrator_storage_directives" {

# -------------- # Units Per App --------------

variable "all_units" {
description = "Number of Mimir worker units with the all meta role"
type = number
default = 1
validation {
condition = var.all_units >= 1 || var.monolithic == 0
error_message = "The number of units must be greater than or equal to 1."
}
}

variable "read_units" {
description = "Number of Mimir worker units with the read meta role"
type = number
default = 1
validation {
condition = var.read_units >= 1
condition = var.read_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -201,7 +231,7 @@ variable "write_units" {
type = number
default = 1
validation {
condition = var.write_units >= 1
condition = var.write_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -211,7 +241,7 @@ variable "backend_units" {
type = number
default = 1
validation {
condition = var.backend_units >= 1
condition = var.backend_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand All @@ -221,7 +251,7 @@ variable "coordinator_units" {
type = number
default = 1
validation {
condition = var.coordinator_units >= 1
condition = var.coordinator_units >= 1 || var.monolithic == 1
error_message = "The number of units must be greater than or equal to 1."
}
}
Expand Down
Loading