Kubernetes is an open-source container management technology initially developed by Google. It is used for managing containerized applications or services in different kinds of environment such as virtual, physical and cloud infrastructure, automating deployment and scaling.
Generally, Kubernetes cluster would have a master node and minions (worker-nodes). These individual worker-nodes are managed from the master node, as the control of the overall system is centralized.
For installation, one has flexible options. You can deploy a single-node Kubernetes cluster or multi-node Kubernetes cluster. Single-node, in general, is recommended for creating lightweight workloads to develop microservices locally.
In this tutorial, I will guide you to install single-node Kubernetes using Microk8s on Ubuntu 19.10. This procedure also works on other versions of Ubuntu like 16.04 and 18.04 LTS systems.
Note: We are going to install a single-node Kubernetes cluster in a virtual machine on our node.
Installing Kubernetes on Ubuntu
Kubernetes on Ubuntu is free to use and unlike other Linux distribution, you get the latest version along with the innovations from the Kubernetes community within a few days.
MicroK8s is a tool that installs a single-node Kubernetes cluster in no time. It is supported across all Linux distribution. It’s lightweight and deploys all Kubernetes services natively on Ubuntu (which means no virtual machines required).
It is best suited for laptops, workstations, CI pipelines, IoT devices, and small edge clouds because of its small space.
Unlike installing through apt-get, microk8s is packaged as snap which requires snapd to be installed. In newer systems, it comes built-in. For other Linux systems, you have to install snapd first.
sudo apt install snapd
After this, install microk8s using the following command:
sudo snap install microk8s --classic
This installs the latest stable release of microk8s.
To check whether it has successfully installed or not, you need to verify by:
microk8s.status

The above output shows that you have successfully installed the microsk8s.
Configuring Kubernetes
Before using Kubernetes, there are certain things one needs to perform.
MicroK8s creates a group to enable uninterrupted usage of commands which require administrative privilege. To add your current user to the group, run the following:
sudo usermod -a -G microk8s $USER
After that, you need to re-enter the session using the following:
su - $USER
Accessing Kubernetes
To access Kubernetes, we use the following command:
microk8s.kubectl
MicroK8s bundles its own version of kubectl for accessing Kubernetes. We use it to run commands to monitor and control our Kubernetes. For example, to view your node:
microk8s.kubectl get nodes

During installation, microk8s embeds a kubectl and a .kubeconfig file required for accessing the installed Microk8s.
If, in any case, you have already installed a local version of it then this file avoids colliding with the local version.
If you would like to use the MicroK8s kubectl and .kubeconfig file locally, you can do the following:
sudo snap alias microk8s.kubectl kubectl
microk8s.kubectl config view --raw > $HOME/.kube/config
Deploying an App
As we know, Kubernetes is meant for deploying apps and services. To fulfill that purpose, we use kubectl command.
In this example, we will try to install a demo app:
microk8s.kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
It may take a few minutes to install, but you can check the status using the following command:
kubectl get pods

Starting and Stopping MicroK8s
You can manually start the Microk8s using the following command:
microk8s.start
This command starts the Microk8s and its services. To stop it along with its services, use the following command:
microk8s.stop
Use Add-Ons
Although MicroK8s uses the minimum of components for a pure, lightweight Kubernetes, there are plenty of extra features available with “add-ons” – pre-packaged components that will provide extra capabilities for your Kubernetes, from simple DNS management to machine learning with Kubeflow.
To start, it is recommended to add DNS management to facilitate communication between services. For applications which need storage, the ‘storage’ add-on provides directory space on the host which can be set up as follows:
microk8s.enable dns storage

To learn more about add-ons, refer to the official Microk8s documentation.
Conclusion
Kubernetes is an extensive and portable platform to manage microservices and containers.
MicroK8s is great for offline development, prototyping, and testing. The smallest, fastest Kubernetes that makes clustering trivial can be used on a VM as a cheap, reliable k8s for CI/CD. It is the best Kubernetes for appliances to develop IoT apps and deploy them to MicroK8s on your Linux boxes.
To know more about Microk8s, refer to the official documentation.

Kushal Rai
A computer science student & Linux and open source lover. He likes sharing knowledge for he believes technology shapes the perception of modern world. Kushal also loves music and photography.