Showing posts with label microk8s. Show all posts
Showing posts with label microk8s. Show all posts

Oct 20, 2022

Start MicroK8s with Multipass

This post is for me to learn how to create a highly available Kubernetes cluster using the MicroK8s and multipass.

Kubernetes clusters host containerised applications in a reliable and scalable way. Having DevOps in mind, Kubernetes makes maintenance tasks such as upgrades and security patching simple.

MicroK8s is a zero-ops, CNCF certified lightweight Kubernetes distribution for workstations, clusters, edge and IoT devices.

Again, the prerequisite is  there must be a working copy multipass, and I'm using WSL. 😎

Here are the setup configuration:

$ multipass launch --name kmaster -m 4G

$ multipass shell kmaster

ubuntu@kmaster:~$ sudo snap install microk8s --classic

ubuntu@kmaster:~$ sudo usermod -a -G microk8s ubuntu
ubuntu@kmaster:~$ sudo chown -f -R ubuntu ~/.kube

ubuntu@kmaster:~$ exit

$ multipass shell kmaster  

ubuntu@kmaster:~$ microk8s status --wait-ready

Next, let setup a second node:

$ multipass launch --name kworker1 -m 4G

$ multipass shell kworker1

ubuntu@kworker1:~$ sudo snap install microk8s --classic

ubuntu@kworker1:~$ sudo usermod -a -G microk8s ubuntu
ubuntu@kworker1:~$ sudo chown -f -R ubuntu ~/.kube

ubuntu@kworker1:~$ exit

$ multipass shell kworker1

ubuntu@kworker1:~$ microk8s status --wait-ready

 Both nodes are ready, let's join them:

$ multipass exec kmaster -- microk8s add-node

From the node you wish to join to this cluster, run the following:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2

Use the '--worker' flag to join a node as a worker not running the control plane, eg:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2 --worker

If the node you are adding is not reachable through the default interface you can use one of the following:
microk8s join 172.22.71.179:25000/daaad28e6febfbdaa5e228479e5f3f7c/8ee2423760f2

Copy the line (in bold) and paste to the second node (kworker), and wait for a few minutes.