[Notes] Using microk8s on Ubuntu

[Notes] Using microk8s on Ubuntu

Jun 2, 2020

microk8s is one of the best tools that people can set up quickly and easily to develop and test k8s apps. This is my notes of some common tricks of using microk8s on Ubuntu machines. This notes will be updated further when I discover new tricks.

Installation

ref: https://microk8s.io/docs

# install microk8s from snap
sudo snap install microk8s --classic --channel=1.18/stable

# add user permission
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube

# re-login to inherit the latest group permissions
su - $USER

# wait for it to be ready
microk8s status --wait-ready

Addons

ref: https://microk8s.io/docs/addons

# check all addons
microk8s status

# install commonly-used addons
microk8s enable dns ingress rbac storage

Usage

Use microk8s kubectl as kubectl, or one can do:

alias kubectl='microk8s kubectl'

If you want to use your own kubectl, you can dump kubeconfig using:

microk8s.kubectl config view --flatten > $HOME/.kube/config

Images

To use locally-built docker images, export the images to containerd

docker save <image> | microk8s ctr image import -

comments powered by Disqus