Skip to content

canonical/terraform-juju-sdcore-nssf-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SD-Core NSSF K8s Terraform Module

This SD-Core NSSF K8s Terraform module aims to deploy the sdcore-nssf-k8s charm via Terraform.

Getting Started

Install requirements

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

  • microk8s
  • juju 3.x
  • terrafom

Install Microk8s and enable storage add-on:

sudo snap install microk8s --channel=1.27-strict/stable
sudo usermod -a -G snap_microk8s $USER
newgrp snap_microk8s
sudo microk8s enable hostpath-storage

Install Juju:

sudo snap install juju --channel=3.1/stable

Install Terraform:

sudo snap install --classic terraform

Bootstrap the Juju using Microk8s and create a model to deploy Terraform module

Bootstrap Juju Controller:

juju bootstrap microk8s

Deploy Mongodb-k8s using Terraform

Initialise the provider:

terraform init

Customize the configuration inputs under terraform.tfvars file according to requirement.

Sample contents of terraform.tfvars file:

model_name ="test"

Run Terraform plan by providing a var-file:

terraform plan -var-file="terraform.tfvars" 

Deploy the resources, skip the approval.

terraform apply -auto-approve 
After running above command, if you get the error below, run the `terraform apply -auto-approve` again. 
`Unable to create application, got error: model "<model_name>" not found`

Check the Output

Run juju switch <juju model> to switch to the target Juju model and observe the status of the applications.

juju status --relations

The output should be similar to the following:

Model  Controller          Cloud/Region        Version  SLA          Timestamp
test   microk8s-localhost  microk8s/localhost  3.1.7    unsupported  13:56:43+03:00

App                       Version  Status  Scale  Charm                     Channel   Rev  Address         Exposed  Message
nssf                               active      1  sdcore-nssf-k8s           1.3/edge   17  10.152.183.163  no       
mongodb-k8s                        active      1  mongodb-k8s               6/beta     38  10.152.183.133  no       
nrf                                active      1  sdcore-nrf-k8s            1.3/edge   18  10.152.183.192  no       
self-signed-certificates           active      1  self-signed-certificates  beta       57  10.152.183.179  no       

Unit                         Workload  Agent  Address      Ports  Message
nssf/0*                      active    idle   10.1.146.2          
mongodb-k8s/0*               active    idle   10.1.146.60         
nrf/0*                       active    idle   10.1.146.6          
self-signed-certificates/0*  active    idle   10.1.146.9          

Integration provider                   Requirer                    Interface         Type     Message
mongodb-k8s:database                   nssf:database               mongodb_client    regular  
mongodb-k8s:database                   nrf:database                mongodb_client    regular  
mongodb-k8s:database-peers             mongodb-k8s:database-peers  mongodb-peers     peer     
nrf:fiveg-nrf                          nssf:fiveg-nrf              fiveg_nrf         regular  
self-signed-certificates:certificates  nssf:certificates           tls-certificates  regular  
self-signed-certificates:certificates  nrf:certificates            tls-certificates  regular 

Clean up

Remove the applications:

terraform destroy -auto-approve