Low Orbit Flux Logo 2 F

Kubernetes - MicroK8s - Ubuntu

Install it from a snap:


sudo snap install microk8s --classic

Add user to the microk8s group:


sudo usermod -a -G microk8s user1

Check status and wait until it is ready:


microk8s status --wait-ready

Enable these components:


microk8s enable dashboard dns registry istio
microk8s disable dashboard dns registry istio
microk8s kubectl get all --all-namespaces

Setup aliases for the kubectl command:


alias mkctl="microk8s kubectl"
alias kubectl="microk8s kubectl"

Launch the dashboard-proxy:


microk8s dashboard-proxy

Start or stop MicroK8s:


microk8s start
microk8s stop

https://192.168.3.214:16443/ API server
https://192.168.3.214:10443 dashboard

HA

Do this on both nodes ( needs at least 1.19 ):


sudo snap install microk8s --classic --channel=1.19/stable       # install 
sudo snap refresh microk8s --classic --channel=1.19/stable       # or update

On first host:


microk8s add-node

On second host (replace token):


microk8s join 10.128.63.86:25000/567a21bdfc9a64738ef4b3286b2b8a69

Setup a failure domain and restart:


echo "failure-domain=42" > /var/snap/microk8s/current/args/ha-conf
microk8s.stop
microk8s.start

Run on the node that is leaving:


microk8s leave

Run on another node:


microk8s remove-node host1

Force removal from another node in case we weren’t able to run leave ( due to crash, etc. ):


microk8s remove-node host1 --force

Add a worker:


microk8s add-node
microk8s join 192.168.1.230:25000/92b2db237428470dc4fcfc4ebbd9dc81/2c0cb3284b05 --worker

Configure Services


$SNAP_DATA
/var/snap/microk8s/current

Edit this file:


vi /var/snap/microk8s/current/args/containerd

Restart the service:


sudo systemctl restart snap.microk8s.daemon-containerd.service

Stop and start MicroK8s:


microk8s stop
microk8s start

References