• Home
  • DevOps
  • Tutorials
  • Web
  • Cloud
  • Monitoring
  • How TO
  • OS
    • Linux OS
    • Mac OS
    • Windows OS
  • Security
  • About Us
devops-team.net
Menu
  • Home
  • DevOps
  • Tutorials
  • Web
  • Cloud
  • Monitoring
  • How TO
  • OS
    • Linux OS
    • Mac OS
    • Windows OS
  • Security
  • About Us
Home  /  DevOps  /  Create kubernetes cluster in ubuntu 18.04 using kubeadm (Step By Step)
To Create a Kubernetes Cluster Using Kubeadm on Ubuntu 18.04
09 November 2019

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

Written by Ismail.EL
DevOps Cloud, Containerization, DevOps, Docker, Dockerization, Linux, Open Source Leave a Comment

Contents

  • 1. What is Kubernetes
  • 2. Adience
  • 3.Prerequisites
  • 4.Kubernetes Installation
    • Step 1 : Install Docker master and slave nodes
    • Step 2: Enable Docker in master and slave nodes
    • Step 3: Add the Kubernetes signing key on both the nodes
    • Step 4: Add Xenial Kubernetes Repository on both the nodes
    • Step 5: Install Kubeadm
  • 5. Kubernetes Deployment
    • Step 1: Disable swap memory (if running) in master and slave nodes
    • Step 2: Give Unique hostnames to master and slave nodes
    • Step3: Initialize Kubernetes on the master node
    • Step 4: Deploy a Pod Network through the master node
    • Step 5: Add the slave node to the network in order to form a cluster
  • 6. Conclusion

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:

1
sudo apt install docker.io

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

1
docker --version

Step 2: Enable Docker in master and slave nodes

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

1
sudo systemctl enable docker

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

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

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

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

1
sudo apt install curl

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:

1
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"

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:

1
sudo apt install kubeadm

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

1
kubeadm version

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 :

1
sudo swapoff -a

Step 2: Give Unique hostnames to master and slave nodes

Run the following command in the master node:

1
sudo hostnamectl set-hostname master-node-k8s

Run the following command in the slave node:

1
hostnamectl set-hostname slave-node-k8s

Step3: Initialize Kubernetes on the master node

Run the following command as sudo on the master node:

1
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

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:

1
mkdir -p $HOME/.kube<br>sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config<br>sudo chown $(id -u):$(id -g) $HOME/.kube/config

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

1
kubectl get node

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:

1
kubeadm join 192.168.43.59:6443 --token vphcvu.bezen1rxiwsmyfg0 --discovery-token-ca-cert-hash sha256:476f497c72ce84839d4edbed0dd0a613b073371c3578e6dbbd03d8b59fdfb151

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.

1
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

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

1
sudo kubectl get pods --all-namespaces

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

1
sudo kubectl get nodes

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):

1
kubeadm join 192.168.43.59:6443 --token vphcvu.bezen1rxiwsmyfg0 --discovery-token-ca-cert-hash sha256:476f497c72ce84839d4edbed0dd0a613b073371c3578e6dbbd03d8b59fdfb151

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 :

1
sudo kubectl get nodes

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 🙂

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

If you found this post useful for you, please share it on
Share on Facebook
Share on Twitter
Share on Google+
Share on LinkedIn
Share on Whatsapp
Ismail.EL

I’m Ismail El. Welcome To devops-team website! • I'm Cloud/DevOps Consultant. I have rich experience in Linux engineer, Cloud and DevOps... • currently a content creator for devops-team, who loves working with computers and strongly believes in sharing knowledge..

 Previous Article What is Kubernetes – The Concepts and architecture ?
Next Article   How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS

Related Posts

  • what is jenkins 2019

    What is Jenkins ?

    November 19, 2019
  • How to Install Kubernetes using Minikube Linux, Mac and Windows

    How to Install Kubernetes (k8s) using Minikube Linux, Mac and Windows

    November 13, 2019
  • How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS

    How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS

    November 11, 2019
  • what is kubernetes

    What is Kubernetes – The Concepts and architecture ?

    October 20, 2019
  • What DevOps Means?

    December 23, 2018

Leave a Reply

Cancel reply

about devops 2019
  • Popular Posts
  • Recent Posts
  • How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS
    How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS Ismail.EL DevOps
  • How to Install Kubernetes using Minikube Linux, Mac and Windows
    How to Install Kubernetes (k8s) using Minikube Linux, Mac and Windows Ismail.EL DevOps
  • What DevOps Means? Ismail.EL DevOps
  • Build a Java app with Maven using Jenkins Pipeline Ismail.EL DevOps
  • what is jenkins 2019
    What is Jenkins ? Ismail.EL DevOps
  • To Create a Kubernetes Cluster Using Kubeadm on Ubuntu 18.04
    Create kubernetes cluster in ubuntu 18.04 using kubeadm (Step By Step) Ismail.EL DevOps
  • what is kubernetes
    What is Kubernetes – The Concepts and architecture ? Ismail.EL DevOps
  • How To install and configure Prometheus on Linux Ismail.EL DevOps, Monitoring, Prometheus
  • Install Jenkins on Ubuntu 18.04 Ismail.EL CI/DI, Continues Integration, Depoloyment Integration, DevOps, Jenkins
  • DevOps practices that you must implement in 2019 Ismail.EL DevOps
  • Kubernetes ComponentKubernetes Component Ismail.EL DevOps
  • Build a Java app with Maven using Jenkins Pipeline Ismail.EL DevOps
  • what is jenkins 2019
    What is Jenkins ? Ismail.EL DevOps
  • How to Install Kubernetes using Minikube Linux, Mac and Windows
    How to Install Kubernetes (k8s) using Minikube Linux, Mac and Windows Ismail.EL DevOps
  • How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS
    How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS Ismail.EL DevOps
  • To Create a Kubernetes Cluster Using Kubeadm on Ubuntu 18.04
    Create kubernetes cluster in ubuntu 18.04 using kubeadm (Step By Step) Ismail.EL DevOps
  • what is kubernetes
    What is Kubernetes – The Concepts and architecture ? Ismail.EL DevOps
  • How To install and configure Prometheus on Linux Ismail.EL DevOps, Monitoring, Prometheus
  • Install Jenkins on Ubuntu 18.04 Ismail.EL CI/DI, Continues Integration, Depoloyment Integration, DevOps, Jenkins
  • DevOps practices that you must implement in 2019 Ismail.EL DevOps

Categories

  • CI/DI (1)
  • Continues Integration (1)
  • Depoloyment Integration (1)
  • DevOps (11)
  • Jenkins (1)
  • Monitoring (1)
    • Prometheus (1)

Recent Comments

  • Linuxi20 on How to Install Kubernetes (k8s) using Minikube Linux, Mac and Windows
  • Ismail.EL on How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS
  • doctorlinux on How to Install Kubernetes with Minikube on Ubuntu 18.04 LTS

Tags

cd ci ci/cd Cloud CloudOps Containerization DevOps Docker Dockerization jenkins k8s kubernetes Linux Mac minikube Open Source Windows
Advertisement

Subscribe

December 2019
M T W T F S S
« Nov    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Social Media

  • Connect on Facebook
  • Connect on Twitter
  • Connect on Google+
  • Connect on Pinterest
  • Connect on LinkedIn
  • Connect on Flickr
  • Connect on Instagram
  • Connect on RSS
  • Connect on YouTube
  • Connect on Tumblr
  • Connect on Github
  • Connect on Dribbble
  • Connect on Xing

Tags

cd ci ci/cd Cloud CloudOps Containerization DevOps Docker Dockerization jenkins k8s kubernetes Linux Mac minikube Open Source Windows

Archives

  • November 2019 (6)
  • October 2019 (1)
  • February 2019 (1)
  • January 2019 (1)
  • December 2018 (2)

Random Posts

  • what is jenkins 2019
    What is Jenkins ? November 19, 2019
  • Kubernetes ComponentKubernetes Component November 27, 2019
© Copyright 2019. Theme by http://devops-team.net.