From 840d17dcb30346f81052e0d168853dd7c49dc55f Mon Sep 17 00:00:00 2001 From: Michael Thamm Date: Tue, 31 Mar 2026 11:30:38 -0400 Subject: [PATCH 1/2] fix: Migrate to monorepos --- terraform/cos/README.md | 4 ++-- terraform/cos/applications.tf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/terraform/cos/README.md b/terraform/cos/README.md index 516bac7f..07d1cedd 100644 --- a/terraform/cos/README.md +++ b/terraform/cos/README.md @@ -19,8 +19,8 @@ This is a Terraform module facilitating the deployment of the COS solution, usin | [alertmanager](#module\_alertmanager) | git::https://github.com/canonical/alertmanager-k8s-operator//terraform | track/2 | | [catalogue](#module\_catalogue) | git::https://github.com/canonical/catalogue-k8s-operator//terraform | track/2 | | [grafana](#module\_grafana) | git::https://github.com/canonical/grafana-k8s-operator//terraform | track/2 | -| [loki](#module\_loki) | git::https://github.com/canonical/observability-stack//terraform/loki | track/2 | -| [mimir](#module\_mimir) | git::https://github.com/canonical/observability-stack//terraform/mimir | track/2 | +| [loki](#module\_loki) | git::https://github.com/canonical/loki-operators//terraform | track/2 | +| [mimir](#module\_mimir) | git::https://github.com/canonical/mimir-operators//terraform | track/2 | | [opentelemetry\_collector](#module\_opentelemetry\_collector) | git::https://github.com/canonical/opentelemetry-collector-k8s-operator//terraform | track/2 | | [ssc](#module\_ssc) | git::https://github.com/canonical/self-signed-certificates-operator//terraform | n/a | | [tempo](#module\_tempo) | git::https://github.com/canonical/tempo-operators//terraform | track/2 | diff --git a/terraform/cos/applications.tf b/terraform/cos/applications.tf index 0e6d526b..3bc0a1d1 100644 --- a/terraform/cos/applications.tf +++ b/terraform/cos/applications.tf @@ -35,7 +35,7 @@ module "grafana" { } module "loki" { - source = "git::https://github.com/canonical/observability-stack//terraform/loki?ref=track/2" + source = "git::https://github.com/canonical/loki-operators//terraform?ref=track/2" anti_affinity = var.anti_affinity channel = var.channel model_uuid = var.model_uuid @@ -66,7 +66,7 @@ module "loki" { } module "mimir" { - source = "git::https://github.com/canonical/observability-stack//terraform/mimir?ref=track/2" + source = "git::https://github.com/canonical/mimir-operators//terraform?ref=track/2" anti_affinity = var.anti_affinity channel = var.channel model_uuid = var.model_uuid From d0616384636dc16e67f720b1b74911a06dd208e1 Mon Sep 17 00:00:00 2001 From: Michael Thamm Date: Wed, 1 Apr 2026 13:14:58 -0400 Subject: [PATCH 2/2] chore: remove loki and mimir modules --- terraform/loki/README.md | 73 ----------- terraform/loki/main.tf | 154 ----------------------- terraform/loki/outputs.tf | 33 ----- terraform/loki/variables.tf | 237 ----------------------------------- terraform/loki/versions.tf | 9 -- terraform/mimir/README.md | 73 ----------- terraform/mimir/main.tf | 155 ----------------------- terraform/mimir/outputs.tf | 34 ----- terraform/mimir/variables.tf | 237 ----------------------------------- terraform/mimir/versions.tf | 9 -- 10 files changed, 1014 deletions(-) delete mode 100644 terraform/loki/README.md delete mode 100644 terraform/loki/main.tf delete mode 100644 terraform/loki/outputs.tf delete mode 100644 terraform/loki/variables.tf delete mode 100644 terraform/loki/versions.tf delete mode 100644 terraform/mimir/README.md delete mode 100644 terraform/mimir/main.tf delete mode 100644 terraform/mimir/outputs.tf delete mode 100644 terraform/mimir/variables.tf delete mode 100644 terraform/mimir/versions.tf diff --git a/terraform/loki/README.md b/terraform/loki/README.md deleted file mode 100644 index a739bd6e..00000000 --- a/terraform/loki/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Terraform module for Loki solution - -This is a Terraform module facilitating the deployment of Loki solution, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs).This Terraform module deploys Loki in its [microservices mode](https://grafana.com/docs/enterprise-logs/latest/get-started/deployment-modes/#microservices-mode), which runs each one of the required roles in distinct processes. - -> [!NOTE] -> `s3-integrator` itself doesn't act as an S3 object storage system. For the HA solution to be functional, `s3-integrator` needs to point to an S3-like storage. See [this guide](https://discourse.charmhub.io/t/cos-lite-docs-set-up-minio/15211) to learn how to connect to an S3-like storage for traces. - - -## Providers - -| Name | Version | -|------|---------| -| [juju](#provider\_juju) | ~> 1.0 | - -## Modules - -| Name | Source | Version | -|------|--------|---------| -| [loki\_backend](#module\_loki\_backend) | git::https://github.com/canonical/loki-worker-k8s-operator//terraform | track/2 | -| [loki\_coordinator](#module\_loki\_coordinator) | git::https://github.com/canonical/loki-coordinator-k8s-operator//terraform | track/2 | -| [loki\_read](#module\_loki\_read) | git::https://github.com/canonical/loki-worker-k8s-operator//terraform | track/2 | -| [loki\_write](#module\_loki\_write) | git::https://github.com/canonical/loki-worker-k8s-operator//terraform | track/2 | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [anti\_affinity](#input\_anti\_affinity) | Enable anti-affinity constraints. | `bool` | `true` | no | -| [backend\_config](#input\_backend\_config) | Map of the backend worker configuration options | `map(string)` | `{}` | no | -| [backend\_name](#input\_backend\_name) | Name of the Loki app with the backend role | `string` | `"loki-backend"` | no | -| [backend\_units](#input\_backend\_units) | Number of Loki worker units with the backend role | `number` | `1` | no | -| [channel](#input\_channel) | Channel that the applications are deployed from | `string` | n/a | yes | -| [coordinator\_config](#input\_coordinator\_config) | Map of the coordinator configuration options | `map(string)` | `{}` | no | -| [coordinator\_constraints](#input\_coordinator\_constraints) | String listing constraints for the coordinator application | `string` | `"arch=amd64"` | no | -| [coordinator\_revision](#input\_coordinator\_revision) | Revision number of the coordinator application | `number` | `null` | no | -| [coordinator\_storage\_directives](#input\_coordinator\_storage\_directives) | Map of storage used by the coordinator application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [coordinator\_units](#input\_coordinator\_units) | Number of Loki coordinator units | `number` | `1` | no | -| [model\_uuid](#input\_model\_uuid) | Reference to an existing model resource or data source for the model to deploy to | `string` | n/a | yes | -| [read\_config](#input\_read\_config) | Map of the read worker configuration options | `map(string)` | `{}` | no | -| [read\_name](#input\_read\_name) | Name of the Loki app with the read role | `string` | `"loki-read"` | no | -| [read\_units](#input\_read\_units) | Number of Loki worker units with the read role | `number` | `1` | no | -| [s3\_access\_key](#input\_s3\_access\_key) | S3 access-key credential | `string` | n/a | yes | -| [s3\_bucket](#input\_s3\_bucket) | Bucket name | `string` | `"loki"` | no | -| [s3\_endpoint](#input\_s3\_endpoint) | S3 endpoint | `string` | n/a | yes | -| [s3\_integrator\_channel](#input\_s3\_integrator\_channel) | Channel that the s3-integrator application is deployed from | `string` | `"2/edge"` | no | -| [s3\_integrator\_config](#input\_s3\_integrator\_config) | Map of the s3-integrator configuration options | `map(string)` | `{}` | no | -| [s3\_integrator\_constraints](#input\_s3\_integrator\_constraints) | String listing constraints for the s3-integrator application | `string` | `"arch=amd64"` | no | -| [s3\_integrator\_name](#input\_s3\_integrator\_name) | Name of the s3-integrator app | `string` | `"loki-s3-integrator"` | no | -| [s3\_integrator\_revision](#input\_s3\_integrator\_revision) | Revision number of the s3-integrator application | `number` | `null` | no | -| [s3\_integrator\_storage\_directives](#input\_s3\_integrator\_storage\_directives) | Map of storage used by the s3-integrator application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [s3\_integrator\_units](#input\_s3\_integrator\_units) | Number of S3 integrator units | `number` | `1` | no | -| [s3\_secret\_key](#input\_s3\_secret\_key) | S3 secret-key credential | `string` | n/a | yes | -| [worker\_constraints](#input\_worker\_constraints) | String listing constraints for the worker application | `string` | `"arch=amd64"` | no | -| [worker\_revision](#input\_worker\_revision) | Revision number of the worker application | `number` | `null` | no | -| [worker\_storage\_directives](#input\_worker\_storage\_directives) | Map of storage used by the worker application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [write\_config](#input\_write\_config) | Map of the write worker configuration options | `map(string)` | `{}` | no | -| [write\_name](#input\_write\_name) | Name of the Loki app with the write role | `string` | `"loki-write"` | no | -| [write\_units](#input\_write\_units) | Number of Loki worker units with the write role | `number` | `1` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [app\_names](#output\_app\_names) | All application names which make up this product module | -| [endpoints](#output\_endpoints) | All Juju integration endpoints which make up this product module | - - -## Usage - -### Microservice deployment - -By default, this Terraform module will deploy each Loki worker with `1` unit. To configure the module to run `x` units of any worker role, you can run `terraform apply -var="_units="`. -See [Loki worker roles](https://discourse.charmhub.io/t/loki-worker-roles/15484) for the recommended scale for each role. diff --git a/terraform/loki/main.tf b/terraform/loki/main.tf deleted file mode 100644 index b7958f41..00000000 --- a/terraform/loki/main.tf +++ /dev/null @@ -1,154 +0,0 @@ -resource "juju_secret" "loki_s3_credentials_secret" { - model_uuid = var.model_uuid - name = "loki_s3_credentials" - value = { - access-key = var.s3_access_key - secret-key = var.s3_secret_key - } - info = "Credentials for the S3 endpoint" -} - -resource "juju_access_secret" "loki_s3_secret_access" { - model_uuid = var.model_uuid - applications = [ - juju_application.s3_integrator.name - ] - secret_id = juju_secret.loki_s3_credentials_secret.secret_id -} - -# TODO: Replace s3_integrator resource to use its remote terraform module once available -resource "juju_application" "s3_integrator" { - config = merge({ - endpoint = var.s3_endpoint - bucket = var.s3_bucket - credentials = "secret:${juju_secret.loki_s3_credentials_secret.secret_id}" - }, var.s3_integrator_config) - constraints = var.s3_integrator_constraints - model_uuid = var.model_uuid - name = var.s3_integrator_name - storage_directives = var.s3_integrator_storage_directives - trust = true - units = var.s3_integrator_units - - charm { - name = "s3-integrator" - channel = var.s3_integrator_channel - revision = var.s3_integrator_revision - } -} - -module "loki_coordinator" { - source = "git::https://github.com/canonical/loki-coordinator-k8s-operator//terraform?ref=track/2" - app_name = "loki" - channel = var.channel - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=loki,anti-pod.topology-key=kubernetes.io/hostname" : var.coordinator_constraints - model_uuid = var.model_uuid - revision = var.coordinator_revision - storage_directives = var.coordinator_storage_directives - units = var.coordinator_units -} - -module "loki_backend" { - source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.loki_coordinator] - - app_name = var.backend_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-backend = true - }, var.backend_config) - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.backend_units -} - -module "loki_read" { - source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.loki_coordinator] - - app_name = var.read_name - channel = var.channel - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.read_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints - config = merge({ - role-read = true - }, var.read_config) - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.read_units -} - -module "loki_write" { - source = "git::https://github.com/canonical/loki-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.loki_coordinator] - - app_name = var.write_name - channel = var.channel - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.write_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints - config = merge({ - role-write = true - }, var.write_config) - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.write_units -} - -# -------------- # Integrations -------------- - -resource "juju_integration" "coordinator_to_s3_integrator" { - model_uuid = var.model_uuid - application { - name = juju_application.s3_integrator.name - endpoint = "s3-credentials" - } - - application { - name = module.loki_coordinator.app_name - endpoint = "s3" - } -} - -resource "juju_integration" "coordinator_to_backend" { - model_uuid = var.model_uuid - - application { - name = module.loki_coordinator.app_name - endpoint = "loki-cluster" - } - - application { - name = module.loki_backend.app_name - endpoint = "loki-cluster" - } -} - -resource "juju_integration" "coordinator_to_read" { - model_uuid = var.model_uuid - - application { - name = module.loki_coordinator.app_name - endpoint = "loki-cluster" - } - - application { - name = module.loki_read.app_name - endpoint = "loki-cluster" - } -} - -resource "juju_integration" "coordinator_to_write" { - model_uuid = var.model_uuid - - application { - name = module.loki_coordinator.app_name - endpoint = "loki-cluster" - } - - application { - name = module.loki_write.app_name - endpoint = "loki-cluster" - } -} diff --git a/terraform/loki/outputs.tf b/terraform/loki/outputs.tf deleted file mode 100644 index ed282902..00000000 --- a/terraform/loki/outputs.tf +++ /dev/null @@ -1,33 +0,0 @@ -output "app_names" { - value = merge( - { - loki_s3_integrator = juju_application.s3_integrator.name, - loki_coordinator = module.loki_coordinator.app_name, - loki_backend = module.loki_backend.app_name, - loki_read = module.loki_read.app_name, - loki_write = module.loki_write.app_name, - } - ) - description = "All application names which make up this product module" -} - -output "endpoints" { - value = { - # Requires - alertmanager = "alertmanager", - certificates = "certificates", - ingress = "ingress", - logging_consumer = "logging-consumer", - s3 = "s3", - charm_tracing = "charm-tracing", - # Provides - grafana_dashboards_provider = "grafana-dashboards-provider", - grafana_source = "grafana-source", - logging = "logging", - loki_cluster = "loki-cluster", - receive_remote_write = "receive-remote-write", - self_metrics_endpoint = "self-metrics-endpoint", - send_datasource = "send-datasource", - } - description = "All Juju integration endpoints which make up this product module" -} diff --git a/terraform/loki/variables.tf b/terraform/loki/variables.tf deleted file mode 100644 index c3676c6f..00000000 --- a/terraform/loki/variables.tf +++ /dev/null @@ -1,237 +0,0 @@ -variable "model_uuid" { - description = "Reference to an existing model resource or data source for the model to deploy to" - type = string -} - -variable "channel" { - description = "Channel that the applications are deployed from" - type = string -} - -variable "anti_affinity" { - description = "Enable anti-affinity constraints." - type = bool - default = true -} - -# -------------- # S3 object storage -------------- - -variable "s3_integrator_channel" { - description = "Channel that the s3-integrator application is deployed from" - type = string - default = "2/edge" -} - -variable "s3_bucket" { - description = "Bucket name" - type = string - default = "loki" -} - -variable "s3_access_key" { - description = "S3 access-key credential" - type = string -} - -variable "s3_secret_key" { - description = "S3 secret-key credential" - type = string - sensitive = true -} - -variable "s3_endpoint" { - description = "S3 endpoint" - type = string -} - -# -------------- # App Names -------------- - -variable "backend_name" { - description = "Name of the Loki app with the backend role" - type = string - default = "loki-backend" -} - -variable "read_name" { - description = "Name of the Loki app with the read role" - type = string - default = "loki-read" -} - -variable "write_name" { - description = "Name of the Loki app with the write role" - type = string - default = "loki-write" -} - -variable "s3_integrator_name" { - description = "Name of the s3-integrator app" - type = string - default = "loki-s3-integrator" -} - -# -------------- # Configs -------------- - -variable "coordinator_config" { - description = "Map of the coordinator configuration options" - type = map(string) - default = {} -} - -variable "backend_config" { - description = "Map of the backend worker configuration options" - type = map(string) - default = {} -} - -variable "read_config" { - description = "Map of the read worker configuration options" - type = map(string) - default = {} -} - -variable "write_config" { - description = "Map of the write worker configuration options" - type = map(string) - default = {} -} - -variable "s3_integrator_config" { - description = "Map of the s3-integrator configuration options" - type = map(string) - default = {} -} - -# -------------- # Constraints -------------- - -# We use constraints to set AntiAffinity in K8s -# https://discourse.charmhub.io/t/pod-priority-and-affinity-in-juju-charms/4091/13?u=jose - -# FIXME: Passing an empty constraints value to the Juju Terraform provider currently -# causes the operation to fail due to https://github.com/juju/terraform-provider-juju/issues/344 -# Therefore, we set a default value of "arch=amd64" for all applications. - -variable "coordinator_constraints" { - description = "String listing constraints for the coordinator application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.coordinator_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -variable "worker_constraints" { - description = "String listing constraints for the worker application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.worker_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -variable "s3_integrator_constraints" { - description = "String listing constraints for the s3-integrator application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.s3_integrator_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -# -------------- # Revisions -------------- - -variable "coordinator_revision" { - description = "Revision number of the coordinator application" - type = number - default = null -} - -variable "worker_revision" { - description = "Revision number of the worker application" - type = number - default = null -} - -variable "s3_integrator_revision" { - description = "Revision number of the s3-integrator application" - type = number - default = null -} - -# -------------- # Storage directives -------------- - -variable "coordinator_storage_directives" { - description = "Map of storage used by the coordinator application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -variable "worker_storage_directives" { - description = "Map of storage used by the worker application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -variable "s3_integrator_storage_directives" { - description = "Map of storage used by the s3-integrator application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -# -------------- # Units Per App -------------- - -variable "backend_units" { - description = "Number of Loki worker units with the backend role" - type = number - default = 1 - validation { - condition = var.backend_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "read_units" { - description = "Number of Loki worker units with the read role" - type = number - default = 1 - validation { - condition = var.read_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "write_units" { - description = "Number of Loki worker units with the write role" - type = number - default = 1 - validation { - condition = var.write_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "coordinator_units" { - description = "Number of Loki coordinator units" - type = number - default = 1 - validation { - condition = var.coordinator_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "s3_integrator_units" { - description = "Number of S3 integrator units" - type = number - default = 1 - validation { - condition = var.s3_integrator_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} diff --git a/terraform/loki/versions.tf b/terraform/loki/versions.tf deleted file mode 100644 index f65a3495..00000000 --- a/terraform/loki/versions.tf +++ /dev/null @@ -1,9 +0,0 @@ -terraform { - required_version = ">= 1.5" - required_providers { - juju = { - source = "juju/juju" - version = "~> 1.0" - } - } -} \ No newline at end of file diff --git a/terraform/mimir/README.md b/terraform/mimir/README.md deleted file mode 100644 index 3de85a93..00000000 --- a/terraform/mimir/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Terraform module for Mimir solution - -This is a Terraform module facilitating the deployment of Mimir solution, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). This Terraform module deploys Mimir in its [microservices mode](https://grafana.com/docs/mimir/latest/references/architecture/deployment-modes/#microservices-mode), which runs each one of the required roles in distinct processes. - -> [!NOTE] -> `s3-integrator` itself doesn't act as an S3 object storage system. For the HA solution to be functional, `s3-integrator` needs to point to an S3-like storage. See [this guide](https://discourse.charmhub.io/t/cos-lite-docs-set-up-minio/15211) to learn how to connect to an S3-like storage for traces. - - -## Providers - -| Name | Version | -|------|---------| -| [juju](#provider\_juju) | ~> 1.0 | - -## Modules - -| Name | Source | Version | -|------|--------|---------| -| [mimir\_backend](#module\_mimir\_backend) | git::https://github.com/canonical/mimir-worker-k8s-operator//terraform | track/2 | -| [mimir\_coordinator](#module\_mimir\_coordinator) | git::https://github.com/canonical/mimir-coordinator-k8s-operator//terraform | track/2 | -| [mimir\_read](#module\_mimir\_read) | git::https://github.com/canonical/mimir-worker-k8s-operator//terraform | track/2 | -| [mimir\_write](#module\_mimir\_write) | git::https://github.com/canonical/mimir-worker-k8s-operator//terraform | track/2 | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [anti\_affinity](#input\_anti\_affinity) | Enable anti-affinity constraints. | `bool` | `true` | no | -| [backend\_config](#input\_backend\_config) | Map of the backend worker configuration options | `map(string)` | `{}` | no | -| [backend\_name](#input\_backend\_name) | Name of the Mimir backend (meta role) app | `string` | `"mimir-backend"` | no | -| [backend\_units](#input\_backend\_units) | Number of Mimir worker units with the backend meta role | `number` | `1` | no | -| [channel](#input\_channel) | Channel that the applications are deployed from | `string` | n/a | yes | -| [coordinator\_config](#input\_coordinator\_config) | Map of the coordinator configuration options | `map(string)` | `{}` | no | -| [coordinator\_constraints](#input\_coordinator\_constraints) | String listing constraints for the coordinator application | `string` | `"arch=amd64"` | no | -| [coordinator\_revision](#input\_coordinator\_revision) | Revision number of the coordinator application | `number` | `null` | no | -| [coordinator\_storage\_directives](#input\_coordinator\_storage\_directives) | Map of storage used by the coordinator application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [coordinator\_units](#input\_coordinator\_units) | Number of Mimir coordinator units | `number` | `1` | no | -| [model\_uuid](#input\_model\_uuid) | Reference to an existing model resource or data source for the model to deploy to | `string` | n/a | yes | -| [read\_config](#input\_read\_config) | Map of the read worker configuration options | `map(string)` | `{}` | no | -| [read\_name](#input\_read\_name) | Name of the Mimir read (meta role) app | `string` | `"mimir-read"` | no | -| [read\_units](#input\_read\_units) | Number of Mimir worker units with the read meta role | `number` | `1` | no | -| [s3\_access\_key](#input\_s3\_access\_key) | S3 access-key credential | `string` | n/a | yes | -| [s3\_bucket](#input\_s3\_bucket) | Bucket name | `string` | `"mimir"` | no | -| [s3\_endpoint](#input\_s3\_endpoint) | S3 endpoint | `string` | n/a | yes | -| [s3\_integrator\_channel](#input\_s3\_integrator\_channel) | Channel that the s3-integrator application is deployed from | `string` | `"2/edge"` | no | -| [s3\_integrator\_config](#input\_s3\_integrator\_config) | Map of the s3-integrator configuration options | `map(string)` | `{}` | no | -| [s3\_integrator\_constraints](#input\_s3\_integrator\_constraints) | String listing constraints for the s3-integrator application | `string` | `"arch=amd64"` | no | -| [s3\_integrator\_name](#input\_s3\_integrator\_name) | Name of the s3-integrator app | `string` | `"mimir-s3-integrator"` | no | -| [s3\_integrator\_revision](#input\_s3\_integrator\_revision) | Revision number of the s3-integrator application | `number` | `null` | no | -| [s3\_integrator\_storage\_directives](#input\_s3\_integrator\_storage\_directives) | Map of storage used by the s3-integrator application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [s3\_integrator\_units](#input\_s3\_integrator\_units) | Number of S3 integrator units | `number` | `1` | no | -| [s3\_secret\_key](#input\_s3\_secret\_key) | S3 secret-key credential | `string` | n/a | yes | -| [worker\_constraints](#input\_worker\_constraints) | String listing constraints for the worker application | `string` | `"arch=amd64"` | no | -| [worker\_revision](#input\_worker\_revision) | Revision number of the worker application | `number` | `null` | no | -| [worker\_storage\_directives](#input\_worker\_storage\_directives) | Map of storage used by the worker application, which defaults to 1 GB, allocated by Juju | `map(string)` | `{}` | no | -| [write\_config](#input\_write\_config) | Map of the write worker configuration options | `map(string)` | `{}` | no | -| [write\_name](#input\_write\_name) | Name of the Mimir write (meta role) app | `string` | `"mimir-write"` | no | -| [write\_units](#input\_write\_units) | Number of Mimir worker units with the write meta role | `number` | `1` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [app\_names](#output\_app\_names) | All application names which make up this product module | -| [endpoints](#output\_endpoints) | All Juju integration endpoints which make up this product module | - - -## Usage - -### Microservice deployment - -By default, this Terraform module will deploy each Mimir worker with `1` unit. To configure the module to run `x` units of any worker role, you can run `terraform apply -var="_units="`. -See [Mimir worker roles](https://discourse.charmhub.io/t/mimir-worker-roles/15484) for the recommended scale for each role. diff --git a/terraform/mimir/main.tf b/terraform/mimir/main.tf deleted file mode 100644 index a05ee199..00000000 --- a/terraform/mimir/main.tf +++ /dev/null @@ -1,155 +0,0 @@ -resource "juju_secret" "mimir_s3_credentials_secret" { - model_uuid = var.model_uuid - name = "mimir_s3_credentials" - value = { - access-key = var.s3_access_key - secret-key = var.s3_secret_key - } - info = "Credentials for the S3 endpoint" -} - -resource "juju_access_secret" "mimir_s3_secret_access" { - model_uuid = var.model_uuid - applications = [ - juju_application.s3_integrator.name - ] - secret_id = juju_secret.mimir_s3_credentials_secret.secret_id -} - -# TODO: Replace s3_integrator resource to use its remote terraform module once available -resource "juju_application" "s3_integrator" { - config = merge({ - endpoint = var.s3_endpoint - bucket = var.s3_bucket - credentials = "secret:${juju_secret.mimir_s3_credentials_secret.secret_id}" - }, var.s3_integrator_config) - constraints = var.s3_integrator_constraints - model_uuid = var.model_uuid - name = var.s3_integrator_name - storage_directives = var.s3_integrator_storage_directives - trust = true - units = var.s3_integrator_units - - charm { - name = "s3-integrator" - channel = var.s3_integrator_channel - revision = var.s3_integrator_revision - } -} - -module "mimir_coordinator" { - source = "git::https://github.com/canonical/mimir-coordinator-k8s-operator//terraform?ref=track/2" - app_name = "mimir" - channel = var.channel - config = var.coordinator_config - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=mimir,anti-pod.topology-key=kubernetes.io/hostname" : var.coordinator_constraints - model_uuid = var.model_uuid - revision = var.coordinator_revision - storage_directives = var.coordinator_storage_directives - units = var.coordinator_units -} - -module "mimir_backend" { - source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.mimir_coordinator] - - app_name = var.backend_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-backend = true - }, var.backend_config) - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.backend_units -} - -module "mimir_read" { - source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.mimir_coordinator] - - app_name = var.read_name - channel = var.channel - config = merge({ - role-read = true - }, var.read_config) - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.read_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.read_units -} - -module "mimir_write" { - source = "git::https://github.com/canonical/mimir-worker-k8s-operator//terraform?ref=track/2" - depends_on = [module.mimir_coordinator] - - app_name = var.write_name - channel = var.channel - config = merge({ - role-write = true - }, var.write_config) - constraints = var.anti_affinity ? "arch=amd64 tags=anti-pod.app.kubernetes.io/name=${var.write_name},anti-pod.topology-key=kubernetes.io/hostname" : var.worker_constraints - model_uuid = var.model_uuid - revision = var.worker_revision - storage_directives = var.worker_storage_directives - units = var.write_units -} - -# -------------- # Integrations -------------- - -resource "juju_integration" "coordinator_to_s3_integrator" { - model_uuid = var.model_uuid - application { - name = juju_application.s3_integrator.name - endpoint = "s3-credentials" - } - - application { - name = module.mimir_coordinator.app_name - endpoint = "s3" - } -} - -resource "juju_integration" "coordinator_to_read" { - model_uuid = var.model_uuid - - application { - name = module.mimir_coordinator.app_name - endpoint = "mimir-cluster" - } - - application { - name = module.mimir_read.app_name - endpoint = "mimir-cluster" - } -} - -resource "juju_integration" "coordinator_to_write" { - model_uuid = var.model_uuid - - application { - name = module.mimir_coordinator.app_name - endpoint = "mimir-cluster" - } - - application { - name = module.mimir_write.app_name - endpoint = "mimir-cluster" - } -} - -resource "juju_integration" "coordinator_to_backend" { - model_uuid = var.model_uuid - - application { - name = module.mimir_coordinator.app_name - endpoint = "mimir-cluster" - } - - application { - name = module.mimir_backend.app_name - endpoint = "mimir-cluster" - } -} diff --git a/terraform/mimir/outputs.tf b/terraform/mimir/outputs.tf deleted file mode 100644 index 512861e7..00000000 --- a/terraform/mimir/outputs.tf +++ /dev/null @@ -1,34 +0,0 @@ -output "app_names" { - value = merge( - { - mimir_s3_integrator = juju_application.s3_integrator.name, - mimir_coordinator = module.mimir_coordinator.app_name, - mimir_read = module.mimir_read.app_name, - mimir_write = module.mimir_write.app_name, - mimir_backend = module.mimir_backend.app_name, - } - ) - description = "All application names which make up this product module" -} - -output "endpoints" { - value = { - # Requires - alertmanager = "alertmanager", - certificates = "certificates", - ingress = "ingress", - logging_consumer = "logging-consumer", - s3 = "s3", - charm_tracing = "charm-tracing", - catalogue = "catalogue", - - # Provides - grafana_dashboards_provider = "grafana-dashboards-provider", - grafana_source = "grafana-source", - mimir_cluster = "mimir-cluster", - receive_remote_write = "receive-remote-write", - self_metrics_endpoint = "self-metrics-endpoint", - send_datasource = "send-datasource", - } - description = "All Juju integration endpoints which make up this product module" -} diff --git a/terraform/mimir/variables.tf b/terraform/mimir/variables.tf deleted file mode 100644 index fa908ce8..00000000 --- a/terraform/mimir/variables.tf +++ /dev/null @@ -1,237 +0,0 @@ -variable "model_uuid" { - description = "Reference to an existing model resource or data source for the model to deploy to" - type = string -} - -variable "channel" { - description = "Channel that the applications are deployed from" - type = string -} - -variable "anti_affinity" { - description = "Enable anti-affinity constraints." - type = bool - default = true -} - -# -------------- # S3 object storage -------------- - -variable "s3_integrator_channel" { - description = "Channel that the s3-integrator application is deployed from" - type = string - default = "2/edge" -} - -variable "s3_bucket" { - description = "Bucket name" - type = string - default = "mimir" -} - -variable "s3_access_key" { - description = "S3 access-key credential" - type = string -} - -variable "s3_secret_key" { - description = "S3 secret-key credential" - type = string - sensitive = true -} - -variable "s3_endpoint" { - description = "S3 endpoint" - type = string -} - -# -------------- # App Names -------------- - -variable "read_name" { - description = "Name of the Mimir read (meta role) app" - type = string - default = "mimir-read" -} - -variable "write_name" { - description = "Name of the Mimir write (meta role) app" - type = string - default = "mimir-write" -} - -variable "backend_name" { - description = "Name of the Mimir backend (meta role) app" - type = string - default = "mimir-backend" -} - -variable "s3_integrator_name" { - description = "Name of the s3-integrator app" - type = string - default = "mimir-s3-integrator" -} - -# -------------- # Configs -------------- - -variable "coordinator_config" { - description = "Map of the coordinator configuration options" - type = map(string) - default = {} -} - -variable "backend_config" { - description = "Map of the backend worker configuration options" - type = map(string) - default = {} -} - -variable "read_config" { - description = "Map of the read worker configuration options" - type = map(string) - default = {} -} - -variable "write_config" { - description = "Map of the write worker configuration options" - type = map(string) - default = {} -} - -variable "s3_integrator_config" { - description = "Map of the s3-integrator configuration options" - type = map(string) - default = {} -} - -# -------------- # Constraints -------------- - -# We use constraints to set AntiAffinity in K8s -# https://discourse.charmhub.io/t/pod-priority-and-affinity-in-juju-charms/4091/13?u=jose - -# FIXME: Passing an empty constraints value to the Juju Terraform provider currently -# causes the operation to fail due to https://github.com/juju/terraform-provider-juju/issues/344 -# Therefore, we set a default value of "arch=amd64" for all applications. - -variable "coordinator_constraints" { - description = "String listing constraints for the coordinator application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.coordinator_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -variable "worker_constraints" { - description = "String listing constraints for the worker application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.worker_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -variable "s3_integrator_constraints" { - description = "String listing constraints for the s3-integrator application" - type = string - default = "arch=amd64" - - validation { - condition = !(var.anti_affinity && var.s3_integrator_constraints != "arch=amd64") - error_message = "Setting both custom charm constraints and anti-affinity to true is not allowed." - } -} - -# -------------- # Revisions -------------- - -variable "coordinator_revision" { - description = "Revision number of the coordinator application" - type = number - default = null -} - -variable "worker_revision" { - description = "Revision number of the worker application" - type = number - default = null -} - -variable "s3_integrator_revision" { - description = "Revision number of the s3-integrator application" - type = number - default = null -} - -# -------------- # Storage directives -------------- - -variable "coordinator_storage_directives" { - description = "Map of storage used by the coordinator application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -variable "worker_storage_directives" { - description = "Map of storage used by the worker application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -variable "s3_integrator_storage_directives" { - description = "Map of storage used by the s3-integrator application, which defaults to 1 GB, allocated by Juju" - type = map(string) - default = {} -} - -# -------------- # Units Per App -------------- - -variable "read_units" { - description = "Number of Mimir worker units with the read meta role" - type = number - default = 1 - validation { - condition = var.read_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "write_units" { - description = "Number of Mimir worker units with the write meta role" - type = number - default = 1 - validation { - condition = var.write_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "backend_units" { - description = "Number of Mimir worker units with the backend meta role" - type = number - default = 1 - validation { - condition = var.backend_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "coordinator_units" { - description = "Number of Mimir coordinator units" - type = number - default = 1 - validation { - condition = var.coordinator_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} - -variable "s3_integrator_units" { - description = "Number of S3 integrator units" - type = number - default = 1 - validation { - condition = var.s3_integrator_units >= 1 - error_message = "The number of units must be greater than or equal to 1." - } -} diff --git a/terraform/mimir/versions.tf b/terraform/mimir/versions.tf deleted file mode 100644 index f65a3495..00000000 --- a/terraform/mimir/versions.tf +++ /dev/null @@ -1,9 +0,0 @@ -terraform { - required_version = ">= 1.5" - required_providers { - juju = { - source = "juju/juju" - version = "~> 1.0" - } - } -} \ No newline at end of file