From 627d7fd00af7a5e872410a0f98a6487728fc380d Mon Sep 17 00:00:00 2001 From: Myles Penner Date: Tue, 7 Jan 2025 08:33:24 -0800 Subject: [PATCH] Integrate k8s to observability stack The principal applications are now stored as a list allowing grafana-agent to be a subordinate to multiple principles in the same model. --- .../observability/etc/deploy-grafana-agent/main.tf | 9 +++++---- .../observability/etc/deploy-grafana-agent/variables.tf | 6 ++++-- sunbeam-python/sunbeam/features/observability/feature.py | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/main.tf b/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/main.tf index 49addf41..85b5074a 100644 --- a/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/main.tf +++ b/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/main.tf @@ -41,8 +41,9 @@ resource "juju_application" "grafana-agent" { } # juju integrate :cos-agent grafana-agent:cos-agent -resource "juju_integration" "principal-application-to-grafana-agent" { - model = var.principal-application-model +resource "juju_integration" "grafana_agent_integrations" { + for_each = toset(var.grafana-agent-integration-apps) + model = var.principal-application-model application { name = juju_application.grafana-agent.name @@ -50,7 +51,7 @@ resource "juju_integration" "principal-application-to-grafana-agent" { } application { - name = var.principal-application + name = each.value endpoint = "cos-agent" } } @@ -71,7 +72,7 @@ resource "juju_integration" "grafana-agent-to-cos-prometheus" { # juju integrate grafana-agent cos.loki-logging resource "juju_integration" "grafana-agent-to-cos-loki" { - count = var.logging-offer-url != null ? 1 : 0 + count = var.logging-offer-url != null ? 1 : 0 model = var.principal-application-model application { diff --git a/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/variables.tf b/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/variables.tf index 70e8dc78..df6eb07a 100644 --- a/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/variables.tf +++ b/sunbeam-python/sunbeam/features/observability/etc/deploy-grafana-agent/variables.tf @@ -15,8 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -variable "principal-application" { - description = "Name of the deployed principal application that integrates with grafana-agent" +variable "grafana-agent-integration-apps" { + description = "List of the deployed principal applications that integrate with grafana-agent" + type = list(string) + default = [] } variable "principal-application-model" { diff --git a/sunbeam-python/sunbeam/features/observability/feature.py b/sunbeam-python/sunbeam/features/observability/feature.py index 2290c2b4..dcfddc2e 100644 --- a/sunbeam-python/sunbeam/features/observability/feature.py +++ b/sunbeam-python/sunbeam/features/observability/feature.py @@ -262,9 +262,10 @@ def __init__( def run(self, status: Status | None = None) -> Result: """Execute configuration using terraform.""" + integration_apps = ["k8s", "openstack-hypervisor"] extra_tfvars = { "principal-application-model": self.model, - "principal-application": "openstack-hypervisor", + "grafana-agent-integration-apps": integration_apps, } # Offer URLs from COS are added from feature extra_tfvars.update(