Kubernetes, also known as K8S, is the most popular container orchestration tool. It is fully open source. Kubernetes allows you to automatically deploy, scale and manage containerized applications.
In this guide, you will learn how to set up a single node kubernetes cluster using MicroK8S. The guide is a first of several in this series that are intended to make is easy for you to run applications in kubernetes. We will set up the cluster, set up Longhorn as our storage solution, deploy WordPress and have it run securely using https by issueing a Lets Encrypt SSL
But first, lets get started with initial set up.
Prerequisites
Our cluster will utilize popular FOSS, tells you just how much you can do with FOSS:
- Ubuntu 20.04
- Server with at least 4GB RAM, 2 Core, 50GB Storage, In our case, we’ll use 8GB RAM, 4 core, 200 SSD Storage
- Root access to the server
- A domain name (get affordable domains from as low as $1 from Truehost Cloud)
1.Login to the server and Update
root@vmi663745:~# apt update
2.Install Snap
root@vmi663745:~# apt install snapd -y
3.Install needed packages from Snap
i)Install microk8s from Canonical using snap
root@vmi663745:~# snap install microk8s --classic --channel=latest/stable 2021-10-11T15:09:06+02:00 INFO Waiting for automatic snapd restart…microk8s v1.22.2 from Canonical✓ installed
root@vmi663745:~#
ii)Install Helm, the kubernetes package manager from Snapcrafters
root@vmi663745:~# snap install helm --classic
helm 3.7.0 from Snapcrafters installed
root@vmi663745:~#
iii) Install kube-apiserver
root@vmi663745:~# snap install kube-apiserver
kube-apiserver 1.22.2 from Canonical✓ installed
root@vmi663745:~#
4. Enable crucial kubernetes services
root@vmi663745:~# microk8s.enable storage ingress dns
This command enables microk8s storage called microk8s-hostpath, then enables Nginx Ingress controller for external access and finally enables Coredns, which handles dns routing within the cluster.
5. [OPTIONAL]. You can configure your cluster on an IDE to simplify managing it. I like Lens
To configure the cluster on Lens, you first need to get the Kubeconfig
root@vmi663745:~# microk8s.kubectl config view --raw
You can then configure it on your Lens IDE under Cluster section. Please check out the docs or demo at Lens website to better understand the steps of configuring the cluster on your Lens IDE.
Conclusion
The above set up should get you up and running, ready to deploy your database and applications. However, the default storage provider used, microk8s-hostpath, is not recommended for production use case. There are other better performing, feature full storage providers available. When selecting a storage provider, there are various factors to consider including dynamic provisioning, ability to take snapshots, performance (IO throughput) etc. Consider this article for a detailed comparison of various popular production storage providers
One such storage provider is Longhorn. Lets see how add Longhorn storage provider on our set up above. Please read on…