diff --git a/modules/external/cos-lite/main.tf b/modules/external/cos-lite/main.tf index 1e54dbc..2ec590e 100644 --- a/modules/external/cos-lite/main.tf +++ b/modules/external/cos-lite/main.tf @@ -390,3 +390,17 @@ resource "juju_integration" "traefik-metrics" { endpoint = module.prometheus.metrics_endpoint } } + +# Cross-model integrations + +resource "juju_offer" "prometheus-remote-write" { + model = var.model_name + application_name = module.prometheus.app_name + endpoint = module.prometheus.receive_remote_write_endpoint +} + +resource "juju_offer" "loki-logging" { + model = var.model_name + application_name = module.loki.app_name + endpoint = module.loki.logging_endpoint +} diff --git a/modules/external/cos-lite/output.tf b/modules/external/cos-lite/output.tf index c8cfd0e..058841c 100644 --- a/modules/external/cos-lite/output.tf +++ b/modules/external/cos-lite/output.tf @@ -35,3 +35,15 @@ output "traefik_app_name" { description = "Name of the Traefik application in the Juju model." value = module.traefik.app_name } + +# Cross-model integrations + +output "prometheus_remote_write_offer_url" { + description = "The URL used to created cross-model relation to Prometheus's `remote-write` interface." + value = juju_offer.prometheus-remote-write.url +} + +output "loki_logging_offer_url" { + description = "The URL used to created cross-model relation to Loki's `logging` interface." + value = juju_offer.loki-logging.url +} diff --git a/modules/sdcore-control-plane-k8s/main.tf b/modules/sdcore-control-plane-k8s/main.tf index 72a469f..47938b5 100644 --- a/modules/sdcore-control-plane-k8s/main.tf +++ b/modules/sdcore-control-plane-k8s/main.tf @@ -786,21 +786,14 @@ resource "juju_integration" "nms-logging" { # Cross-model integrations -resource "juju_offer" "prometheus-remote-write" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].prometheus_app_name - endpoint = "receive-remote-write" -} -resource "juju_offer" "loki-logging" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].loki_app_name - endpoint = "logging" +resource "juju_offer" "amf-fiveg-n2" { + model = var.model_name + application_name = module.amf.app_name + endpoint = module.amf.fiveg_n2_endpoint } resource "juju_integration" "prometheus" { - count = var.deploy_cos ? 1 : 0 + count = var.deploy_cos || var.use_existing_cos ? 1 : 0 model = var.model_name application { @@ -809,12 +802,12 @@ resource "juju_integration" "prometheus" { } application { - offer_url = juju_offer.prometheus-remote-write[0].url + offer_url = length(module.cos-lite) != 0 ? module.cos-lite[0].prometheus_remote_write_offer_url : var.prometheus_remote_write_offer_url } } resource "juju_integration" "loki" { - count = var.deploy_cos ? 1 : 0 + count = var.deploy_cos || var.use_existing_cos ? 1 : 0 model = var.model_name application { @@ -823,6 +816,6 @@ resource "juju_integration" "loki" { } application { - offer_url = juju_offer.loki-logging[0].url + offer_url = length(module.cos-lite) != 0 ? module.cos-lite[0].loki_logging_offer_url : var.loki_logging_offer_url } } diff --git a/modules/sdcore-control-plane-k8s/outputs.tf b/modules/sdcore-control-plane-k8s/outputs.tf index 5798f14..b4280c1 100644 --- a/modules/sdcore-control-plane-k8s/outputs.tf +++ b/modules/sdcore-control-plane-k8s/outputs.tf @@ -1,14 +1,11 @@ # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. -output "amf_app_name" { - description = "Name of the deployed AMF application." - value = module.amf.app_name -} +# Cross-model integrations -output "fiveg_n2_endpoint" { - description = "Name of the endpoint used to provide information on connectivity to the N2 plane." - value = module.amf.fiveg_n2_endpoint +output "amf_fiveg_n2_offer_url" { + description = "" + value = juju_offer.amf-fiveg-n2.url } output "nms_app_name" { diff --git a/modules/sdcore-control-plane-k8s/terraform.tf b/modules/sdcore-control-plane-k8s/terraform.tf index 3bcd8a9..8aebcbd 100644 --- a/modules/sdcore-control-plane-k8s/terraform.tf +++ b/modules/sdcore-control-plane-k8s/terraform.tf @@ -5,7 +5,7 @@ terraform { required_providers { juju = { source = "juju/juju" - version = ">= 0.11.0" + version = ">= 0.12.0" } } } diff --git a/modules/sdcore-control-plane-k8s/variables.tf b/modules/sdcore-control-plane-k8s/variables.tf index fe34294..8fe7f99 100644 --- a/modules/sdcore-control-plane-k8s/variables.tf +++ b/modules/sdcore-control-plane-k8s/variables.tf @@ -88,11 +88,39 @@ variable "deploy_cos" { type = bool default = false } +variable "use_existing_cos" { + description = "" + type = bool + default = false +} + variable "cos_model_name" { - description = "Name of Juju model to deploy COS to." + description = "Name of COS Juju model. This model will be created if `deploy_cos` is set to true or used as a source when integrating with existing COS deployment." type = string default = "cos-lite" } + +variable "prometheus_remote_write_offer_url" { + description = "URL of Prometheus's `remote_write` offer. This variable is used to integrate with an existing COS deployment." + type = string + default = "" + + validation { + condition = var.use_existing_cos && length(var.prometheus_remote_write_offer_url) != 0 + error_message = "Variable `prometheus_remote_write_offer_url` is required." + } +} +variable "loki_logging_offer_url" { + description = "URL of Loki's `logging` offer. This variable is used to integrate with an existing COS deployment." + type = string + default = "" + + validation { + condition = var.use_existing_cos && length(var.loki_logging_offer_url) != 0 + error_message = "Variable `loki_logging_offer_url` is required." + } +} + variable "cos_configuration_config" { description = "COS Configuration application config. Details about available options can be found at https://charmhub.io/cos-configuration-k8s/configure." type = map(string) diff --git a/modules/sdcore-k8s/main.tf b/modules/sdcore-k8s/main.tf index f10df5d..9392f54 100644 --- a/modules/sdcore-k8s/main.tf +++ b/modules/sdcore-k8s/main.tf @@ -837,21 +837,14 @@ resource "juju_integration" "upf-nms" { # Cross-model integrations -resource "juju_offer" "prometheus-remote-write" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].prometheus_app_name - endpoint = "receive-remote-write" -} -resource "juju_offer" "loki-logging" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].loki_app_name - endpoint = "logging" +resource "juju_offer" "amf-fiveg-n2" { + model = var.model_name + application_name = module.amf.app_name + endpoint = module.amf.fiveg_n2_endpoint } resource "juju_integration" "prometheus" { - count = var.deploy_cos ? 1 : 0 + count = var.deploy_cos || var.use_existing_cos ? 1 : 0 model = var.model_name application { @@ -860,12 +853,12 @@ resource "juju_integration" "prometheus" { } application { - offer_url = juju_offer.prometheus-remote-write[0].url + offer_url = length(module.cos-lite) != 0 ? module.cos-lite[0].prometheus_remote_write_offer_url : var.prometheus_remote_write_offer_url } } resource "juju_integration" "loki" { - count = var.deploy_cos ? 1 : 0 + count = var.deploy_cos || var.use_existing_cos ? 1 : 0 model = var.model_name application { @@ -874,6 +867,6 @@ resource "juju_integration" "loki" { } application { - offer_url = juju_offer.loki-logging[0].url + offer_url = length(module.cos-lite) != 0 ? module.cos-lite[0].loki_logging_offer_url : var.loki_logging_offer_url } } diff --git a/modules/sdcore-k8s/outputs.tf b/modules/sdcore-k8s/outputs.tf index aabcd16..b32c4c3 100644 --- a/modules/sdcore-k8s/outputs.tf +++ b/modules/sdcore-k8s/outputs.tf @@ -1,14 +1,9 @@ # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. -output "amf_app_name" { - description = "Name of the deployed AMF application." - value = module.amf.app_name -} - -output "fiveg_n2_endpoint" { - description = "Name of the endpoint used to provide information on connectivity to the N2 plane." - value = module.amf.fiveg_n2_endpoint +output "amf_fiveg_n2_offer_url" { + description = "" + value = juju_offer.amf-fiveg-n2.url } output "nms_app_name" { @@ -21,21 +16,6 @@ output "fiveg_gnb_identity_endpoint" { value = module.nms.fiveg_gnb_identity_endpoint } -output "grafana_agent_app_name" { - description = "Name of the deployed Grafana-agent application." - value = module.grafana-agent.app_name -} - -output "send_remote_write_endpoint" { - description = "Name of the endpoint to forward client charms metrics and associated alert rules to Prometheus using prometheus_remote_write interface." - value = module.grafana-agent.send_remote_write_endpoint -} - -output "logging_consumer_endpoint" { - description = "Name of the endpoint to send the logs to Loki using loki_push_api interface." - value = module.grafana-agent.logging_consumer_endpoint -} - output "upf_app_name" { description = "Name of the deployed UPF application." value = module.upf.app_name @@ -45,8 +25,3 @@ output "fiveg_n3_endpoint" { description = "Name of the endpoint used to provide information on connectivity to the N3 plane." value = module.upf.fiveg_n3_endpoint } - -output "fiveg_n4_endpoint" { - description = "Name of the endpoint used to provide information on connectivity to the N4 plane." - value = module.upf.fiveg_n4_endpoint -} diff --git a/modules/sdcore-k8s/terraform.tf b/modules/sdcore-k8s/terraform.tf index 3bcd8a9..8aebcbd 100644 --- a/modules/sdcore-k8s/terraform.tf +++ b/modules/sdcore-k8s/terraform.tf @@ -5,7 +5,7 @@ terraform { required_providers { juju = { source = "juju/juju" - version = ">= 0.11.0" + version = ">= 0.12.0" } } } diff --git a/modules/sdcore-k8s/variables.tf b/modules/sdcore-k8s/variables.tf index 168db50..f868677 100644 --- a/modules/sdcore-k8s/variables.tf +++ b/modules/sdcore-k8s/variables.tf @@ -98,11 +98,39 @@ variable "deploy_cos" { type = bool default = false } +variable "use_existing_cos" { + description = "Allows integrating with an existing COS deployment. When set to `true`, `cos_model_name`, `prometheus_remote_write_offer_url` and `loki_logging_offer_url` are required." + type = bool + default = false +} + variable "cos_model_name" { - description = "Name of Juju model to deploy COS to." + description = "Name of COS Juju model. This model will be created if `deploy_cos` is set to true or used as a source when integrating with existing COS deployment." type = string default = "cos-lite" } + +variable "prometheus_remote_write_offer_url" { + description = "URL of Prometheus's `remote_write` offer. This variable is used to integrate with an existing COS deployment." + type = string + default = "" + + validation { + condition = var.use_existing_cos && length(var.prometheus_remote_write_offer_url) != 0 + error_message = "Variable `prometheus_remote_write_offer_url` is required." + } +} +variable "loki_logging_offer_url" { + description = "URL of Loki's `logging` offer. This variable is used to integrate with an existing COS deployment." + type = string + default = "" + + validation { + condition = var.use_existing_cos && length(var.loki_logging_offer_url) != 0 + error_message = "Variable `loki_logging_offer_url` is required." + } +} + variable "cos_configuration_config" { description = "COS Configuration application config. Details about available options can be found at https://charmhub.io/cos-configuration-k8s/configure." type = map(string) diff --git a/modules/sdcore-user-plane-k8s/main.tf b/modules/sdcore-user-plane-k8s/main.tf index ade8a26..4a7100f 100644 --- a/modules/sdcore-user-plane-k8s/main.tf +++ b/modules/sdcore-user-plane-k8s/main.tf @@ -62,19 +62,6 @@ resource "juju_integration" "upf-logging" { # Cross-model integrations -resource "juju_offer" "prometheus-remote-write" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].prometheus_app_name - endpoint = "receive-remote-write" -} -resource "juju_offer" "loki-logging" { - count = var.deploy_cos ? 1 : 0 - model = module.cos-lite[0].model_name - application_name = module.cos-lite[0].loki_app_name - endpoint = "logging" -} - resource "juju_integration" "prometheus" { count = var.deploy_cos ? 1 : 0 model = var.model_name @@ -85,7 +72,7 @@ resource "juju_integration" "prometheus" { } application { - offer_url = juju_offer.prometheus-remote-write[0].url + offer_url = module.cos-lite[0].prometheus_remote_write_offer_url } } @@ -99,6 +86,6 @@ resource "juju_integration" "loki" { } application { - offer_url = juju_offer.loki-logging[0].url + offer_url = module.cos-lite[0].loki_logging_offer_url } }