Skip to content

Commit

Permalink
Refactor sdcore-user-plane-k8s to follow spec CC006.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainbourgeois committed Oct 4, 2024
1 parent 5a9a5f1 commit 5ecad98
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
8 changes: 6 additions & 2 deletions modules/sdcore-user-plane-k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The module can be used to deploy the `sdcore-user-plane-k8s` separately as well
- **main.tf** - Defines the Juju application to be deployed.
- **variables.tf** - Allows customization of the deployment including Juju model name, charm's channel and configuration.
- **output.tf** - Responsible for integrating the module with other Terraform modules, primarily by defining potential integration endpoints (charm integrations).
- **terraform.tf** - Defines the Terraform provider.
- **versions.tf** - Defines the Terraform provider.

## Deploying sdcore-user-plane-k8s module separately

Expand Down Expand Up @@ -74,7 +74,11 @@ Create the `terraform.tfvars` file to specify the name of the Juju model to depl

```console
cat << EOF | tee terraform.tfvars
model_name = "put your model-name here"
data "juju_model" "sdcore_upf_k8s" {
name = "sdcore_upf_k8s"
}

model = data.juju_model.sdcore_upf_k8s.name

# Customize the configuration variables here if needed
EOF
Expand Down
34 changes: 18 additions & 16 deletions modules/sdcore-user-plane-k8s/main.tf
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

resource "juju_model" "sdcore" {
count = var.create_model == true ? 1 : 0
name = var.model_name
data "juju_model" "sdcore_upf" {
name = var.model
}

module "upf" {
source = "git::https://github.com/canonical/sdcore-upf-k8s-operator//terraform"
model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name
channel = var.upf_channel
config = var.upf_config
source = "git::https://github.com/canonical/sdcore-upf-k8s-operator//terraform?ref=chore-cc006"
model = data.juju_model.sdcore_upf.name
channel = var.upf_channel
config = var.upf_config
constraints = "arch=amd64"
}

module "grafana-agent" {
source = "../external/grafana-agent-k8s"
model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name
model_name = data.juju_model.sdcore_upf.name
channel = var.grafana_agent_channel
config = var.grafana_agent_config
}

# Integrations for `metrics` endpoint

resource "juju_integration" "upf-metrics" {
model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name
model = data.juju_model.sdcore_upf.name

application {
name = module.upf.app_name
endpoint = module.upf.metrics_endpoint
endpoint = module.upf.provides.metrics
}

application {
Expand All @@ -39,11 +39,11 @@ resource "juju_integration" "upf-metrics" {
# Integrations for `logging` endpoint

resource "juju_integration" "upf-logging" {
model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name
model = data.juju_model.sdcore_upf.name

application {
name = module.upf.app_name
endpoint = module.upf.logging_endpoint
endpoint = module.upf.requires.logging
}

application {
Expand All @@ -55,13 +55,15 @@ resource "juju_integration" "upf-logging" {
# Cross-model integrations

resource "juju_offer" "upf-fiveg-n3" {
model = var.model_name
model = data.juju_model.sdcore_upf.name
application_name = module.upf.app_name
endpoint = module.upf.fiveg_n3_endpoint
endpoint = module.upf.provides.fiveg_n3
name = "upf-fiveg-n3"
}

resource "juju_offer" "upf-fiveg-n4" {
model = var.model_name
model = data.juju_model.sdcore_upf.name
application_name = module.upf.app_name
endpoint = module.upf.fiveg_n4_endpoint
endpoint = module.upf.provides.fiveg_n4
name = "upf-fiveg-n4"
}
10 changes: 2 additions & 8 deletions modules/sdcore-user-plane-k8s/variables.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

variable "model_name" {
description = "Name of Juju model to deploy application to."
variable "model" {
description = "Reference to a juju_model to deploy application to."
type = string
default = ""
}

variable "create_model" {
description = "Allows to skip Juju model creation and re-use a model created in a higher level module."
type = bool
default = true
}

variable "upf_channel" {
description = "The channel to use when deploying `sdcore-upf-k8s` charm."
type = string
Expand Down

0 comments on commit 5ecad98

Please sign in to comment.