1. Overview

What is Kubernetes

Kubernetes clusters host containerised applications in a reliable and scalable way. Having DevOps in mind, Kubernetes makes maintenance tasks such as upgrades dead simple.

What is MicroK8s

MicroK8s is a CNCF certified upstream Kubernetes deployment that runs entirely on your workstation or edge device. Being a snap it runs all Kubernetes services natively (i.e. no virtual machines) while packing the entire set of libraries and binaries needed. Installation is limited by how fast you can download a couple of hundred megabytes and the removal of MicroK8s leaves nothing behind.

What is Multipass

Multipass is a lightweight VM manager for Linux, Windows and macOS. It’s designed for developers who want a fresh Ubuntu environment with a single command. It uses KVM on Linux, Hyper-V on Windows and HyperKit on macOS to run the VM with minimal overhead. It can also use VirtualBox on Windows and macOS. Multipass will fetch images for you and keep them up to date.

In this tutorial you’ll learn how to…

  • Setting up Multipass on Windows
  • Setting up MicroK8s on your Multipass VM
  • Enabling MicroK8s add-ons in Multipass

You will only need …

  • A Windows machine with at least 8GB of RAM
  • Multipass installed on your PC, you can download the latest Windows executable from GitHub

2. Spinning up a VM with MicroK8s

To install MicroK8s from the command prompt, use the following commands (make sure you have Multipass installed):

multipass launch --name microk8s-vm --mem 4G --disk 40G
multipass exec microk8s-vm -- sudo snap install microk8s --classic
multipass exec microk8s-vm -- sudo iptables -P FORWARD ACCEPT

Make sure you reserve enough resources to host your deployments; above, we got 4GB of RAM and 40GB of hard disk. We also make sure packets to/from the pod network interface can be forwarded to/from the default interface.

The VM has an IP address that you can check with the command:

multipass list
Name                    State             IPv4             Release
microk8s-vm             RUNNING     Ubuntu 18.04 LTS

The services once enabled will be available at the IP address shown in your console.

Before we move on, a few quick handy commands:

Create a shell inside the VM

multipass shell microk8s-vm

Shutdown the VM

multipass stop microk8s-vm

Delete the VM and cleanup

multipass delete microk8s-vm 
multipass purge 

3. Using MicroK8s

Open a shell in Multipass with a MicroK8s VM

multipass shell microk8s-vm

To execute a command without getting a shell, you can use multipass exec as in the example below:

multipass exec microk8s-vm -- /snap/bin/microk8s.status

This will show us the status of our MicroK8s deployment and components.

4. Testing Add-ons

While MicroK8s has a lot of useful add-ons, for simplicity’s sake we’ll enable and use the dns and dashboard addons. We can view the Grafana dashboard for our deployment.

Let’s enable the add-ons. Use the follwoing command:

multipass exec microk8s-vm -- /snap/bin/microk8s.enable dns dashboard

Let’s access hosted services. The API server proxies our services, here is how to get to them:

multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl cluster-info
Kubernetes master is running at
Heapster is running at
CoreDNS is running at
Grafana is running at
InfluxDB is running at

We need to point our browser to Get the username and password using the command

multipass exec microk8s-vm -- /snap/bin/microk8s.config

Grafana Dashboard

5. Host your first service in Kubernetes

We start by creating a microbot deployment with two pods via the kubectl cli:

multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl create deployment microbot --image=dontrebootme/microbot:v1
multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl scale deployment microbot --replicas=2

To expose our deployment we need to create a service:

multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl expose deployment microbot --type=NodePort --port=80 --name=microbot-service

After a few minutes our cluster looks like this:

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl get all --all-namespaces
NAMESPACE     NAME                                                  READY   STATUS    RESTARTS   AGE
default       pod/microbot-7dd47b8fd6-4rzt6                         1/1     Running   0          46s
default       pod/microbot-7dd47b8fd6-xr49r                         1/1     Running   0          39s
kube-system   pod/coredns-f7867546d-zb9t5                           1/1     Running   0          10m
kube-system   pod/heapster-v1.5.2-844b564688-5bpzs                  4/4     Running   0          8m22s
kube-system   pod/kubernetes-dashboard-7d75c474bb-jcglw             1/1     Running   0          10m
kube-system   pod/monitoring-influxdb-grafana-v4-6b6954958c-nc6bq   2/2     Running   0          10m

NAMESPACE     NAME                           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
default       service/kubernetes             ClusterIP     <none>        443/TCP                  10m
default       service/microbot-service       NodePort    <none>        80:32648/TCP             25s
kube-system   service/heapster               ClusterIP     <none>        80/TCP                   10m
kube-system   service/kube-dns               ClusterIP    <none>        53/UDP,53/TCP,9153/TCP   10m
kube-system   service/kubernetes-dashboard   ClusterIP    <none>        443/TCP                  10m
kube-system   service/monitoring-grafana     ClusterIP     <none>        80/TCP                   10m
kube-system   service/monitoring-influxdb    ClusterIP   <none>        8083/TCP,8086/TCP        10m

NAMESPACE     NAME                                             READY   UP-TO-DATE   AVAILABLE   AGE
default       deployment.apps/microbot                         2/2     2            2           46s
kube-system   deployment.apps/coredns                          1/1     1            1           10m
kube-system   deployment.apps/heapster-v1.5.2                  1/1     1            1           10m
kube-system   deployment.apps/kubernetes-dashboard             1/1     1            1           10m
kube-system   deployment.apps/monitoring-influxdb-grafana-v4   1/1     1            1           10m

NAMESPACE     NAME                                                        DESIRED   CURRENT   READY   AGE
default       replicaset.apps/microbot-7dd47b8fd6                         2         2         2       46s
kube-system   replicaset.apps/coredns-f7867546d                           1         1         1       10m
kube-system   replicaset.apps/heapster-v1.5.2-6b794f77c8                  0         0         0       10m
kube-system   replicaset.apps/heapster-v1.5.2-6f5d55456                   0         0         0       8m42s
kube-system   replicaset.apps/heapster-v1.5.2-844b564688                  1         1         1       8m22s
kube-system   replicaset.apps/kubernetes-dashboard-7d75c474bb             1         1         1       10m
kube-system   replicaset.apps/monitoring-influxdb-grafana-v4-6b6954958c   1         1         1       10m

At the very top we have the microbot pods, service/microbot-service is the second in the services list. Our service has a ClusterIP through which we can access it. Notice, however, that our service is of type NodePort. This means that our deployment is also available on a port on the host machine; that port is randomly selected and in this case it happens to be 32648. All we need to do is to point our browser to http://localhost:32648.


6. That’s all folks!

Congratulations, you got your MicroK8s deployment running on Mac!

Until next time, stop all MicroK8s services:

multipass exec microk8s-vm -- /snap/bin/microk8s.stop

Where to go from here?