Clustering with MicroK8s
Note: Each node on a MicroK8s cluster requires its own environment to work in, whether that is a separate VM or container on a single machine or a different machine on the same network. Note that, as with almost all networked services, it is also important that these instances have the correct time (e.g. updated from an ntp server) for inter-node communication to work.
Adding a node
To create a cluster out of two or more already-running MicroK8s instances, use the microk8s add-node
command. The MicroK8s instance on which this command is run will be the master of the cluster and will host the Kubernetes control plane:
microk8s add-node
This will return some joining instructions, such as:
Join node with:
microk8s join ip-172-31-20-243:25000/DDOkUupkmaBezNnMheTBqFYHLWINGDbf
If the node you are adding is not reachable through the default
interface you can use one of the following:
microk8s join 10.1.84.0:25000/DDOkUupkmaBezNnMheTBqFYHLWINGDbf
microk8s join 10.22.254.77:25000/DDOkUupkmaBezNnMheTBqFYHLWINGDbf
The add-node
command prints a microk8s join
command which should
be executed on the MicroK8s instance that you wish to join to the
cluster (NOT THE NODE YOU RAN add-node
FROM):
microk8s join ip-172-31-20-243:25000/DDOkUupkmaBezNnMheTBqFYHLWINGDbf
Joining a node to the cluster should only take a few seconds. Afterwards
you should be able to see the node has joined:
microk8s kubectl get no
NAME STATUS ROLES AGE VERSION
10.22.254.79 Ready <none> 27s v1.15.3
ip-172-31-20-243 Ready <none> 53s v1.15.3
Removing a node
First, on the node you want to remove, run microk8s leave
. MicroK8s on the departing node
will restart its own control plane and resume operations as a full single node cluster:
microk8s leave
To complete the node removal, call microk8s remove-node
from the remaining nodes to
indicate that the departing (unreachable now) node should be removed permanently:
microk8s remove-node 10.22.254.79
High Availability
From the 1.19 release of MicroK8s, HA is enabled by default. If your cluster consists of three or more nodes, the datastore will be replicated across the nodes and it will be resilient to a single failure (if one node develops a problem, workloads will continue to run without interruption).
The microk8s status
now includes information about the HA state. For example:
microk8s is running
high-availability: yes
datastore master nodes: 10.128.63.86:19001 10.128.63.166:19001 10.128.63.43:19001
datastore standby nodes: none
For more information about how HA works, and how to manage an HA cluster, please see the High Availability page.
Last updated 4 months ago. Help improve this document in the forum.