Set up your deployment - local testing and development

Important

The logic is always the same: set up an isolated environment; get Juju, a cloud, and charms; start deploying. However, for certain steps there is an automatic path that greatly facilitates things – we strongly recommend you take it.

If you however wish to follow the manual path and to skip the blueprint or the entire Multipass VM: For best results try to stay very close to the definition of the charm-dev blueprint .

Depending on your use case you may also wish to install further Juju clients or charm development tools; we include those steps too, though feel free to skip them if they don’t apply.

  1. Create an isolated environment, as below:

Install Multipass . For example, on a Linux with snapd:

$ sudo snap install multipass

Important

If on Windows: Note that Multipass can only be installed on Windows 10 Pro or Enterprise. If you are using a different version, please follow the manual path, omitting the Multipass step.

Use Multipass to create an isolated environment:

Launch a VM called my-juju-vm using the charm-dev blueprint:

Note

This step may take a few minutes to complete (e.g., 10 mins).

This is because the command downloads, installs, (updates,) and configures a number of packages, and the speed will be affected by network bandwidth (not just your own, but also that of the package sources).

However, once it’s done, you’ll have everything you’ll need – all in a nice isolated environment that you can clean up easily. (See more: GitHub > multipass-blueprints > charm-dev.yaml .)

$ multipass launch --cpus 4 --memory 8G --disk 50G --name my-juju-vm charm-dev

Open a shell into the VM:

$ multipass shell my-juju-vm
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-100-generic x86_64)
# ...
# Type any further commands after the VM shell prompt:
ubuntu@my-juju-vm:~$
Tips for usage

At any point:

  • To exit the shell, press mod + C (e.g., Ctrl+C) or type exit.

  • To stop the VM after exiting the VM shell, run multipass stop my-juju-vm.

  • To restart the VM and re-open a shell into it, type multipass shell my-juju-vm.

Tips for troubleshooting

If the VM launch fails, run multipass delete --purge my-juju-vm to clean up, then try the launch line again.

  1. Ensure you have the juju CLI client; on juju, a localhost cloud (microk8s - a MicroK8s-based Kubernetes cloud for Kubernetes charms; localhost – a LXD-based machine cloud for machine charms); in the cloud, a Juju controller (i.e., control plane); on the controller, a model (i.e., workspace):

Thanks to the charm-dev blueprint, you should already have everything you need:

# Verify that you have juju:
juju

# Verify that you have a Kubernetes and a machine cloud
# and they're already known to juju:
juju clouds

# Verify that you already have a controller bootstrapped into each:
juju controllers

# Switch to the preexisting workload model on the controller:
## For the MicroK8s cloud:
ubuntu@my-juju-vm:~$ juju switch microk8s:welcome-k8s

## For the LXD cloud:
ubuntu@my-juju-vm:~$ juju switch lxd:welcome-lxd
  1. (If you are developing a charm or planning to also use a different Juju client:) Ensure you have all the necessary tools, for example, charming tools such as Charmcraft, Python, Tox, Docker, or additional Juju clients such as the Terraform Provider for Juju or JAAS:

Example: Charming tools
# Install Charmcraft:
$ sudo snap install charmcraft --classic

# Ensure you have a version of Python suitable for development with Ops (3.8+):
$ python3 --version

# Set up tox:
$ sudo apt update; sudo apt install python3 python3-pip
$ python3 -m pip install --user tox

# Set up Docker:
$ sudo addgroup --system docker
$ sudo adduser $USER docker
$ newgrp docker
$ sudo snap install docker
  1. (If you are developing a charm or planning to also use a different Juju client, e.g., terraform-provider-juju:) Ensure any local files are accessible from your Multipass VM by creating a local directory and then mounting it to the Multipass VM. For example, if you’re developing a charm:

$ mkdir ~/my-charm

# Mount it to the Multipass VM:
$ multipass mount --type native ~/my-charm my-juju-vm:~/my-charm

# Verify that it's indeed on the VM:
ubuntu@my-juju-vm:~$ ls
my-charm  snap

# Going forward:
# - Use your host machine (on Linux, `cd ~/my-charm`) to create and edit your charm files. This will allow you to use your favorite local editor.
# - Use the Multipass VM shell (on Linux, `ubuntu@my-juju-vm:~$ cd ~/my-charm`) to run Charmcraft and Juju commands.
  1. Continue as usual by setting up users, storage, etc.; adding models; and deploying, configuring, integrating, etc., applications.