From a9efc5cd455ec36cb0ddedb83cabd1a436baf2fd Mon Sep 17 00:00:00 2001 From: "Jason C. Nucciarone" Date: Fri, 22 Nov 2024 13:48:25 -0500 Subject: [PATCH] feat: add module to deploy and integrate grafana agent with slurmctld Changes: * Replace `juju_applicaton` entry for `mysql` with the tf module from the upstream `mysql-operator` GitHub repository. Signed-off-by: Jason C. Nucciarone --- main.tf | 64 ++++++++++++++++++++++++++++++++++++---------------- variables.tf | 12 +++++----- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/main.tf b/main.tf index 372ed21..9f06888 100644 --- a/main.tf +++ b/main.tf @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Deploy a minimal Charmed HPC cloud on LXD +## Deploy a Charmed HPC cluster. provider "juju" {} @@ -20,6 +20,7 @@ resource "juju_model" "charmed-hpc" { name = var.model } +## Slurm - workload manager for Charmed HPC. module "controller" { source = "git::https://github.com/charmed-hpc/slurm-charms//charms/slurmctld/terraform" @@ -56,21 +57,19 @@ module "rest-api" { units = var.rest-api-scale } -# FIXME: Source from upstream mysql operator once tf module is published. -resource "juju_application" "mysql" { - name = "mysql" - model = juju_model.charmed-hpc.name - - charm { - name = "mysql" - channel = var.mysql-channel - revision = var.mysql-revision - } +## MySQL - provides backing database for `slurmdbd`. +module "mysql" { + source = "git::https://github.com/canonical/mysql-operator//terraform" - units = var.mysql-scale + juju_model_name = juju_model.charmed-hpc.name + app_name = "mysql" + channel = var.mysql-channel + units = var.mysql-scale } -# FIXME: Source from upstream mysql-router operator once tf module is published. +# TODO: +# Pull a Terraform module for mysql-router-operator once +# it has been published to the upstream repository. resource "juju_application" "database-mysql-router" { name = "database-mysql-router" model = juju_model.charmed-hpc.name @@ -80,9 +79,20 @@ resource "juju_application" "database-mysql-router" { channel = var.mysql-router-channel revision = var.mysql-router-revision } - units = 0 + units = 0 # Units should always be zero since mysql-router is a subordinate operator. } +## Grafana Agent - forwards collected cluster metrics to COS. +module "grafana-agent" { + source = "git::https://github.com/canonical/grafana-agent-operator//terraform" + + model_name = juju_model.charmed-hpc.name + app_name = "grafana-agent" + channel = var.grafana-agent-channel + units = 0 # Units should always be zero since grafana-agent is a subordinate operator. +} + +## Integrate `slurmctld`, `slurmd`, `slurmdbd`, and `slurmrestd` together. resource "juju_integration" "compute-to-controller" { model = juju_model.charmed-hpc.name @@ -125,30 +135,44 @@ resource "juju_integration" "rest-api-to-controller" { } } +## Integrate `slurmd` with `mysql`. resource "juju_integration" "database-to-mysql-router" { model = juju_model.charmed-hpc.name application { - name = module.database.app_name - endpoint = module.database.requires.database + name = juju_application.database-mysql-router.name + endpoint = "database" } application { - name = juju_application.database-mysql-router.name - endpoint = "database" + name = module.database.app_name + endpoint = module.database.requires.database } } resource "juju_integration" "mysql-router-to-mysql" { model = juju_model.charmed-hpc.name + application { + name = module.mysql.application_name + endpoint = module.mysql.provides.database + } + application { name = juju_application.database-mysql-router.name endpoint = "backend-database" } +} + +## Integrate `slurmctld` with `grafana-agent`. +resource "juju_integration" "controller-to-grafana-agent" { + model = juju_model.charmed-hpc.name application { - name = juju_application.mysql.name - endpoint = "database" + name = module.controller.app_name + } + + application { + name = module.grafana-agent.app_name } } diff --git a/variables.tf b/variables.tf index f4510ee..cb47ab4 100644 --- a/variables.tf +++ b/variables.tf @@ -54,18 +54,18 @@ variable "database-scale" { default = 1 } +variable "grafana-agent-channel" { + description = "Channel to deploy grafana-agent-operator from." + type = string + default = "latest/stable" +} + variable "mysql-channel" { description = "Channel to deploy mysql from." type = string default = "8.0/stable" } -variable "mysql-revision" { - description = "Revision of mysql to deploy from channel." - type = number - default = null -} - variable "mysql-scale" { description = "Scale of mysql application" type = number