Training Outcomes Within Your Budget!

We ensure quality, budget-alignment, and timely delivery by our expert instructors.

Share this Resource
Table of Contents

How to Install Kubernetes on Ubuntu

Kubernetes is an open-source container orchestration platform that enables the automatic deployment, scaling, and management of containerised applications. Similarly, Ubuntu is a popular Operating System (OS) often used for application deployment and development. However, before installing, you must ensure your system meets specific prerequisites. These include a compatible Ubuntu version, a working internet connection, sufficient system resources, a user account with sudo privileges, and a disabled swap. Learning how to Install Kubernetes on Ubuntu can allow you to leverage the powerful features of both tools and manage your containerised applications effectively.

According to Statista, Kubernetes has been adopted by over 61% of organisations worldwide untill 2022. If you also wish to start your journey on Kubernetes, Ubuntu is the right OS operating system for this job. Read this blog to learn how to Install Kubernetes on Ubuntu and understand how to install Docker, Kubernetes components and Master, among others. 

Table of Contents 

1) What is Kubernetes?

2) Prerequisite for installation

3) Steps for installation

4) What are the benefits of Kubernetes?

5) Conclusion 

What is Kubernetes?

Kubernetes can be defined as an open-source system which Google developed. It is now overseen by the Cloud Native Computing Foundation (CNCF).This system helps in simplifying container orchestration. This means it helps automatically provision, deploy, scale, and manage containerised applications without fretting over the rudimentary infrastructure. Therefore, it allows developers to build apps with ease. Developers can utilise Kubernetes's container management and scheduling features to dictate application behaviours within a cluster.
 

DEVOPS Training
 

Prerequisite for installation  

Here are some prerequisites that you need you to know before you install Ubuntu:

a) Ubuntu system: Ubuntu is a popular Linux distribution widely used in server environments. You need a system running Ubuntu 18.04 LTS or a more recent version to install Kubernetes. The Long-Term Support (LTS) release ensures stable and well-supported software.  

b) Administrative access: Administrative access or sudo privileges are required to install, configure, and manage software components. Without these privileges, you won't be able to execute critical commands during the Kubernetes setup.  

c) Stable internet connection: A stable and reliable internet connection is necessary to download the required packages and dependencies during installation. A fast and uninterrupted connection will ensure a smooth installation experience.  

d) Linux command line knowledge: Basic knowledge of the Linux command line is essential to navigate the system, execute commands, and configure various components. Familiarity with commands like cd, ls, mkdir, and nano/vim text editors will be beneficial.  

e) Containerisation familiarity: Understanding containerisation concepts, particularly Docker, is crucial for deploying applications with Kubernetes. Docker simplifies packaging applications and their dependencies into containers, making them portable across different environments.  

f) Sufficient storage space: Kubernetes and its components require disk space for storing data, container images, and logs. Allocating a minimum of 20 GB of free disk space is recommended to ensure smooth operation and scalability of the cluster.  

g) Updated system packages: Before installing Kubernetes, updating the system packages is essential. Using the package manager (apt) to update the software will ensure your system has the latest security patches and updates.  

h) Networking understanding: Basic knowledge of networking concepts, such as IP addressing, subnetting, ports, and network protocols (e.g., TCP/IP), helps configure the Kubernetes cluster's networking and handling communication between nodes.  

i) Hardware requirements: The hardware requirements for running Kubernetes vary based on your cluster's size and the number of applications you plan to deploy. However, a system with at least 2 CPU cores and 4 GB of RAM is generally recommended for small-scale deployments. Larger clusters may require more resources for optimal performance. 

Keen on gaining in depth knowledge about Kubernetes, refer to our blog on "Kubernetes Architecture"

Steps for installation  

Ubuntu and Kubernetes are a powerful combination for container orchestration and application deployment. As a popular Linux distribution, Ubuntu provides a stable and reliable operating system foundation. It offers LTS versions, regular security updates, and a vast community support base. Ubuntu's lightweight nature and compatibility with various hardware architectures make it an ideal choice for running Kubernetes.  

Kubernetes is a container orchestration platform that simplifies the management and scaling of containerised applications. It automates tasks such as deployment, scaling, load balancing, and service discovery, enabling efficient utilisation of computing resources.  

Combining Ubuntu as an OS with Kubernetes as the container orchestration platform provides a reliable, scalable, and secure infrastructure for running and managing containerised applications easily and efficiently. To install Kubernetes on Ubuntu, follow these steps: 

Step 1: Updating system packages 

The system refers to the software components and dependencies the operating system requires to support Kubernetes functionality. These packages include libraries, utilities, and tools that enable the proper functioning of the Kubernetes ecosystem, such as networking, container runtime, and cluster management tools. To update the system packages, open a terminal and run the following commands: 

sudo apt update

sudo apt upgrade -y 

These commands will update the package repositories and install the latest updates for your Ubuntu system. 

Step 2: Installing Docker 

Docker is a widely used containerisation platform that allows applications to be packaged and run in isolated environments called containers. It provides an efficient and lightweight way to deploy and manage applications, enabling easier software distribution, scalability, and portability across different operating systems and environments. To install Docker, execute the following commands: 

sudo apt install docker.io -y 

sudo systemctl enable docker 

sudo systemctl start docker 

These commands will install Docker and enable it to start automatically on system boot. 

Try our Kubernetes Training for DevOps Course and learn pods and container management! 

Step 3: Installing Kubernetes components  

Kubernetes components are the essential building blocks of a Kubernetes cluster. They include the Master components (API server, etcd, controller manager, and scheduler) that manage the cluster's control plane and the worker components (kubelet, kube-proxy, and container runtime) that run and manage the containers on worker nodes. These components work together to enable container orchestration and application management in Kubernetes. To install Kubernetes components, run the following commands: 

sudo apt install -y apt-transport-https curl 

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - 

echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list 

sudo apt update 

sudo apt install -y kubelet kubeadm kubectl 

sudo apt-mark hold kubelet kubeadm kubectl 

These commands will add the Kubernetes repository, update the package list, and install the necessary components. 

Step 4: Initialising Kubernetes Master  

Initialising the Kubernetes Master node is crucial in setting up a Kubernetes cluster. It involves running the command on the Master node, which initialises the control plane components, such as the API server, etcd, controller manager, and scheduler.   

The command generates a unique token and a join command that must be executed on worker nodes to join them to the cluster. The initialisation process configures the Master node to manage and orchestrate the Kubernetes cluster. To initialise the Kubernetes Master node, use the following command: 

sudo kubeadm init 

After the initialisation, the command will provide a join command you need to run on the Worker nodes to join them to the cluster. Alternatively, if you wish to install Kubernetes 1.24 on Ubuntu, you can use this command instead: 

sudo swapoff -a 

Kubernetes 1.24 is a stable release of the popular container orchestration platform. It introduces new features, enhancements, and bug fixes. This improves the overall performance and functionality of the Kubernetes ecosystem. The version 1.24, users can leverage advanced capabilities for managing and scaling containerised applications reliably and efficiently.  

Kubernetes requires swap to be disabled on the host machine. The given command will help you disable the swap. You can make the change permanent, comment out the swap entry in the /etc/fstab file. Lastly you can initialise the Kubernetes master as follows: 

sudo kubeadm init --kubernetes-version=1.24.0

sudo kubeadm init --kubernetes-version=1.24.0 

Try our Certified DevOps Security Professional (CDSOP) Course to unleash your potential! 

Step 5: Joining Worker Nodes to the cluster 

A node is a worker machine that runs containerised applications. It is responsible for executing tasks assigned by the Master node. Each node has its capacity for running containers and is managed by the Master node. Multiple nodes form a cluster, enabling distributed deployment and scalability of applications. To join Worker nodes to the Kubernetes cluster, run the join command obtained from the Master node: 

sudo kubeadm join : --token --discovery-token-ca-cert-hash 

Replace , , , and with the appropriate values provided during the initialisation. 

Step 6: Deploying a sample application 

Deploying a sample application in Kubernetes involves creating a deployment manifest file that describes the desired state of the application. This file specifies the container image, replicas, ports, and other configuration parameters.   

The kubectl apply command is then used to apply the manifest file, instructing Kubernetes to create the necessary resources and deploy the application. Once deployed, Kubernetes schedules the application's containers, manages scaling, and ensures high availability based on the specified configuration. To deploy a sample application, create a Kubernetes deployment file and use the kubectl command to apply it, for example: 

kubectl apply -f sample-app.yaml 

This will deploy the sample application described in the YAML file to your Kubernetes cluster. 

Step 7: Scaling and managing applications 

Scaling and managing applications in Kubernetes is a powerful feature that allows you to dynamically adjust the resources allocated to your applications based on demand. With Kubernetes, you can scale your application horizontally by adding or removing replicas, ensuring high availability and efficient resource utilisation.   

Kubernetes also provides features like auto-scaling, rolling updates, and health checks for effective application management and seamless operation. Use kubectl commands to scale the deployed application, manage replicas, perform rolling updates, and monitor the application's health. Explore Kubernetes documentation and resources to learn more about these advanced features.

What are the benefits of Kubernetes?

Here are some benefits of Kubernetes:

a) It automates the scaling process of the applications based on the surge of demand. This allows developers to precisely handle more resources to handle the spikes in traffic and ensure that the resources are utilised efficiently while saving costs for the company.

b) Kubernetes ensure that the applications remain running despite a node failure. It helps in automatically detecting failed containers. In that event, it distributes the workload to other healthier nodes.  This feature of Kubernetes reduces downtime, and the application is available continuously.

c) It helps in distributing resources across several nodes in a cluster. It also schedules containers automatically based on their resource requirements. 

d) As mentioned before, Kubernetes automatically deploys and manages containerised applications. This reduces the downtime, which could have occurred during updates. This automatic deployment and management helps Developers maintain a seamless application upgrade.

e) The Kubernetes applications are portable so users can move them to different Cloud providers with different infrastructure environments. This also helps in on-premises setups without making any significant changes.

f) Kubernetes also employ various security measures to protect containerised applications. These security measures involve isolating containers, enforcing various access control policies and enabling vulnerability scanning to ensure that no security measures are breached.

g) Kubernetes help in resource utilisation and reduce Cloud costs. As they automate scaling and load balancing, overprovisioning can be avoided.

Conclusion 

We hope you enjoyed reading this blog and understood how to Install Kubernetes on Ubuntu systems. Hopefully, you now clearly understand how to set up a Kubernetes cluster, deploy applications and leverage Kubernetes' features within an Ubuntu Operating System. 

Try our Certified SecOps Professional (CSOP) Course to enhance security operations!

Frequently Asked Questions

Upcoming Programming & DevOps Resources Batches & Dates

Date

building Kubernetes Training

Get A Quote

WHO WILL BE FUNDING THE COURSE?

cross
Unlock up to 40% off today!

Get Your Discount Codes Now and Enjoy Great Savings

WHO WILL BE FUNDING THE COURSE?

close

close

Thank you for your enquiry!

One of our training experts will be in touch shortly to go over your training requirements.

close

close

Press esc to close

close close

Back to course information

Thank you for your enquiry!

One of our training experts will be in touch shortly to go overy your training requirements.

close close

Thank you for your enquiry!

One of our training experts will be in touch shortly to go over your training requirements.