Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

chore: Replacing Juju bundles with Terraform modules in Deploy SD-Core Standalone and Integrate SD-Core with Canonical Observability Stack #192

2 changes: 2 additions & 0 deletions docs/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ PCF
pdpe
PDU
PFCP
Pre
RAN
resolv
RDRAND
Expand All @@ -107,6 +108,7 @@ subnets
systemd
TCP
Terraform
Terraform's
TLS
Traefik
UDM
Expand Down
51 changes: 47 additions & 4 deletions docs/how-to/deploy_sdcore_standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,58 @@ You will need a Kubernetes cluster installed and configured with Multus.

- Juju >= 3.4
- Kubernetes >= 1.25
- A `LoadBalancer` Service for Kubernetes
- A `LoadBalancer` Service for Kubernetes with at least 3 addresses available
- Multus
- Terraform
- Git

## Deploy

```bash
juju deploy sdcore-k8s --trust --channel=beta
Get Charmed 5G Terraform modules by cloning the [Charmed 5G Terraform modules][Charmed 5G Terraform modules] Git repository.
Inside the `modules/sdcore-k8s` directory, create a `terraform.tfvars` file to set the name of Juju model for the deployment:

```console
git clone https://github.com/canonical/terraform-juju-sdcore-k8s.git
cd terraform-juju-sdcore-k8s/modules/sdcore-k8s
cat << EOF > terraform.tfvars
model_name = "<YOUR_JUJU_MODEL_NAME>"
EOF
```

Initialize Juju Terraform provider:

```console
terraform init
```

Deploy 5G network.

```console
terraform apply -var-file="terraform.tfvars" -auto-approve
```

The deployment process should take approximately 15-20 minutes.

You can monitor the status of the deployment:

```console
juju switch <YOUR_JUJU_MODEL_NAME>
watch -n 1 -c juju status --color --relations
```

The deployment is ready when all the charms are in the `Active/Idle` state.
It is normal for `grafana-agent` to remain in waiting state.

## Configure

To view all configuration options, please visit the bundle's [Charmhub page](https://charmhub.io/sdcore-k8s/).
Configuration of the Charmed 5G deployment should be done **only** through the `.tfvars` file.

To view all the available configuration options, please inspect the `variables.tf` file available inside the Terraform module directory.

To be effective, every configuration change needs to be applied using the following command:

```console
terraform apply -var-file="terraform.tfvars" -auto-approve
```

[Charmed 5G Terraform modules]: https://github.com/canonical/terraform-juju-sdcore-k8s
66 changes: 0 additions & 66 deletions docs/how-to/deploy_sdcore_user_plane_with_hugepages.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/how-to/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ These how-to guides cover key operations and processes in Charmed 5G.
deploy_sdcore_standalone
deploy_sdcore_cups
deploy_sdcore_gnbsim
deploy_sdcore_user_plane_with_hugepages
integrate_sdcore_with_observability
```

Expand Down
103 changes: 64 additions & 39 deletions docs/how-to/integrate_sdcore_with_observability.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,104 @@
# Integrate SD-Core with Canonical Observability Stack

## Requirements
[Charmed 5G Terraform modules][Charmed 5G Terraform modules] come with built-in support for the Canonical Observability Stack (COS).
By default, COS deployment and integration is disabled.
This guide covers two ways of integrating SD-Core with COS:
1. [Integrating SD-Core with COS at the deployment stage](#option-1)
2. [Integrating COS with an existing SD-Core deployment](#option-2)

- One of the `sdcore-k8s` bundles deployed in a Juju model
(option-1)=
## Integrating SD-Core with COS at the deployment stage

## Deploy the `cos-lite` bundle
This option allows deploying COS and integrating it with SD-Core as a Day 1 operation.

Deploy the `cos-lite` charm bundle in a Juju model named `cos`:
### Pre-requisites

```bash
juju add-model cos
juju deploy cos-lite --trust
```
- A Kubernetes cluster capable of handling the load from both SD-Core and COS
- [Charmed 5G Terraform modules][Charmed 5G Terraform modules] Git repository cloned onto the Juju host machine

## Deploy the `cos-configuration-k8s` charm
### Including COS integration in the SD-Core deployment

Deploy the `cos-configuration-k8s` charm with the following SD-Core COS configuration:
Inside the directory of a desired SD-Core Terraform module, create `variables.tfvars` file and add following line(s) to it:

```console
juju deploy cos-configuration-k8s \
--config git_repo=https://github.com/canonical/sdcore-cos-configuration \
--config git_branch=main \
--config git_depth=1 \
--config grafana_dashboards_path=grafana_dashboards/sdcore/
deploy_cos = true
cos_model_name = "YOUR_CUSTOM_COS_MODEL_NAME" (Optional. Defaults to `cos-lite`.)
cos_configuration_config = {} (Optional. Allows customization of the `COS Configuration` application.)
```

Integrate it with Grafana:

```console
juju integrate cos-configuration-k8s grafana
```{note}
If you have already created the `.tfvars` file, to customize the deployment of SD-Core, you should edit the existing file rather than create a new one.
```

## Integrate Grafana Agent with Prometheus
Proceed with the deployment.

(option-2)=
## Integrating COS with an existing SD-Core deployment

This option allows deploying COS and integrating it with SD-Core as a Day 2 operation.

We will create a cross model integration between Grafana Agent (in the SD-Core model) and Prometheus (in the `cos` model).
### Pre-requisites

First, offer the following integrations from Prometheus and Loki for use in other models:
- A Kubernetes cluster capable of handling the load from both SD-Core and COS
- Any [Charmed 5G Terraform module][Charmed 5G Terraform modules] deployed

```bash
juju offer cos.prometheus:receive-remote-write
juju offer cos.loki:logging
### Adding COS to an existing SD-Core deployment

Go to a directory from which SD-Core was deployed (the one containing Terraform's `.tfstate` file).
Edit the `.tfvars` and add following line(s) to it:

```console
deploy_cos = true
cos_model_name = "<YOUR_CUSTOM_COS_MODEL_NAME>" (Optional. Defaults to `cos-lite`.)
cos_configuration_config = {} (Optional. Allows customization of the `COS Configuration` application.)
```

Then, consume the integrations from the SD-Core model:
Apply the changes:

```bash
juju switch <SD-Core model>
juju consume cos.prometheus
juju consume cos.loki
```console
terraform apply -var-file="<YOUR_TFVARS_FILE>" -auto-approve
```
Gmerold marked this conversation as resolved.
Show resolved Hide resolved

Integrate `grafana-agent-k8s` with `prometheus` and `loki`:
Monitor the status of the deployment:

```bash
juju integrate prometheus:receive-remote-write grafana-agent-k8s:send-remote-write
juju integrate loki:logging grafana-agent-k8s:logging-consumer
```console
juju switch <YOUR_CUSTOM_COS_MODEL_NAME>
watch -n 1 -c juju status --color --relations
```

The deployment is ready when all the charms are in the `Active/Idle` state.

## Accessing the 5G Network Overview Grafana dashboard

Retrieve the Grafana URL and admin password:

```console
ubuntu@host:~ $ juju run grafana/leader get-admin-password
juju switch cos-lite
juju run grafana/leader get-admin-password
```

You should see the output similar to the following:

```console
Running operation 1 with 1 task
- task 2 on unit-grafana-0

Waiting for task 2...
admin-password: ngdrjomIOMyt
url: http://10.0.0.5/cos-grafana
admin-password: c72uEq8FyGRo
url: http://10.201.0.51/cos-lite-grafana
```

```{note}
Grafana can be accessed using both `http` (as returned by the command above) or `https`.
```

You can now see metrics and logs coming from SD-Core in your Grafana dashboard. Login using
the "admin" username and the admin password obtained in the last command.
In your browser, navigate to the URL from the output (`https://10.201.0.51/cos-grafana`).
Login using the "admin" username and the admin password provided in the last command.
Click on "Dashboards" -> "Browse" and select "5G Network Overview".

```{image} ../images/grafana_5g_dashboard_sim_after.png
:alt: Grafana dashboard
:align: center
```

[Charmed 5G Terraform modules]: https://github.com/canonical/terraform-juju-sdcore-k8s