An easy and step by step exercise for, How to Install and Deploy 2-Node Kubernetes Cluster Using Kubeadm In Ubuntu 20.04

Mentor and Source of Learning: Mr. Babar Zahoor : OpenSourceEducation.net
Learning Kubeadm Master Node Creation
Learning Kubeadm Worker Node Creation
میرے یوٹیوب چینل پراس مشق کی وڈیو ملاحظہ فرمائیے۔
You can watch the whole installation exercise of 2-Node Kubernetes Cluster on my youtube channel
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 کلسٹر کو بوٹسٹریپ کرنے کے عمل کو آسان بناتا ہے۔
It handles:
- 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 کلسٹر کو ترتیب دینے کے لیے بنیادی ضروریات پر بات کرتے ہیں۔ تنصیب کے عمل میں غوطہ لگانے سے پہلے، تعیناتی/ ڈپلائےمنٹ کوسادااورآسان بنانے کے لیے آپ کو چند تقاضے پورے کرنے کی ضرورت ہے۔وہ چند کلیدی شرائط یہ ہیں:
Sufficient Resources:
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) کی مناسب مقدار شامل ہے ۔تاکہ آپ کلسٹر پر جو کام کرنے والے ہیں اس کے بوجھ کو سنبھال سکے۔
Network Connectivity:
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 کےوسائل تک رسائی کے لیے بہت اہم ہے۔
Root Privileges:
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 کلسٹر چل رہا ہوگا، جو آپ کی کنٹینرائزڈ ایپلی کیشنز کی میزبانی کے لیے تیار ہوگا۔
~ 1 ~
Swap and Firewall should be Turned-Off!
سویپ اور فائروال کو لازم بند کریں!۔
Run these command on each machine!
ان کمانڈوں کو کلسٹر کی ہر مشین پر چلائیں!
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
Disabling The Swap
سویپ کو معطل کرتے ہیں۔
Mark the swap partition entry line with “#” to ‘comment’.
سوَیپ پارٹیشن کی سیٹنگز والی لائن کو”#” سے کمنٹ لائن مارک کردیں۔
sudo nano /etc/fstab
OR directly use the following command to do it:
یا مندرجہ ذیل کمانڈ سے بلاواسطہ یہ کام کر لیں۔
sudo sed -i '/ swap / s/^/#/' /etc/fstab
Enabling Ping by-Name
نام کے ذریعےمشین کو پِنگ کرنا
Repeat this on each machine!
اس عمل کو کلسٹرکی ہر مشین پر دوہرائیں!
Edit the hosts file in /etc directory and add the following information about each machine.
ہر مشین کی etc/ ڈائریکٹری میں موجود “ھاسٹس” hosts نام کی فائل میں اپنی ہر مشین کا آئی پی ایڈریس اور نام درج کریں۔
For example:
IP address machine name
:
IP n n machine
In my case it is:
192.168.10.11 3tKmaster
192.168.10.14 3tKworker1
مثلاً؛ سامنے دی گئی ترتیب کے ساتھ:
میرے سیٹ اپ میں یہ کچھ ایسے ہے:
Now, Restart The Machine!
اب مشین کو ریسٹارٹ کریں!
~ 2 ~
Before Installing Kubeadm
کیوب أیڈیئم کی انسٹالیشن سے پہلے کی تیاری
Run these command on each machine!
ان کمانڈوں کو کلسٹر کی ہر مشین پر چلائیں!
Configuring The IPv4 bridge
IPv4 بریج کا کانفگریشن سیٹ أپ
Loading 2 modules and making them available on Reboots.
یہ کمانڈان دو ماڈیولز کو ایسے لوڈ اور متحرک کردے گی کہ “سسٹم ری-بوٹ” پر دستیاب ہوجائیں گے۔
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
Confirm if overlay modules are loaded.
ان کمانڈ وں سے اس بات کی تسلی ہوجائیگی کہ “اؤور لے ماڈیولز” لوڈ ہوچکے ہیں۔
sudo modprobe overlay
sudo modprobe br_netfilter
~ 3 ~
Configuring the needed sysctl parameters.
‘سسٹم سی ٹی ایل’ کمانڈکانفگریشن
Run this command on each machine!
اس کمانڈ کو کلسٹر کی ہر مشین پر چلائیں!
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
Following command applied sysctl parameters in current env. without Restart.
مندرجہ ذیل کمانڈ سے سیس-سی-ٹی-ایل کے پیرامیٹرزموجودہ سیٹ اپ میں بغیرسسٹم رِیسٹارٹ کے لگا دیئے گئے۔
sudo sysctl --system
~ 4 ~
Installing Docker

ڈاکر کی انسٹالیشن
Do This on Each Machine!
مندرجہ ذیل عمل ہر مشین پر دوہرائیں!
Always update the system before installing any package.
ہمیشہ کوئی بھی نیا پیکیج/ایپلیکیشن انسٹال کرنے سے پہلے سسٹم کو أپڈیٹ ضرور کریں۔
sudo apt update
sudo apt install docker.io
Checking version of docker.
ڈاکر کاورژن دیکھنے کے لئے ۔
docker --version
Enabling Docker on Reboots.
ڈاکر کی دستیابی کو سسٹم ری-بوٹس پر ممکن بنانے کے لئے ۔
sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl status docker
~ 5 ~
Installing Packages, Initially Required by Kubernetes.
کوبرنیٹیس کی بنیادی ضرورت کے پیکیجزکی انسٹالیشن
Run this command on each machine!
اس کمانڈ کو کلسٹر کی ہر مشین پر چلائیں!
sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl -y
~ 6 ~
Downloading the Google Cloud Public Keys.

گوگل کلاؤڈ کی “پبلک کیز” کی ڈاؤنلوڈنگ
Do This on Each Machine!
مندرجہ ذیل عمل ہر مشین پر دوہرائیں!
First need to create the directory for the keyrings.
کی رنگز کے لئے پہلے سب ڈائریکٹری بنانی ہے۔
sudo mkdir /etc/apt/keyrings
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
~ 7 ~
Adding/Enabling the Kubernetes apt repository.

کوبرنیٹیس کی ریپازٹری کا کمپیوٹر میں سیٹ أپ
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
Official documentation about the process:
اس عمل سے متعلق مزید تفصیلات کے لئے
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
اس کے لئے دیئے گئے آفیشل لنک پر ڈاکومنٹیشن پیج پر آپ کو یہ سب معلومات ملیں گی۔
~ 8 ~
Installing Kubeadm

کیوب أیڈیئم کی انسٹالیشن
Run This Command on Each Machine!
اس کمانڈ کو کلسٹرکی ہر مشین پر چلائیں!
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
Creating and Configuring The Cluster
کلسٹر کی بناوٹ اور کانفگریشن
sudo Kubeadm init
Kubeadm config images pull
Kubectl Normal User Setup on 🔥Master Only🔥
کیوب سی ٹی ایل کے عام یوزر کا سیٹ أپ 🔥صرف ماسٹرنوڈپر🔥
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
~ 9 ~
Initializing Kubernetes on 🔥Master🔥
🔥ماسٹرنوڈ🔥پر کوبرنیٹیس کاابتدائی سیٹ أپ
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.
کیوب أیڈیئم جائن کمانڈکے پراسیس کے مکمل ہونے پر ایک میسیج سکرین پر آئے گا۔ اس میسیج کو نوٹ کرلیں یا کاپی پیسٹ کرکے رکھ لیں، اس کے ذریعے ہم نے آگے چل کر ورکر نوڈز کوکلسٹرمیں شامل کرنا ہے۔
Should be Typed on the🔥Master Node’s🔥command line
لازماً🔥ماسٹرنوڈ🔥کی کمانڈلائن پر ٹائپ کریں
sudo kubeadm init - -ignore-preflight-errors=all - -pod-network-cidr=192.168.0.0/16
Kubectl get nodes
Kubectl get pods -A
To keep/hold the packages from getting “Auto-updates”.
پیکیجز/ایپلیکیشنز کو “آٹو أپڈیٹ” سے باز رکھنے کےلئے
Run This Command on Each Machine!
اس کمانڈ کو کلسٹرکی ہر مشین پر چلائیں!
sudo apt-mark hold kubeadm kubelet kubectl
~ 10 ~
Installing Calico Networking/SDN (The Overlay Network)

کالِیکونیٹورکنگ کی انسٹالیشن
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
Custom resources downloaded to configure Calico:
کالیکو کے کانفیگریشن کے لئے منتخب وسائل کی ڈاؤنلوڈنگ
curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml -O
Applying the settings in ‘.yaml’ file:
‘یامل۔’ فائل میں درج ترتیب کا اطلاق 🏁
kubectl apply -f custom-resources.yaml
Kubectl get po -A
If you have come this far, it means you may have found the blog as of your interest. I am really thankful for your time, please do leave your valuable opinion as comment. Happy learning.
اگرآپ اس حد تک پڑھتے ہوئے آگئے ہیں تو مجھے بے حد خوشی ہے کہ آپ نے میری بلاگ کو اس قابل پایا۔میں تہہ دل سےشکرگزرا ہوں۔ حصول علم میں آپ کے لئے آسانیاں ہوں۔




