Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using Vagrant with MicroK8S to experiment with Kubernetes

Using Vagrant with MicroK8S to experiment with Kubernetes

This Virtual Machine (using Vagrant) to build an Ubuntu based virtual machine that has the MicroK8S setup of Kubernetes.

It also installs docker, and sets up aliases for kubectl in line with the MicroK8S documentation.

Initially this should be functionally similar to MiniKube.

If you want a multi-node similar environment, here's a similar repository.


On my Windows machine, I wanted to follow the advice of a colleague and run MicroK8S to experiment with Kubernetes. I followed the advice on MicroK8S, and tried to use Multipass and found that it recommends using Hyper-V on Windows Hosts. Unfortunately, on my machine, I also use VirtualBox for some machines I've worked with, so I'm unable to use the Hyper-V based MultiPass. Multipass does allow a VirtualBox backend, however, it doesn't then bridge an interface, nor does it allow port forwarding.

Vagrant.configure("2") do |config|
config.vm.define "microk8s" do |microk8s| = "ubuntu/bionic64"
microk8s.vm.hostname = "microk8s" "public_network",
use_dhcp_assigned_default_route: true
microk8s.vm.provider "virtualbox" do |vb| = "microk8s"
vb.memory = 4096
vb.cpus = 2
microk8s.vm.provision "shell", inline: <<-EOF
snap install microk8s --classic
snap install docker
microk8s.status --wait-ready
microk8s.enable dns dashboard registry
usermod -a -G microk8s vagrant
echo "alias kubectl='microk8s.kubectl'" > /home/vagrant/.bash_aliases
chown vagrant:vagrant /home/vagrant/.bash_aliases
echo "alias kubectl='microk8s.kubectl'" > /root/.bash_aliases
chown root:root /root/.bash_aliases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment