Skip to content

How to!: Installation And Deployment Of 2-Node Kubernetes Cluster Using Kubeadm In Ubuntu 20.04 🙆



How to Installation and Deployment Of 2-Node Kubernetes Cluster Using Kubeadm in Ubuntu 20.04 🙆


Mentor and Source of Learning: Mr. Babar Zahoor : OpenSourceEducation.net




میرے یوٹیوب چینل پراس مشق کی وڈیو ملاحظہ فرمائیے۔


Talking a little about Kubernetes


Welcome to my comprehensive and practical guide on the installation and deployment of 2-node Kubernetes cluster using Kubeadm in Ubuntu 20.04.

قارئین کرام أبنٹو [Ubuntu20.04] میں کیوب أیڈیئم[Kubeadm] کا استعمال کرتے ہوئے دو نوڈ کے کیوبرنیٹس کلسٹر کی تنصیب یعنی انسٹالیشن اور تعیناتی /ڈیپلائیمنٹ سے متعلق میری جامع اور عملی مشق میں خوش آمدید۔

Kubernetes is an open-source platform, it is also called with name K8s and has become the de facto standard for container orchestration, it enables organizations to efficiently manage and scale their applications.

Kubernetes ایک اوپن سورس پلیٹ فارم ہے، اسے K8s کے نام سے بھی پکارا جاتا ہے اور یہ کنٹینر آرکیسٹریشن کے لئے ڈی فیکٹو سٹینڈرڈ بن گیا ہے، یہ اداروں کو اپنی ایپلی کیشنز کو مؤثر طریقے سے منظم کرنے کے قابل بناتا ہے۔

The Kubeadm, a tool designed to simplify the process of setting up a Kubernetes cluster, you can quickly get started with your own cluster deployment using kubeadm.

Kubeadm ایک ٹول ہےجسے   Kubernetes کلسٹر قائم کرنے کے عمل کو آسان بنانے کے لیے ڈیزائن کیا گیا ہے۔ آپ kubeadm کا استعمال کرتے ہوئے اپنے کلسٹر کو بڑی آسانی سے اور تھوڑے وقت میں ڈپلائے کرنا شروع کر سکتے ہیں۔

In this blog post, you will walk through a detailed, step-by-step process of installing and configuring a 2-node Kubernetes cluster using Kubeadm on Ubuntu 20.04 based Desktop PC.

اس بلاگ پوسٹ میں، آپ اُبُنٹُو آپریٹنگ سسٹم والے ڈیسک ٹاپ پی سی پر Kubeadm کا استعمال کرتے ہوئے کیوبرنیٹس کے 2 نوڈکلسٹر کو انسٹال اور کانفیگر کرنے کے تفصیلی اور مرحلہ وار عمل سے گزریں گے۔

Especially for the beginners, if you are a beginner exploring Kubernetes for the first time, this guide is here to assist you.

 خاص طور پر نئے سیکھنے والوں  کے لیے، اگر آپ پہلی بار کیوبرنیٹس کادورہ  کرنے والے ہیں، تو یہ گائیڈ آپ کی مدد کے لیے حاضر ہے۔

Before diving into the installation process, let’s take a bird’s eye view of its key components.

تنصیب یعنی انسٹالیشن  کے عمل میں غوطہ لگانے سے پہلے، آئیے اس میں شامل کلیدی اجزاء پر ایک طائرانہ نظر ڈالتے  ہیں۔

Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It organizes containers into logical units called “pods,” which are the basic building blocks of Kubernetes deployments.

Kubernetes ایک اوپن سورس کنٹینر آرکیسٹریشن پلیٹ فارم ہے۔  جو کنٹینرائزڈ ایپلی کیشنز کی تعیناتی/ ڈپلائمنٹ، اسکیلنگ اور انتظام کو خودکار بناتا ہے۔ یہ کنٹینرز کو منطقی اکائیوں(logical units) میں ترتیب دیتا ہے جنہیں “pods” کہتے ہیں، جو Kubernetes کی تعیناتیوں /ڈپلائمنٹس کے بنیادی تعمیراتی بلاکس ہیں۔

Kubeadm, on the other hand, is a command-line tool (CLI Tool) that simplifies the process of bootstrapping a Kubernetes cluster.

دوسری طرف Kubeadm ایک کمانڈ لائن ٹول (CLI Tool ) ہے۔   جو Kubernetes کلسٹر کو بوٹسٹریپ کرنے کے عمل کو آسان بناتا ہے۔


  • Initialization of the control plane
  • Joins worker nodes to the cluster
  • Configures the necessary components for communication and coordination between nodes.

– کنٹرول پلین کی ابتدائی ترتیب
– کارکن /ورکرنوڈ زکو کلسٹر میں شامل کرتا ہے۔
– نوڈز کے مابین مواصلات /کمیونیکیشن اور ہم آہنگی کے لئے ضروری اجزاء کو تشکیل دیتا ہے۔

By leveraging Kubeadm and Calico Trigera, you can effortlessly set up a Kubernetes cluster without the need for laborious manual configuration.

Kubeadm اور Calico Tigera کا فائدہ اٹھا تے ہوئے، آپ آسانی سے بغیر کسی عملی مشقت کے Kubernetes کلسٹر قائم کر سکتے ہیں۔

After having a short introduction to K8s, let’s discuss the prerequisites for setting up this Kubernetes cluster. Before diving into the installation process, there are a few requirements you need to fulfill to ensure a smooth deployment. Here are the key prerequisites:

K8s سے مختصر تعارف کرانے کے بعد، آئیے اس Kubernetes کلسٹر کو ترتیب دینے کے لیے بنیادی ضروریات پر بات کرتے ہیں۔ تنصیب کے عمل میں غوطہ لگانے سے پہلے،  تعیناتی/ ڈپلائےمنٹ کوسادااورآسان  بنانے کے لیے آپ کو چند تقاضے پورے کرنے کی ضرورت ہے۔وہ چند  کلیدی شرائط یہ ہیں:

Check that your system meets the minimum resource requirements for running a Kubernetes cluster. This includes an adequate amount of CPU(s), memory (RAM), and storage (HardDisk space) to handle the workload you plan to run on the cluster.

چیک کرلیں کہ آیا آپ کا سسٹم Kubernetes  کلسٹر چلانے کے لیے کم از کم وسائل کی ضروریات کو پورا کرتا ہےیا نہیں٘۔ اس میں CPU(s)، میموری (RAM)، اور اسٹوریج (HardDisk space) کی مناسب مقدار شامل ہے ۔تاکہ آپ کلسٹر پر جو کام کرنے والے ہیں  اس کے بوجھ کو سنبھال سکے۔

Ensure that your machine has a stable internet connection. This is crucial for downloading necessary packages, container images, and accessing Kubernetes resources during the installation process.

یقینی بنائیں کہ آپ کی مشین کا انٹرنیٹ کنکشن مستحکم ہے۔ یہ ضروری پیکجز، کنٹینر امیجز کو ڈاؤن لوڈ کرنے اور انسٹالیشن کے عمل کے دوران Kubernetes کےوسائل تک رسائی کے لیے بہت اہم ہے۔

You will need administrative privileges or root access to execute commands and make system-level changes during the installation and configuration process. Make sure you have the necessary permissions to perform these tasks.

4. رُوٹ  پرمشنز/مراعات:
آپ کو کمانڈ پر عمل درآمد کرنے اور انسٹالیشن اور کانفیگریشن کے عمل کے دوران سسٹم کی سطح پر تبدیلیاں کرنے کے لیے انتظامی مراعات/ ایڈمنسٹریٹؤ پریولیجز یا رُوٹ رسائی یعنی رُوٹ ایکسَیس کی ضرورت ہوگی۔ یقینی بنائیں کہ آپ کے پاس ان کاموں کو انجام دینے کے لیے ضروری اجازتیں ہیں۔

By meeting these prerequisites, you will be well-prepared to proceed with the installation and deployment of your 2-node Kubernetes cluster using Kubeadm and Calico Tigera.

ان شرائط کو پورا کرنے سے، آپ Kubeadm اور Calico Tigera کا استعمال کرتے ہوئے اپنے Kubernetesکے Two node کلسٹر کی تنصیب/انسٹالیشن اور تعیناتی/ڈپلائمنٹ کے لئے عمل کو آگے بڑھانے کے لیے اچھی طرح سے تیار ہو جائیں گے۔

Now, let’s dive into the installation and deployment process of a 2-node Kubernetes cluster using Kubeadm on Ubuntu 20.04. Follow along, and soon you’ll have a fully functional Kubernetes cluster up and running, ready to power your containerized applications.

اب، آئیے Ubuntu 20.04 پر Kubeadm کا استعمال کرتے ہوئے دو نوڈز والے Kubernetes کلسٹر کی تنصیب اور تعیناتی کے عمل میں غوطہ لگاتے ہیں۔ ساتھ چلیں، اور جلد ہی آپ کے پاس مکمل طور پر فعال Kubernetes کلسٹر  چل رہا ہوگا، جو آپ کی کنٹینرائزڈ ایپلی کیشنز کی میزبانی کے لیے تیار ہوگا۔


Swap is the space of hard disk to support RAM. In case RAM got loaded and no space left the system then uses the Hard Disk space as RAM.

سویپ RAM کو سپورٹ کرنے کے لیے ہارڈ ڈسک کے اوپر جگہ ہے۔ اگر RAM لوڈ ہو جائے اور سسٹم میں کوئی جگہ نہ رہ جائے ،تو سسٹم ہارڈ ڈسک کی جگہ کو بطور RAM استعمال کرتا ہے۔

sudo swapoff -a
sudo systemctl disable firewalld
Command Copied

Mark the swap partition entry line with “#” to ‘comment’.

سوَیپ پارٹیشن کی سیٹنگز والی لائن کو”#” سے کمنٹ لائن مارک کردیں۔

sudo nano /etc/fstab Command Copied

OR directly use the following command to do it:

یا مندرجہ ذیل کمانڈ سے بلاواسطہ یہ کام کر لیں۔

sudo sed -i '/ swap / s/^/#/' /etc/fstab Command Copied

Edit the hosts file in /etc directory and add the following information about each machine.

ہر مشین کی etc/ ڈائریکٹری میں موجود “ھاسٹس” hosts نام کی فائل میں اپنی ہر مشین کا آئی پی ایڈریس اور نام درج کریں۔

Now, Restart The Machine!

اب مشین کو ریسٹارٹ کریں!


Loading 2 modules and making them available on Reboots.

یہ کمانڈان دو ماڈیولز کو ایسے لوڈ اور متحرک کردے گی کہ “سسٹم ری-بوٹ” پر دستیاب ہوجائیں گے۔

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
Command Copied

Confirm if overlay modules are loaded.

ان کمانڈ وں سے اس بات کی تسلی ہوجائیگی کہ “اؤور لے ماڈیولز” لوڈ ہوچکے ہیں۔

sudo modprobe overlay
sudo modprobe br_netfilter
Command Copied

The needed parameters of sysctl are configured Persistent around system reboots.

سیس سی ٹی ایل کے ضرورت کے پیرامیٹرز کو مشین ری-بُوٹ پر مستقلاً دستیاب بنانے کے لئےیہ کمانڈ چلائیں گے۔

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
Command Copied

Following command applied sysctl parameters in current env. without Restart.

مندرجہ ذیل کمانڈ سے سیس-سی-ٹی-ایل کے پیرامیٹرزموجودہ سیٹ اپ میں بغیرسسٹم رِیسٹارٹ کے لگا دیئے  گئے۔

sudo sysctl --system Command Copied

Docker Logo

Always update the system before installing any package.

ہمیشہ کوئی بھی نیا پیکیج/ایپلیکیشن انسٹال کرنے سے پہلے سسٹم کو أپڈیٹ ضرور کریں۔

sudo apt update
sudo apt install docker.io
Command Copied

Checking version of docker.

ڈاکر کاورژن دیکھنے کے لئے ۔

docker --version Command Copied

Enabling Docker on Reboots.

ڈاکر کی دستیابی کو سسٹم ری-بوٹس پر ممکن بنانے کے لئے ۔

sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl status docker
Command Copied

sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl -y
Command Copied

First need to create the directory for the keyrings.

  کی رنگز کے لئے پہلے سب ڈائریکٹری بنانی ہے۔

sudo mkdir /etc/apt/keyrings Command Copied

Following command will download the keys.

  مندرجہ ذیل کمانڈ  “پبلک کِیز” کو ڈاؤنلوڈ کرے گی۔

curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg Command Copied

Kubernetes Logo

This command will add and enable the repository.

یہ کمانڈ ریپازٹری کو کمپیوٹر میں فعال کرے گی۔

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list Command Copied

If you feel like to dive deeper to know more, and you should!

  اگر آپ سمجھتے ہیں کہ آپ کو مزید اس کے بارے میں جاننا چاہیئے، بلکہ ضرور جانیئے۔

Goto:kubernetes.io/docs/home/
and search for Kubeadm and
-pick-
– Installing kubeadm
-Creating cluster with kubeadm

اس کے لئے دیئے گئے آفیشل لنک پر ڈاکومنٹیشن پیج پر آپ کو یہ سب معلومات ملیں گی۔


sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
Command Copied

Creating and Configuring The Cluster

کلسٹر کی بناوٹ اور کانفگریشن

sudo Kubeadm init
Kubeadm config images pull
Command Copied
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
Command Copied

At the completion of the process of following command the kubeadm join message will appear. Copy paste or take notes of this whole message, as we will be using this to join the worker nodes to the cluster.

کیوب أیڈیئم جائن کمانڈکے پراسیس کے مکمل ہونے پر ایک میسیج سکرین پر آئے گا۔ اس میسیج کو نوٹ کرلیں یا کاپی پیسٹ کرکے رکھ لیں، اس کے ذریعے ہم نے آگے چل کر ورکر نوڈز کوکلسٹرمیں شامل کرنا ہے۔

sudo kubeadm init - -ignore-preflight-errors=all - -pod-network-cidr=192.168.0.0/16
Kubectl get nodes
Kubectl get pods -A
Command Copied

To keep/hold the packages from getting “Auto-updates”.

پیکیجز/ایپلیکیشنز کو “آٹو أپڈیٹ” سے باز رکھنے کےلئے

sudo apt-mark hold kubeadm kubelet kubectl Command Copied

Calico Logo

A Pod Network to Cluster Deployment allows Nodes in a cluster to communicate with each other.

 کلسٹرڈپلائمنٹ میں  “Pod network/ پاڈنیٹورک” نوڈز کو اس قابل بناتا ہے کہ وہ کلسٹر میں دیگر نوڈز کے ساتھ رابطہ کر سکیں، یعنی آپس میں لنک ہوسکیں۔

Creating Tigera Operator

ٹائیگیرا آپریٹر بنانے کے لئے

kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml Command Copied

Custom resources downloaded to configure Calico:

کالیکو کے کانفیگریشن کے لئے منتخب وسائل کی ڈاؤنلوڈنگ

curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml -O Command Copied

Applying the settings in ‘.yaml’ file:

‘یامل۔’ فائل میں درج ترتیب کا اطلاق 🏁

kubectl apply -f custom-resources.yaml
Kubectl get po -A
Command Copied




Leave a Reply

Your email address will not be published. Required fields are marked *