Set up your development environment with Microk8s for Juju Terraform Provider

Prerequisites

Make sure the following software and tools are installed in the development environment.

  • Kubernetes Cluster
  • juju
  • Terraform

Prepare Development Environment

Install Microk8s:

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

Enable storage plugin for 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 Controller using Microk8s:

juju bootstrap microk8s

Testing

Terraform provider

The Terraform module uses the Juju provider to provision Juju resources. Please refer to the Juju provider documentation for more information.

A Terraform working directory needs to be initialized at the beginning.

Initialise the provider:

terraform init

Terraform CLI provides various ways to do formatting and validation.

Formats to a canonical format and style:

terraform fmt

Check the syntactical validation:

terraform validate

Preview the changes:

terraform plan

We are also starting to add terraform provider for juju documentation into the overall juju docs. It will be included as an available client when using some functionality. e.g. Juju | Client