Multipass: Mount Host Volume

03-12-2021

I’ve recently been exploring solutions for local development of a robust microservices platform that is using Kubernetes (k8) in production. The basic idea is that I have an application with a few services, a user interface (UI), database, etc. that I want to develop features for in an environment as close to the real production environment as possible. We’ve recently moved to Kubernetes to support production and I want parity for local development as well. I need something easy to setup, configure, and extend to the entire development team.

The tool that is most interesting currently is MicroK8s. MicroK8s uses a virtual machine (VM) provisioned my Multipass to layer a Kubernetes implementation on top. This solution gets really close to the real-world which I like.

For local development I also want a very quick feedback cycle, i.e. I save changes in my local code base and I want to see the results of that local change right away. To achieve this I need to mount my a folder (“volume”) from my local machine to the VM provisioned by Multipass which can then be used by Microk8s in the Kubernetes implementation.

/folder-on-local-machine --> /volume-on-vm --> /volume-on-k8s-pod

With Multipass installed on my local machine and a VM running, run the following command in the terminal:

1
multipass mount /path-to-local-folder <name-of-vm>:/path-on-vm

Example:

1
multipass mount ./api-server microk8s-vm:/api

I’m still exploring this tool chain for local development, but I think this might be part of a workable solution.