Below is a process to install the Kubernetes cluster on three nodes. with MicroK8s.
+ Deploying MicroK8s on node 1, node 2, and node 3
![](https://tungle.ca/wp-content/uploads/2022/03/image-39-1024x206.png)
Install MicroK8s directly from the snap store.
sudo apt install snapd
![](https://tungle.ca/wp-content/uploads/2022/03/image-40.png)
To follow a specific upstream release series it’s possible to select a channel during installation, for example, v1.18 series.
sudo snap install microk8s --classic --channel=1.18/stable
![](https://tungle.ca/wp-content/uploads/2022/03/image-41.png)
Configure your firewall to allow pod-to-pod and pod-to-internet communication.
sudo ufw allow in on cni0 && sudo ufw allow out on cni0
sudo ufw default allow routed
![](https://tungle.ca/wp-content/uploads/2022/03/image-42.png)
Dashboard, core-dns, or local storage can be enabled by running the microk8s enable
command:
microk8s enable dns dashboard storage
sudo usermod -a -G microk8s tung
sudo chown -f -R tung ~/.kube
newgrp microk8s
![](https://tungle.ca/wp-content/uploads/2022/03/image-43.png)
![](https://tungle.ca/wp-content/uploads/2022/03/image-44-913x1024.png)
Get the output of the first node.
![](https://tungle.ca/wp-content/uploads/2022/03/image-45.png)
Get token.
![](https://tungle.ca/wp-content/uploads/2022/03/image-46.png)
Copy and paste the token on the following screenshot.
![](https://tungle.ca/wp-content/uploads/2022/03/image-47.png)
Kubernetes dashboard.
![](https://tungle.ca/wp-content/uploads/2022/03/image-48-950x1024.png)
Get status of mircok8s service.
![](https://tungle.ca/wp-content/uploads/2022/03/image-49.png)
Do previous steps on node 2 and node 3. We do not need to install dashboard service on node 2 and node 3.
![](https://tungle.ca/wp-content/uploads/2022/03/image-50.png)
![](https://tungle.ca/wp-content/uploads/2022/03/image-52.png)
+ Create a MicroK8s multi-node cluster.
Now let’s focus on creating the Kubernetes cluster. On the first node run a command below.
microk8s add-node
This command will give you the following output:
![](https://tungle.ca/wp-content/uploads/2022/03/image-53.png)
On node 2, join the cluster.
![](https://tungle.ca/wp-content/uploads/2022/03/image-54.png)
Repeat this process (including generating a token, run it from the joining node) for the third node.
![](https://tungle.ca/wp-content/uploads/2022/03/image-55.png)
![](https://tungle.ca/wp-content/uploads/2022/03/image-56.png)
+ Deploy a sample containerized application
Let’s now create a microbot deployment with three pods via the kubectl cli. Run this on any of the control plane nodes:
microk8s kubectl create deployment microbot --image=dontrebootme/microbot:v1
microk8s kubectl scale deployment microbot --replicas=3
To expose our deployment we need to create a service:
microk8s kubectl expose deployment microbot --type=NodePort --port=80 --name=microbot-service
After a few minutes, check your cluster.
![](https://tungle.ca/wp-content/uploads/2022/03/image-57-908x1024.png)
Check IP address of the K8S node.
![](https://tungle.ca/wp-content/uploads/2022/03/image-58-912x1024.png)
Access micro-bot service via the port 30711.
![](https://tungle.ca/wp-content/uploads/2022/03/image-59.png)
Kubernetes dashboard.
![](https://tungle.ca/wp-content/uploads/2022/03/image-60.png)