Alternative install methods
MicroK8s is spectacularly easy to install and use on Ubuntu or any Linux which supports snaps. For other platforms or less common scenarios, see the relevant notes below.
Although Windows 10 now has some very useful features, such as the ability to install Ubuntu as an app, the integration of WSL2 still doesn’t provide all the Ubuntu functionality required to make MicroK8s run smoothly out-of-the-box.
If you wish to experiment with running MicroK8s semi-natively, take a look at this discourse post on WSL2.
For now, the best way to run MicroK8s on Windows is with virtualisation. MicroK8s will install without problems on Ubuntu running on number of different VMs, including VirtulBox.
As with Windows, the recommended way to run MicroK8s on macOS is to use multipass, although it is possible to run under other VMs.
There is an installer for multipass available on the multipass site. See the notes for running MicroK8s on multipass below.
With multipass installed, you can now create a VM to run MicroK8s. At least 4 Gigabytes of RAM and 40G of storage is recommended – we can pass these requirements when we launch the VM:
multipass launch --name microk8s-vm --mem 4G --disk 40G
To install the MicroK8s snap and configure the network:
multipass exec microk8s-vm -- sudo snap install microk8s --classic multipass exec microk8s-vm -- sudo iptables -P FORWARD ACCEPT
We can now find the IP address which has been allocated. Running:
… will return something like:
Name State IPv4 Release microk8s-vm RUNNING 10.72.145.216 Ubuntu 18.04 LTS
Take a note of this IP as services will become available there when accessed from the host machine.
Useful multipass commands
Get a shell inside the VM:
multipass shell microk8s-vm
Shutdown the VM:
multipass stop microk8s-vm
Delete and cleanup the VM:
multipass delete microk8s-vm multipass purge
Running MicroK8s on some ARM hardware may run into difficulties because cgroups (required!) are not enabled by default. This can be remedied on the Rasberry Pi by editing the boot parameters:
sudo vi /boot/firmware/cmdline.txt
And adding the following:
Systems using ZFS
There is currently an issue surrounding using MicroK8s on a ZFS filesystem due to the way containerd is configured. If you have installed MicroK8s on ZFS you can fix this:
Remove old state of containerd:
sudo rm -rf /var/snap/microk8s/common/var/lib/containerd
Configure containerd to use ZFS: Edit the file
snapshotter = "overlayfs"with
snapshotter = "zfs"
Create new zfs dataset for containerd to use:
zfs create -o mountpoint=/var/snap/microk8s/common/var/lib/containerd/io.containerd.snapshotter.v1.zfs $POOL/containerd
There are situations where it is necessary or desirable to run MicroK8s on a machine not connected to the internet. This is possible, but there are a few extra things to be aware of.
Downloading a snap
If the machine you are intending to install MicroK8s to has no connectivity at all, it is possible to download the snap from a machine which does have access to the internet.
snap download microk8s
this will retrieve two files to the local directory:
- microk8s_xxx.snap: The snap package with a versioned suffix.
- microk8s_xxx.assert: The assertion file (effectively a signature validating the package).
When the files are transferred to the offline machine, MicroK8s can then be installed with the following commands:
sudo snap ack microk8s_993.assert sudo snap install microk8s_993.snap
In an offline environment, the snap will not be able to contact the store for any updates.
Simulating a network
In some environments, as well as being offline, there is no network capability at all (e.g. no NIC hardware). In such cases the Kubernetes apiserver will not be able to work. This can be solved by simulating hardware (e.g. in a VM) or adding a virtual address.
For an example, see this answer on askubuntu.