This mongodb-k8s Terraform module aims to deploy the mongodb-k8s charm via Terraform.
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 Juju Controller:
juju bootstrap microk8s
Add Juju model named test
:
juju add model test
Initialise the provider:
terraform init
Customize the configuration inputs under terraform.tfvars
file according to requirement. Make sure that given model-name
exists.
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
Run juju switch <juju model>
to switch to the target Juju model and observe the status of the application.
juju status
The output should be similar to the following:
Model Controller Cloud/Region Version SLA Timestamp
test microk8s-localhost microk8s/localhost 3.1.7 unsupported 15:28:02+03:00
App Version Status Scale Charm Channel Rev Address Exposed Message
mongodb-k8s active 1 mongodb-k8s 6/beta 38 10.152.183.51 no Primary
Unit Workload Agent Address Ports Message
mongodb/0* active idle 10.1.146.21 Primary
Remove the application:
terraform destroy -auto-approve