Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Feb 14, 2024
1 parent e8259aa commit 7325385
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 152 deletions.
50 changes: 6 additions & 44 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,13 @@

## Prerequisites

To make contributions to this repository, the following software and tools needs to be installed in your development environment.
To make contributions to this repository, the following software is needed to be installed in your development environment. Please [set up your environment][set-up-environment] before development.

- A Kubernetes cluster
- Juju 3.x
- Juju controller bootstrapped onto the K8s cluster
- Terraform

## Prepare Development Environment

Install Microk8s:

```console
sudo snap install microk8s --channel=1.27-strict/stable
sudo usermod -a -G snap_microk8s $USER
newgrp snap_microk8s
```

Enable `storage` plugin for Microk8s:

```console
sudo microk8s enable hostpath-storage
```

Install Juju:

```console
sudo snap install juju --channel=3.1/stable
```

Install Terraform:

```console
sudo snap install --classic terraform
```

Bootstrap the Juju Controller using Microk8s:

```console
juju bootstrap microk8s
```

Add a Juju model:

```console
juju add-model <model-name>
````

## Development and Testing

The Terraform module uses the Juju provider to provision Juju resources. Please refer to the [Juju provider documentation](https://registry.terraform.io/providers/juju/juju/latest/docs) for more information.
Expand All @@ -61,13 +21,13 @@ Initialise the provider:
terraform init
```

Formats the *.tf files to a canonical format and style:
Format the *.tf files to a canonical format and style:

```console
terraform fmt
```

Check the syntactical validation:
Check the syntax:

```console
terraform validate
Expand All @@ -77,4 +37,6 @@ Preview the changes:

```console
terraform plan
```
```

[set-up-environment]: [https://discourse.charmhub.io/t/set-up-your-development-environment-with-microk8s-for-juju-terraform-provider/13109]
93 changes: 87 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# SD-Core Terraform Module

This folder contains the [Terraform][Terraform] module for [sdcore-k8s][sdcore-k8s] consisting of [sdcore-control-plane-k8s][sdcore-control-plane-k8s] and [sdcore-user-plane-k8s][sdcore-user-plane-k8s] modules.
This project contains 3 [Terraform][Terraform] modules to deploy the following SD-Core bundles: [SD-Core][sdcore-k8s], [SD-Core CP][sdcore-control-plane-k8s] and [SD-Core UP][sdcore-user-plane-k8s].

The modules use the [Terraform Juju provider][Terraform Juju provider] to model the charm deployment onto any Kubernetes environment managed by [Juju][Juju].
The modules use the [Terraform Juju provider][Terraform Juju provider] to model the bundle deployment onto any Kubernetes environment managed by [Juju][Juju].

`sdcore-k8s` module deploys a standalone 5G core network. This module contains the 5G control plane functions, the UPF, Webui, Grafana Agent, Traefik, Self Signed Certificates and MongoDB.

`sdcore-control-plane-k8s` module deploys the 5G control plane and the `sdcore-user-plane-k8s` module deploys only the 5G user plane. Hence, the SD-Core 5G core network deployment could be performed following the Control and User Plane Separation (CUPS) principles.

## Module structure

- **main.tf** - Defines the Juju application to be deployed.
- **variables.tf** - Allows customization of the deployment. Except for exposing the deployment options (Juju model name, channel) also allows overwriting charm's default configuration.
- **variables.tf** - Allows customization of the deployment including Juju model name, charm's channel and configuration.
- **terraform.tf** - Defines the Terraform provider.

## Deploying sdcore-k8s module

### Pre-requisites

The following tools needs to be installed and should be running in the environment.
The following tools need to be installed and should be running in the environment.

- A Kubernetes host with a CPU supporting AVX2 and RDRAND instructions (Intel Haswell, AMD Excavator or equivalent)
- A Kubernetes cluster with the `Multus` and `Metallb` addon enabled.
- The Load balancer (MetalLB) has address range with at least 3 available IP addresses
- Juju 3.x
- Juju controller bootstrapped onto the K8s cluster
- Terraform
Expand All @@ -39,6 +44,7 @@ sudo microk8s addons repo add community https://github.com/canonical/microk8s-co
```

Enable the `hostpath-storage`, `multus` and `metallb` MicroK8s addons.

```shell
sudo microk8s enable hostpath-storage
sudo microk8s enable multus
Expand Down Expand Up @@ -67,11 +73,12 @@ terraform init

Create the `terraform.tfvars` file to specify the name of the Juju model to deploy to. Reusing already existing model is not recommended.

```yaml
# Mandatory Config Options
```console
cat << EOF | tee terraform.tfvars
model_name = "put your model-name here"

# Customize the configuration variables here if needed
EOF
```

Create the Terraform Plan:
Expand All @@ -94,6 +101,80 @@ Run `juju switch <juju model>` to switch to the target Juju model and observe th
juju status --relations
```

This will show an output similar to the following:

```console
Model Controller Cloud/Region Version SLA Timestamp
<model_name> microk8s-localhost microk8s/localhost 3.1.7 unsupported 16:57:40+03:00

App Version Status Scale Charm Channel Rev Address Exposed Message
amf active 1 sdcore-amf-k8s 1.3/edge 29 10.152.183.243 no
ausf active 1 sdcore-ausf-k8s 1.3/edge 24 10.152.183.126 no
grafana-agent 0.32.1 waiting 1 grafana-agent-k8s latest/stable 51 10.152.183.232 no installing agent
mongodb active 1 mongodb-k8s 6/beta 38 10.152.183.205 no Primary
nms active 1 sdcore-nms-k8s 1.3/edge 23 10.152.183.87 no
nrf active 1 sdcore-nrf-k8s 1.3/edge 30 10.152.183.27 no
nssf active 1 sdcore-nssf-k8s 1.3/edge 24 10.152.183.210 no
pcf active 1 sdcore-pcf-k8s 1.3/edge 26 10.152.183.64 no
self-signed-certificates active 1 self-signed-certificates beta 72 10.152.183.104 no
smf active 1 sdcore-smf-k8s 1.3/edge 25 10.152.183.134 no
traefik 2.10.4 active 1 traefik-k8s latest/stable 166 10.0.0.14 no
udm active 1 sdcore-udm-k8s 1.3/edge 23 10.152.183.165 no
udr active 1 sdcore-udr-k8s 1.3/edge 23 10.152.183.166 no
upf active 1 sdcore-upf-k8s 1.3/edge 31 10.152.183.91 no
webui active 1 sdcore-webui-k8s 1.3/edge 15 10.152.183.208 no

Unit Workload Agent Address Ports Message
amf/0* active idle 10.1.146.108
ausf/0* active idle 10.1.146.112
grafana-agent/0* blocked idle 10.1.146.122 logging-consumer: off, grafana-cloud-config: off
mongodb/0* active idle 10.1.146.107 Primary
nms/0* active idle 10.1.146.82
nrf/0* active idle 10.1.146.127
nssf/0* active idle 10.1.146.78
pcf/0* active idle 10.1.146.95
self-signed-certificates/0* active idle 10.1.146.120
smf/0* active idle 10.1.146.111
traefik/0* active idle 10.1.146.74
udm/0* active idle 10.1.146.81
udr/0* active idle 10.1.146.105
upf/0* active idle 10.1.146.103
webui/0* active idle 10.1.146.65

Integration provider Requirer Interface Type Message
amf:metrics-endpoint grafana-agent:metrics-endpoint prometheus_scrape regular
grafana-agent:logging-provider mongodb:logging loki_push_api regular
grafana-agent:peers grafana-agent:peers grafana_agent_replica peer
mongodb:database amf:database mongodb_client regular
mongodb:database nrf:database mongodb_client regular
mongodb:database pcf:database mongodb_client regular
mongodb:database smf:database mongodb_client regular
mongodb:database udr:database mongodb_client regular
mongodb:database webui:database mongodb_client regular
mongodb:database-peers mongodb:database-peers mongodb-peers peer
mongodb:metrics-endpoint grafana-agent:metrics-endpoint prometheus_scrape regular
nrf:fiveg_nrf amf:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf ausf:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf nssf:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf pcf:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf smf:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf udm:fiveg_nrf fiveg_nrf regular
nrf:fiveg_nrf udr:fiveg_nrf fiveg_nrf regular
self-signed-certificates:certificates amf:certificates tls-certificates regular
self-signed-certificates:certificates ausf:certificates tls-certificates regular
self-signed-certificates:certificates nrf:certificates tls-certificates regular
self-signed-certificates:certificates nssf:certificates tls-certificates regular
self-signed-certificates:certificates pcf:certificates tls-certificates regular
self-signed-certificates:certificates smf:certificates tls-certificates regular
self-signed-certificates:certificates udm:certificates tls-certificates regular
self-signed-certificates:certificates udr:certificates tls-certificates regular
smf:metrics-endpoint grafana-agent:metrics-endpoint prometheus_scrape regular
traefik:ingress nms:ingress ingress regular
traefik:peers traefik:peers traefik_peers peer
upf:metrics-endpoint grafana-agent:metrics-endpoint prometheus_scrape regular
webui:sdcore-management nms:sdcore-management sdcore_management regular
```

### Clean up

Destroy the deployment:
Expand Down
Loading

0 comments on commit 7325385

Please sign in to comment.