Still in search of a Kubernetes development environment I can run on my development machine that somewhat replicates, I was recently introduced to both the multipass and microk8s projects from Canonical.

multipass is a prerequisite for microk8s, so let’s start there. With multipass, you can easily launch and run Ubuntu virtual machines with a single command.

❯ multipass launch --name foo

Launched: foo

With a virtual machine in hand, you can run execute arbitrary commands on the machine using the exec subcommand.

❯ multipass shell foo

...

ubuntu@foo:~$ pwd
/home/ubuntu
ubuntu@foo:~$ logout

And of course you can manage your VMs by stopping, starting, or deleting them with single commands. Full details and documentation is available at multipass.run.

When running microk8s on a macOs environment, it leverages multipass for creating the underlying Ubuntu VM that microk8s will be installed to. You can see this VM using the multipass ls command.

❯ multipass ls
Name                    State             IPv4             Image
microk8s-vm             Running           192.168.64.2     Ubuntu 18.04 LTS
                                          10.1.254.64

The nice thing about microk8s is that it bundles the Kubernetes services you most commonly would want to use into the microk8s distribution. So with a single command you can enable any services you are likely to use. In this example, I enable the Kubernetes dashboard, Core DNS, and a container registry so I can easily deploy applications to the cluster.

❯ microk8s enable dashboard dns registry

Enable kubectl to access the microk8s distribution is done using the microk8s config and adding the output to the $HOME/.kube/config file.

❯ microk8s config > $HOME/.kube/config

And lastly, one of my favourite features of microk8s is the ability to reset a cluster to a working state.

❯ microk8s reset --destroy-storage

I’ve found micropass and microk8s both very useful for local development. Multipass gives you easy to use and configure Ubuntu-based development environments where you can keep all of your development dependencies isolated between projects. If your development team also uses Kubernetes, the microk8s project can create simple Kubernetes deployments that use the standard Kubernetes APIs.