MicroK8s
MicroK8s is a lightweight, pre-packaged Kubernetes distribution which is easy to use and works well for small deployments.
Install
Install MicroK8s 1.19.1 or greater from Snap on all your nodes. https://microk8s.io/
# To install
sudo snap install microk8s --classic --channel=1.22/stable
# Or to upgrade
sudo snap refresh microk8s --classic --channel=1.22/stable
sudo usermod -a -G microk8s jonathan
sudo chown -f -R jonathan ~/.kube
microk8s status --wait-ready
Cluster
Enable microk8s HA mode on all nodes, which allows any of the worker nodes to also behave as a master, instead of just being a worker node. This must be enabled before nodes are joined to the master. https://microk8s.io/docs/high-availability
microk8s enable ha-cluster
Enable microk8s clustering, which allows you to add multiple worker nodes to your existing master node https://microk8s.io/docs/clustering
On the first node:
[jonathan@kube01 ~]$ microk8s add-node
From the node you wish to join to this cluster, run the following:
microk8s join 192.168.0.41:25000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Then execute the join command on the other nodes, to join them to the master. Verify that they are correctly joined:
[jonathan@kube01 ~]$ microk8s kubectl get nodes
NAME STATUS ROLES AGE VERSION
kube02.jonathangazeley.com Ready <none> 27m v1.18.8-33+c9c9e3f85f05f9
kube01.jonathangazeley.com Ready <none> 6d16h v1.18.8-33+c9c9e3f85f05f9
kube03.jonathangazeley.com Ready <none> 86s v1.18.8-33+c9c9e3f85f05f9
Finally make sure that full HA mode is enabled:
[jonathan@kube01 ~]$ microk8s status
microk8s is running
high-availability: yes
datastore master nodes: 192.168.0.41:19001 192.168.0.42:19001 192.168.0.43:19001
datastore standby nodes: none
addons:
enabled:
...
We've already checked that all 3 nodes are up. Now let's make sure pods are being scheduled on all nodes:
[jonathan@kube01 ~]$ kubectl get pods --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
kube-system calico-node-bqqqd 1/1 Running 0 112m 192.168.0.41 kube01.jonathangazeley.com
kube-system calico-node-z4sxd 1/1 Running 0 110m 192.168.0.43 kube03.jonathangazeley.com
kube-system calico-kube-controllers-847c8c99d-4qblz 1/1 Running 0 115m 10.1.58.1 kube01.jonathangazeley.com
kube-system coredns-86f78bb79c-t2sgt 1/1 Running 0 109m 10.1.111.65 kube02.jonathangazeley.com
kube-system calico-node-t5skc 1/1 Running 0 111m 192.168.0.42 kube02.jonathangazeley.com