Microk8s - The deadly simple Kubernetes cluster
Low resource, Zero-ops and Production ready Kubernetes cluster
Kubernetes and The Cloud Native
Hi all, in this article, I am going to share my interesting journey while I seek and compare some Kubernetes cluster enablers. We know in the current cloud-based era, we might need to have a tough local Kubernetes cluster with a lot of similarities to cloud-based such as Google Kubernetes Engine (GKE) from Google Cloud Platform, or Amazon Elastic Kubernetes Service (EKS) from Amazon Web Service even some cool stuff from Azure which is Azure Kubernetes Service (AKS).
There are a lot of solutions for local Kubernetes development, such as Minikube, Kind, or the popular k3s. Maybe we want to create from scratch using Kubeadm, Kops or Kubespray. We have all the tools needed for that. Along my way in the seek for the fittest solution I came to a tool provided by the mighty Canonical, which is known for the most popular Linux distro (Ubuntu). It is Microk8s with its tempting tagline on its official website The lightweight Kubernetes: Zero-ops, pure-upstream Kubernetes, from developer workstations to production. Let's take a look then.
What is Microk8s
So, Microk8s is a self-managed Kubernetes cluster made by Canonical, which claimed to be lightweight, zero-ops, pure-upstream Kubernetes. It is designed for any stakeholder such as a Developer, DevOps and Software Vendor. It came with a lot of features and benefits, so every user will only need to focus on what to be deployed instead of struggling with the complex network and depth of internal infrastructure and configuration.
Features
It is super lightweight, as a comparison in this link, microk8s only need 540MB of memory to run the cluster.
Batteries included for a minimal complete setup, we might enable a lot of brought by their features such as Calico, Cilium, CoreDNS, Traefik, NGINX, Ambassador, Multus, MetalLB, Hostpath storage, OpenEBS, Ceph, Helm, Kubernetes Dashboard, Prometheus and so on. We can simply enable and disable them effortlessly.
Powered with containerd and kata for its container runtime, which is used by Kubernetes native instead of Docker which needs shim for its engine.
High Available and Multi node cluster support in a simple single command. Automatic, autonomous and self-healing HA. For more detail on its HA explanation click here.
CNCF-certified by nature, Get all Kubernetes services in a single, fully contained package.
Automatic security updates and streamlined upgrades.
Let's jump to more technical stuff and know more about the implementations.
Installation
The installation for Microk8s is very easy, for Linux users just need to have snap or snap store installed in their distribution.
For windows, it came with its installer which can be downloaded here then click to install.
For macOS no other it is just usual homebrew.
Since I am using Linux (ubuntu) I will continue with the example using it. The installation is pretty straightforward
sudo snap install microk8s --classic
Checking status
microk8s status --wait-ready
as we can see the output when running the command below on my Linux. It will show enabled and available features to be enabled brought by the microk8s itself.
Start and Stop
microk8s start
microk8s stop
To save your resource when you don't want to use it
Join usergroup
this is used to avoid using sudo while executing the microk8s command
sudo usermod -aG microk8s $USER
refresh the terminal session using these commands newgrp microk8s
or su - $USER
Generate cluster config
microk8s config
as we can see in the image below, it's displaying the configuration manifest of the Kubernetes cluster made of Microk8s. It will be very useful when we want to extend its functionality as a native Kubernetes cluster, so we could access the cluster externally using kubectl command.
Accessing Kubernetes
It came with built-in kubectl which can be accessed through this command microk8s kubectl
for example
# list all nodes
microk8s kubectl get nodes
# list all services of namespace
microk8s kubectl get services -n <namespace>
# list all namespaces
microk8s kubectl get namespace
# getting all element from all namespace
microk8s kubectl get all -A
The command is similar to the native kubernetes kubectl command.
Or if you want more seamless native kubectl command execution. We can generate microk8s cluster configuration into the default kubernetes configuration file. Usually, on linux it located at ~/.kube/config
so to do that you can just easily execute this command
microk8s config > ~/.kube/config
After that, you can access your microk8s cluster through direct kubectl command without microk8s prefix.
Troubleshoot
They had a super easy way to troubleshoot microk8s daemon and its component. Just execute microk8s inspect
and it resulting a very comprehensive checking through every dependency needed to run.
So, that was fun and easy to play with. have a good playtime with a new toy!!!
Well, just sit tight and wait for my next series of kubernetes trial experiences with microk8s. Also, there will be a lot of tips and tricks.