How to Install Kubernetes on Ubuntu 18.04 Bionic Beaver

Install Kubernetes on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure Kubernetes on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Kubernetes is a free and open-source container management system that provides a platform for deployment automation, scaling, and operations of application containers across clusters of host computers. With Kubernetes, you can freely make use of the hybrid, on-premise, and public cloud infrastructure in order to run deployment tasks of your organization.

Install Kubernetes on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install Docker.

Install Docker with the command:

You can verify the installation and also check the version number of Docker through the following command:

Enable the Docker utility on both the nodes by running the following command on each:

Step 2. Installing Kubernetes.

First, Add Kubernetes Signing Key:

Next, Add Software Repositories:

Kubeadm (Kubernetes Admin) is a tool that helps initialize a cluster. It fast-tracks setup by using community-sourced best practices. Kubelet is the work package, which runs on every node and starts containers. The tool gives you command-line access to clusters:

Verify the installation with:

Step 3. Kubernetes Deployment.

Begin Kubernetes Deployment, Start by disabling the swap memory on each server:

Assign Unique Hostname for Each Server Node:

Next, set a worker node hostname by entering the following on the worker server:

Step 4. Initialize Kubernetes on Master Node.

Switch to the master server node, and enter the following:

Once this command finishes, it will display a kubeadm join message at the end. Make a note of the whole entry. This will be used to join the worker nodes to the cluster. Then, enter the following to create a directory for the cluster:

Step 5. Deploy Pod Network to Cluster.

A Pod Network is a way to allow communication between different nodes in the cluster. This tutorial uses the flannel virtual network:

Verify that everything is running and communicating:

Step 6. Join Worker Node to Cluster.

Switch to the worker01 system and enter the command you noted from Step 3:

Replace the alphanumeric codes with those from your master server. Repeat for each worker node on the cluster. Wait a few minutes. then you can check the status of the nodes and Switch to the master server, and enter:

That’s all you need to do to install Kubernetes on Ubuntu 18.04 LTS. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.