Kubernetes

How to Install Kubernetes on Ubuntu Single Node

Containers, Kubernetes, and IoT/edge applications are playing an extremely important role in enterprise digital transformation. They are especially important for DevOps teams working to accelerate software releases and improve IT operations through integration and optimization. The majority of cloud-native software is user-friendly, allowing many developers to contribute and customize the relevant software. This has resulted in simplified Kubernetes versions with small footprints that are ideal for IoT/edge tasks.

MicroK8s creates a certified Kubernetes cluster from a single node in minutes. Canonical’s Microk8s Kubernetes distribution is small, versatile, and lightweight  It’s an uncluttered distribution with an emphasis on improving performance and usability. Microk8s can usually be configured in IoT and edge devices due to their small size.

MicroK8s is designed to run on any Linux distribution. It’s thin and compact, deploying all Kubernetes services on Ubuntu while also including all of the necessary libraries. Because of its tiny footprint, it’s ideal for tablets, desktops, CI pipelines, IoT cameras, and small edge clouds.

Pre-requisites

  • Ubuntu 20.04 LTS or any other version of Ubuntu.
  • A stable internet connection
  • Sudo privileges

Installation of Microk8s on Ubuntu 20.04 LTS

For installing Microk8s on Ubuntu 20.04 LTS, open the terminal by using the shortcut key as “CTRL+ALT+T”. As soon as you see the terminal screen of Ubuntu, follow the listed basic steps for installation.

Step 1: Install Microk8s using snap package
MicroK8s is released as a snap, which necessarily involves the installation of snapd. This is already included in the most recent Ubuntu version. To have the most recent version of MicroK8s, type the following command:

:~$ sudo snap install microk8s –classic

As soon as you execute the command in the terminal, you will see that it will start downloading microk8s.

Depending upon your internet speed, the installation will be accomplished, and on your terminal, you will see a message indicating that the installation was successful.

From the above-displayed image, you can check that v1.20.5 has been installed on your Ubuntu 20.04 LTS.

Step 2:  List different versions of Microk8s on your Ubuntu 20.04
To list all available versions of miccrok8s, you can use the following snap command.

:~$ snap info microk8s

As soon as you execute the command mentioned above, you will see different versions of Microk8s displayed on your Ubuntu 20.04 terminal.

Step 3: View Status of installed Microk8s
After installation, you have to check the status of installed microk9s. The status of MicroK8s can be viewed using an already built-in command available in Ubuntu 20.04. For this specific purpose, you have to execute the below-mentioned command in your terminal simply.

:~$ microk8s status --wait-ready

Note: You have to write the “–wait-ready” flag during installation to wait for  services of the Kubernetes to get started:

During the execution of this command, it is suggested not to quit the terminal and wait for the Kubernetes to start their services.

You can see that microk8s is running, and it is available for further work.

Step 4: Accessing Kubernetes
Now it is the most important step to access Kubernetes. For accessing Kubernetes, MicroK8s includes its edition of kubectl. It can be used to operate commands that will track and manage your Kubernetes cluster. If you want to view your current node, you must execute the following specified command in the terminal.

:~$ microk8s kubectl get nodes

From the above-displayed image, you can view that the status is “Ready”. You can also view the Name, roles, age, and version of the node by executing this command.

Step 5: View Running services
If you want to view the running services of microk8s, you can check it by the following below-mentioned command:

:~$ microk8s kubectl get services

You can see the name, type, Cluster-ip, external-ip, port(s), and age of the running services by executing this command.

Step 6: Deployment of the application using mickro8s
Kubernetes is a container management system for deploying applications and services. In the below-mentioned example, we are deploying an application of Ngnix by using kubectl. You can deploy any other app by using the same command. The most vital point is to replace your desired application name with Ngnix.

Type this command for the successful deployment of Ngnix:

:~$ microk8s kubectl create deployment nginx --image=nginx

From the image shown above, you can see that application has been deployed.

Step 7: Check the version of kubectl
To verify the successful installation of Kubernetes, you can check its version by typing the below-mention command in the terminal.

:~$ kubectl version

Additional Commands

If you are confused in writing different commands related to kubectl, you can check some basic commands of kubectl by executing the following command:

:~$ kubectl --help

Conclusion

Finally, you are done with the installation of Kubernetes on Ubuntu 20.04 single node. In this guide, we tried our best to explain all the steps that are essentially required for the installation. However, we also teach you about the deployment of applications in Kubernetes using kubectl.

About the author

Kalsoom Akhtar

Hello, I am a freelance writer and usually write for Linux and other technology related content