• +43 660 1453541
  • contact@germaniumhq.com

Try Kubernetes in a Snap in Ubuntu 18.04


Try Kubernetes in a Snap in Ubuntu 18.04

If you want to try Kubernetes locally you’re in for a lot of trouble. Installing it requires you to deal with changing apt repos, installing docker, installing kubectl and kubeadm, provisioning, installing networking, configuring the keys for cluster access, etc. Fortunately Ubuntu offers an easier way, via snaps.

To install your own private tiny cluster, you execute in the terminal:

snap install --classic microk8s

This snap is provided by Canonical, the company behind Ubuntu. When you install it you just get a bare bones Kubernetes installation. To access it, you need to call microk8s.kubectl. Yes, it’s already configured for use.

A thing I like, is to alias it:

alias kubectl=microk8s.kubectl

As we know, an empty Kubernetes cluster it’s pretty boring. But to install DNS, ingress, istio, and even a private docker registry, in this snap version of it, is trivial. We get the following tools to administer the cluster, beside kubectl:

microk8s.config    microk8s.docker    microk8s.inspect   microk8s.kubectl
microk8s.start     microk8s.stop      microk8s.disable   microk8s.enable
microk8s.istioctl  microk8s.reset     microk8s.status

To enable addons such as DNS, or registry, just call microk8s.enable ADDON. These are the addons available, straight from the help:

Usage: microk8s.enable ADDON...
Enable one or more ADDON included with microk8s
Example: microk8s.enable dns storage

Available addons:

  dashboard
  dns
  gpu
  ingress
  istio
  metrics-server
  registry
  storage

If we install the registry, we can use the microk8s.docker that operates against that docker registry bundled in our cluster. No /etc/docker/daemon.conf changes needed, no nothing. This alone is super sweet.

This is fantastically awesome, since if for whatever reason you need to get start over, you wipe it out of existence with stap remove and start over, and in minutes you’ll have a fresh new cluster.

Happy Kubernetes!