Skip to content

canonical/terraform-juju-traefik-k8s

Repository files navigation

SD-Core Traefik K8s Terraform Module

This SD-Core Traefik K8s Terraform module aims to deploy the traefik-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:

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

Enable dns, storage and metallb plugin.

sudo microk8s enable storage dns
sudo microk8s enable metallb:10.0.0.2-10.0.0.100

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 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 application.

juju status --relations

The output should be similar to the following:

Clean up

Remove the application:

terraform destroy -auto-approve