Create kubernetes cluster in ubuntu 18.04 using kubeadm (Step By Step)

by Ismail.EL
0 comment

1. What is Kubernetes

kubernetes (commonly stylized as k8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

k8s : technology developed in Google lab in 2005 to manage containerized applications in different kind of environments such as physical, virtual, and cloud infrastructure.

2. Adience

This article is prepared for anyone who want to understand the containerized infrastructure and deployment of application on containers using kubernetes. and will help you to understand the concepts of container management using this technology.

3.Prerequisites

  • An SSH key pair on your local Linux/Mac OS/BSD machine.
  • Three servers running Ubuntu 19.04 with at least 2GB RAM and 2 vCPUs each.

4.Kubernetes Installation

In this article we will use two servers to setting up kubernetes cluster, the first server is considered as master and the second as slave
Both these nodes need to have Kubernetes and docker installed. Therefore, to install kubernetes on both the Ubuntu nodes follow the steps described below:

Step 1 : Install Docker master and slave nodes

Install Docker utility on both the nodes by running the following command as root  user (use sudo) in the Terminal of each node:

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

Step 2: Enable Docker in master and slave nodes

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

Step 3: Add the Kubernetes signing key on both the nodes

Run the following command in order to get the Kubernetes signing key:

If Curl is not installed on your system, you can install it through the following command as root:

Step 4: Add Xenial Kubernetes Repository on both the nodes

Run the following command on both the nodes in order to add the Xenial Kubernetes repository:

Step 5: Install Kubeadm

kubeadm helps you bootstrap a minimum viable Kubernetes cluster that conforms to best practices. With kubeadm, your cluster should pass Kubernetes Conformance tests. Kubeadm also supports other cluster lifecycle functions, such as upgrades, downgrade, and managing bootstrap tokens.

The final step in the installation process is to install Kubeadm on both the nodes through the following command:

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

5. Kubernetes Deployment

Step 1: Disable swap memory (if running) in master and slave nodes

You need to disable swap memory in master/slaves nodes as kubernetes does not perform properly on a system that is using swap memory.
To disable swap memory you can run the following command :

Step 2: Give Unique hostnames to master and slave nodes

Run the following command in the master node:

Run the following command in the slave node:

Step3: Initialize Kubernetes on the master node

Run the following command as sudo on the master node:

The process might take a minute and the output of this command is very important:

To start using your cluster, you need to run the following as a regular user:

You can check the status of the master node by running the following command:

Firstly, you will see that the status of the master node is “not ready” yet. It is because no pod has yet been deployed on the master node and thus the Container Networking Interface is empty.

Then you can join any number of worker nodes by running the following on each as root:

Step 4: Deploy a Pod Network through the master node

A pod network is a medium of communication between the nodes of a network. In my case i use Flannel pod network:

flannel is a virtual network that gives a subnet to each host for use with container runtimes.

Use the following command in order to view the status of the network:

After deploying flannel pod network Now when you see the status of the nodes, you will see that the master-node is ready:

Step 5: Add the slave node to the network in order to form a cluster

Now we have master node is up and cluster is ready and configued, we can add slaves nodes to cluster.
On the slave node you can run the following command you generated while initializing Kubernetes on the master-node-k8s (Step3: Initialize Kubernetes on the master node):

After adding first slave node to cluster you can see a second node in cluster nodes list, to verify that you run the following command on the master node, it will confirm that two nodes, the master node, and the server nodes are running on your cluster kubernetes :

6. Conclusion

In this post, i have explained the installation of the Kubernetes cluster on two Ubuntu nodes.
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂

4240cookie-checkCreate kubernetes cluster in ubuntu 18.04 using kubeadm (Step By Step)

Related Posts

Leave a Comment