Simple Development Environment with Vagrant and MicroK8S

Simple Development Environment

The key to success in any application development lifecycle is to have as few discrepancies as possible between environments. Luckily, Kubernetes and Docker give you the necessary tools to achieve environment uniformization. Nonetheless, it was always challenging to create development environments that would work on any operating system, be it Linux, Windows, or macOS. This short article will guide you through all the necessary steps to create your own development environment with Vagrant and MicroK8S on your laptop or PC.

The Stack

  • VirtualBox
  • Vagrant
  • MicroK8S

The reason for choosing these 3 tools is that they are very easy to use. Additionally, Vagrant provides a reproducible environment that is versioned using git—thus, everyone is welcome to bring their own contributions.

Now, to install VirtualBox and Vagrant, you can use the following links:

Getting Started with Your Development Evnironment

To make things easier, we have already created a Vagrant project you can fork and modify according to your needs. Next, run the following command to download it:


Further, after cloning the repository, you only need to run the following commands:

$ cd vagrant-microk8s
$ vagrant up

After the virtual machine has finished booting, run:

$ vagrant ssh

This should log you into the machine. Then, you can carry out the rest of the tasks to build your own development environment based on Kubernetes. To check that everything is OK, run:

$ kubectl get ns

The output should look similar to this:

NAME              STATUS   AGE
default           Active   109s
kube-node-lease   Active   110s
kube-public       Active   110s
kube-system       Active   110s

The Vagrantfile

Without delay, I would like to explain what the Vagrantfile does.

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |v|
    v.memory = 4096
    v.cpus = 1 = 'vagrant-microk8s'
  end "private_network", ip: "" = "generic/ubuntu2004"
  config.vm.provision "file", source: "#{File.dirname(__FILE__)}/.bash_aliases", destination: "~/.bash_aliases"
  config.vm.provision :shell, path: "#{File.dirname(__FILE__)}/bin/"
  config.ssh.username = "vagrant"
  config.ssh.password = "vagrant"

This creates a virtual machine, which will appear as vagrant-microk8s in VirtualBox. It has 4GB of RAM and 1 CPU core (customizable if you fork the repository). It’s based on Ubuntu 20.04 and it uses a private network with an IP address of Therefore, you can reach it directly from your laptop or PC without requiring port forwarding. Moreover, this part is configurable if you fork the repository.

Now, the last things are copying the bootstrap shell script which installs microk8s and a bunch of aliases. By doing this, you won’t have to prefix your kubectl and docker commands with microk8s. Finally, the username and password for ssh-ing are configured to vagrant/ vagrant.

This is all for now in the area of building a development environment using Vagrant and MicroK8S. We hope that our article will help you in the process of running Kubernetes on any machine—easier and reproducible.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.