Development Setup

Charms created with the Charmed Operator Framework are able to operate across a wide variety of infrastructure. Before we start, you’ll need access to a machine with snapd installed. If you’re using Ubuntu, you’ve probably already got this installed. There are install instructions for most Linux distributions in the Snapcraft docs. This guide will walk through the installation of the following tools to get you started with charm development:

  • Charmcraft - Developer tooling for creating, building and publishing Charmed Operators
  • Juju - a Charmed Operator Lifecycle Manager (OLM), used for deploying and managing operators
  • Multipass - a lightweight Ubuntu virtual machine manager (optional)
  • MicroK8s - a low-ops Kubernetes distribution we’ll use for testing our Charmed Operator (optional if developing a Charmed Operator for Kubernetes)


Charmcraft is a command line tool used alongside the Charmed Operator Framework to create, build, and publish charms. It is installed using snap:

$ sudo snap install --classic charmcraft

For more information about installing Charmcraft, see Installing Charmcraft.

Charmcraft depends on LXD to build the charms in a container matching the target base(s). To set up LXD manually:

$ sudo snap install lxd
$ sudo adduser $USER lxd
$ newgrp lxd
$ lxd init --auto


Juju can also be installed using snap:

$ sudo snap install juju

Multipass (optional)

If you’d like to create an isolated development environment, or you are running a different operating system or distribution and you’d like to ensure you can follow the documentation without any hurdles, Multipass provisions Ubuntu virtual machines on-demand on any workstation. Whether you’re using a Windows, macOS, or Linux machine, Multipass will provision a fresh new Ubuntu VM using the most appropriate hypervisor for your platform. If you’re working across multiple versions of Juju, or just want to keep your development environment separate, you can use Multipass to do that quickly and easily:

# Install Multipass
$ sudo snap install multipass

# Launch a fresh new VM with 4 cores, 8GB RAM and a 20GB disk
$ multipass launch --cpus 4 --mem 8G --disk 20G --name charm-dev

# Get a shell in the new VM and continue the setup
$ multipass shell charm-dev

Once your VM is up and running, if you’d prefer to work in an editor on your local machine, you can just mount your charm repository into the VM and work on it locally using multipass mount.


MicroK8s (optional) is a low-ops, minimal production Kubernetes for devs, cloud, clusters, workstations, Edge, and IoT. The steps below will get you up and running if you are developing a Charmed Operator for Kubernetes.

# Install MicroK8s package
$ snap install microk8s --channel 1.28-strict

# Add your user to the `microk8s` group for unprivileged access
$ sudo adduser $USER snap_microk8s

# Wait for MicroK8s to finish initialising
$ sudo microk8s status --wait-ready

# Enable the 'storage' and 'dns' addons
# (required for the Juju controller)
$ sudo microk8s enable hostpath-storage dns

# Alias kubectl so it interacts with MicroK8s by default
$ sudo snap alias microk8s.kubectl kubectl

# Ensure your new group membership is apparent in the current terminal
# (Not required once you have logged out and back in again)
$ newgrp snap_microk8s

In order to test our Charmed Operator, we need to first bootstrap a controller onto our Kubernetes instance, and then create a model for our deployment:

# 'micro' is a user-specified name for the controller.
# You can leave this blank, or specify your own name
# This will create a new namespace named `controller-micro` and
# provision a pod which runs the Juju controller with an associated instance
# of MongoDB
$ juju bootstrap microk8s micro

# 'development' is also user-specified.
$ juju add-model development

Creating a model on a Kubernetes controller creates a Kubernetes namespace, and provides a workspace into which Juju can deploy Charmed Operators.

Non-Kubernetes Charm Development

If you are looking to develop a charm for non-Kubernetes infrastructure, Juju can be easily set up to work with a local LXD provider. To learn more, see Using LXD with Juju.

Advanced charm development may require integrating with larger deployments. In those cases, a local MicroK8s or LXD provider may not be sufficient. Instructions for configuring Juju to work with larger deployments can be found here:

Hi, here are some suggestions that might improve this page.

  • The structure in this page is confusing. We start by saying that in order to create a charm we need Multipass (optional), MicroK8s, Juju and Charmcraft. The page assumes we are building a K8s charms and we go as far to say in the instructions of Juju to bootstrap onto MicroK8s. Then comes a disconnected section saying “If you are doing a machine charm use LXD”. Instead we should be clear at the very beginning stating that the tools you need to build a charm are Charmcraft, Juju and Multipas (optional). If you target k8s charms you can use MicroK8s if you target machine charms use LXD. When describing the MicroK8s and LXD substrates we should mention the way Juju bootstraps on them.

  • I would expect to be able to find the charmcraft snap with snap search charmcraft but it is not there.

I’m surprised charmcraft doesn’t appear considering it is in fact on the Snapcraft store. @facundo any idea why?

My guess is that it is “unlisted” - that is you can install it, and you can navigate directly to the URL in the Snap store, but it doesn’t appear in listings/searches. Same for the store search: Snap search results for 'charmcraft' — Linux software in the Snap Store

@facundo @roadmr Do we think now that Charmcraft is in latest/stable we should tidy up the store page and get it listed? We just need someone that’s handy with a pencil to come up with a catchy icon for it :sunglasses:

I’ll bring this to the team.

Multipass isn’t --classic for a while now, care to remove that bit?

1 Like

done, thanks! (fwiw these posts are wikis so they should be editable by most people on here :))

Ah, I only just created an account, thought I’d need a bit more trust to edit, didn’t actually check ¯\(ツ)/¯.

Should ingress be included here?

So I included this because this guide was linked extensively during the “Hello, Kubecon!” talk at the last Operator Day, which included using the nginx-ingress-integrator library. It’s not strictly necessary, but it is if you want to use an nginx ingress controller without doing all the work yourself :slight_smile:

The command

$ sudo snap install charmcraft

Doesn’t seem to work. Charmcraft appear to be a classic snap.

$ sudo snap install charmcraft --classic

On the contrary, juju is mentioned to be installed with --classic while it’s a strictly confined snap.

It appears that the new group of the strictly confined microk8s is no longer microk8s but snap_microk8s.

Thanks for this! I’ve fixed this and the MicroK8s group name issue.