Microk8s is one of the coolest small Kubernetes distros you can play around with and it is not just for playing around, it is actually built for running production workloads in the cloud. But, it can also serve as the platform you use in your home lab for running Kubernetes and getting familiar with it. Let’s look at Microk8s for beginners and how it can be installed and configured.
What is Microk8s?
Microk8s is a very lightweight Kubernetes distribution from Canonical (same people that make Ubuntu) that provides a platform for not just testing and development, but also for production workloads. It is super easy to install and it can easily setup a HA cluster and install add-ons as you need.
Canonical bills it as a production-ready Kubernetes version that is CNCF-certified. You get automatic security updates and upgrades with Microk8s as well. For production environments, it has some pretty appealing benefits. Those are:
- 99.9% uptime SLA
- 10-year security maintenance
- over the air updates
Compared to Minikube, k3s, and others
I really like Microk8s compared to Minikube. I think it is less complicated to setup and it is production ready Kubernetes where Minikube is not. Minikube is only for single-node Kubernetes installs.
I think k3s is honestly a very good Kubernetes distro that compares to microk8s. However, Microk8s is still a little less complex than k3s, even though k3s can be installed with a single binary. Canonical has made microk8s pretty rock solid from an operational standpoint.
Microk8s add ons
One of the really cool things about Microk8s is the fact that you can easily install add-ons with the microk8s enable <add on>
command. You can see the available list of Microk8s addons and which ones are enabled with the microk8s status
command.
This really makes it much easier to add services and configurations to the Microk8s cluster as it is just a simple one-liner command you run from the prompt.
There are a few core services that are enabled when you install Microk8s. These include:
- DNS
- ha-cluster
- helm
- helm3
These are available to be added:
- cert-manager
- cis-hardening
- community
- dashboard
- GPU
- host-access
- hostpath-storage
- ingress
- kube-ovn
- mayastor
- metallb
- metrics-server
- minio
- nvidia
- observability
- prometheus
- rbac
- registry
- rook-ceph
- storage
How do you install Microk8s?
You can install Microk8s very easily. In fact, with a single-line command in Ubuntu, using the following:
sudo snap install microk8s --classic
Is possible to install in Windows Subsystem for Linux (WSL)
You can also install Microk8s inside of Windows Subsystem for Linux as well which makes it a great way to play around with Kubernetes even on a workstation machine that you have running with WSL installed.
I am using an Ubuntu Server 24.04 LTS WSL instance and it works just fine with the normal installation command without issue.
Setting up an alias for microk8s kubectl
One thing you will note with microk8s kubectl is that you have to issue the explicit command microk8s kubectl
to run kubectl commands. Many who work with Microk8s quite a bit will set up an alias for that command so they can just issue a simpler command like mkctl.
alias mkctl="microk8s kubectl"
Check the status of microk8s
After you install Microk8s, it should start the cluster, you can check the status:
sudo microk8s status --wait-ready
Start a Microk8s cluster
You can easily start a Microk8s cluster if stopped with the command:
sudo microk8s start
Stop a Microk8s cluster
You can stop your Microk8s cluster if needed using the command:
sudo microk8s stop
Reset your Microk8s cluster
If you have issues with your Microk8s cluster, you can reset the cluster using the command:
sudo microk8s reset
Enabling the Microk8s dashboard
As an example of enabling an add-on, you can enable the Microk8s dashboard using the command below:
sudo microk8s enable dashboard
Adding a node to your microk8s Kubernetes cluster
The command to add a node couldn’t be much simpler, it is the command:
microk8s add-node
This will create a join string you will need to use to join another node to the cluster. You will use this with the microk8s join
command for adding the node.
Joining a node
Now that we have the join token that we need to use, we can join another node using the command:
microk8s join <your master node and token string>
Fully automated with Portainer
Another tool to mention that works great with Microk8s is Portainer. If you add an environment in Portainer, you will see the option for Create a Kubernetes cluster on existing infrastructure. Basically, with this option, you provide Portainer with 3 Linux virtual machines and it will do the rest by installing Microk8s, configuring clustering, and will bring in the cluster as part of your Portainer environments you can manage.
Wrapping up
Hopefully, this Microk8s for beginners install and configuration guide will help any who are looking to start playing around with Microk8s in the home lab or development environment. It doesn’t take long to get familiar with microk8s and it is a great distro for production, development, and the home lab. Let me know if you are using Microk8s in your lab environment.