এই Demo-তে আমরা দেখব কীভাবে Minikube Kubernetes Cluster-এর মধ্যে একটি NGINX Pod Create এবং Inspect করতে হয়।
আগের Tutorial-এ আমরা শিখেছি Kubernetes Pod কী, কীভাবে Containers Pod-এর মধ্যে Run করে এবং Pod কেন Kubernetes-এর Smallest Deployable Unit।
এবার আমরা সেই Concepts Practically দেখব।
এই Demo-এর মূল ধারণা হলো:
আমরা kubectl ব্যবহার করে Kubernetes-কে একটি Pod Create করার Instruction দিই। Kubernetes Container Image Pull করে এবং Cluster-এর মধ্যে Container Run করে।
এছাড়াও আমরা দেখব kubectl run এবং kubectl create deployment-এর মধ্যে কী পার্থক্য এবং Real Applications-এর জন্য Deployment কেন গুরুত্বপূর্ণ।
1. Demo শুরু করার আগে কী কী Ready থাকতে হবে?
এই Demo শুরু করার আগে আমরা ধরে নিচ্ছি:
- Minikube Cluster Running রয়েছে।
- kubectl Installed রয়েছে।
- kubectl Minikube Cluster-এর সঙ্গে Connect করার জন্য Configured রয়েছে।
অর্থাৎ আমরা এখন Terminal থেকে Kubernetes Commands Execute করতে পারব।
Minikube Status Check
minikube status
Kubernetes Node Check
kubectl get nodes
Expected Example:
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 5m v1.x.x
এখানে Ready Status দেখালে বোঝা যায় Kubernetes Node Running এবং Workloads Run করার জন্য Ready।
2. kubectl দিয়ে একটি Pod Create করা
এবার আমরা NGINX Container Image ব্যবহার করে একটি Kubernetes Pod Create করব।
Command:
kubectl run nginx --image=nginx
এই Command-এর অর্থ হলো:
nginxনামে একটি Pod Create করো এবং সেই Pod-এর মধ্যেnginxContainer Image ব্যবহার করে Container Run করো।
Command Breakdown
| Command Part | Meaning |
|---|---|
kubectl | Kubernetes-এর Command-Line Tool |
run | একটি Pod Create এবং Run করার Instruction |
nginx | Pod-এর Name |
--image=nginx | কোন Container Image ব্যবহার করা হবে |
এখানে Pod-এর Name আমরা প্রয়োজন অনুযায়ী দিতে পারি, তবে সেটি Kubernetes Naming Rules অনুসরণ করতে হবে।
অন্যদিকে Image Name অবশ্যই একটি Valid এবং Accessible Container Image Reference হতে হবে।
Default Configuration-এ nginx Image সাধারণত Docker Hub থেকে Pull করা হয়।
Internally কী ঘটে?
Developer
|
▼
kubectl run nginx --image=nginx
|
▼
Kubernetes API Server
|
▼
Pod Object Created
|
▼
Kubernetes Scheduler
|
▼
Node Assignment
|
▼
Kubelet
|
▼
Container Runtime
|
▼
NGINX Image Pull
|
▼
NGINX Container Starts
অর্থাৎ আমরা সরাসরি Docker Container Start করছি না।
আমরা একটি Kubernetes Pod Create করছি এবং Kubernetes Container Runtime-এর মাধ্যমে Container Execute করছে।
3. Pod Name এবং Container Image Tag বোঝা
আগের Command-এ আমরা লিখেছি:
kubectl run nginx --image=nginx
এখানে দুটি গুরুত্বপূর্ণ বিষয় রয়েছে।
Pod Name: nginx
Container Image: nginx
Pod Name হলো Kubernetes Object-এর Name।
Container Image Name Kubernetes-কে বলে কোন Image ব্যবহার করে Container Run করতে হবে।
Default Image Tag
যদি Image Name-এর সঙ্গে কোনো Tag না দেওয়া হয়, তাহলে সাধারণত latest Tag ব্যবহার করা হয়।
nginx
সাধারণত Equivalent:
nginx:latest
তবে latest মানেই সর্বশেষ Published Version নিশ্চিতভাবে ব্যবহার হচ্ছে — এমন নয়। Image Pull Policy এবং Local Image Cache-এর ওপর Behavior নির্ভর করতে পারে।
Specific Image Tag ব্যবহার করা
kubectl run nginx --image=nginx:1.25
এখানে আমরা একটি Specific NGINX Version-এর Image Reference ব্যবহার করছি।
Version-specific Tag ব্যবহার করলে কোন Application Version Run হচ্ছে সেটি বোঝা সহজ হয়।
তবে Tag পরিবর্তনযোগ্য হতে পারে। Strict Reproducibility-এর জন্য Image Digest Pinning আরও নির্ভরযোগ্য।
Private Registry Image ব্যবহার করা
ধরো, Application Image একটি Company Registry-তে Store করা আছে।
Example:
kubectl run myapp --image=myregistry.example.com/myapp:v1
এখানে Kubernetes নির্দিষ্ট Registry থেকে Image Pull করার চেষ্টা করবে।
Private Registry হলে Image Pull Credentials Configure করার প্রয়োজন হতে পারে।
মনে রাখবে
Pod Name
|
▼
Kubernetes Object-এর Identity
Image Name
|
▼
Container তৈরির জন্য Image Reference
Pod Name এবং Image Name এক জিনিস নয়।
4. Pod Status Check করা
Pod Create করার পর আমাদের Check করতে হবে Pod Successfully Running হয়েছে কি না।
Command:
kubectl get pods
Expected Example:
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 30s
এই Output-এর প্রতিটি Column গুরুত্বপূর্ণ।
| Column | Meaning |
|---|---|
NAME | Pod-এর Name |
READY | কতটি Container Ready / মোট কতটি Container |
STATUS | Pod-এর Current Displayed Status |
RESTARTS | Container কতবার Restart হয়েছে |
AGE | Pod Create হওয়ার পর কত সময় হয়েছে |
এখানে আমরা দেখতে পাচ্ছি NGINX Pod Running রয়েছে।
5. READY Column কী বোঝায়?
kubectl get pods Command-এর Output-এ একটি গুরুত্বপূর্ণ Column হলো READY।
Single-Container NGINX Pod-এর ক্ষেত্রে:
READY
1/1
এর অর্থ:
একটি Container-এর মধ্যে একটি Container Ready রয়েছে।
Multiple Containers থাকলে
ধরো, একটি Pod-এর মধ্যে দুটি Containers রয়েছে।
তাহলে Output হতে পারে:
READY
2/2
অর্থাৎ দুটি Containers-এর মধ্যে দুটিই Ready।
Container Ready না থাকলে
READY
0/1
এর অর্থ Pod-এ একটি Container Defined থাকলেও সেটি এখনও Ready নয়।
এটি হতে পারে:
- Container এখনও Start হয়নি।
- Image Pull হচ্ছে।
- Container Start হতে Problem হচ্ছে।
- Readiness Check Pass করছে না।
Example
Pod A → READY 1/1 → Ready
Pod B → READY 2/2 → Both Containers Ready
Pod C → READY 0/1 → Container Not Ready
READY এবং STATUS একই জিনিস নয়।
একটি Pod Running Phase-এ থেকেও তার Application Container READY 0/1 দেখাতে পারে।
6. Pod STATUS বোঝা
Kubernetes Pod-এর Current State বোঝার জন্য STATUS Column খুব গুরুত্বপূর্ণ।
Common Displayed Status Values:
| Status | Meaning |
|---|---|
ContainerCreating | Kubernetes Container Create করার Preparation করছে |
Running | Pod Running Phase-এ রয়েছে |
Pending | Pod এখনও Running Phase-এ যায়নি |
Error | কোনো Container Operation Failure হয়েছে |
CrashLoopBackOff | Container বারবার Fail করছে এবং Restart Delay হচ্ছে |
এখানে একটি Technical Detail মনে রাখা ভালো:
Pending এবং Running Kubernetes-এর Actual Pod Phases-এর মধ্যে পড়ে।
কিন্তু ContainerCreating, Error এবং CrashLoopBackOff সাধারণত kubectl-এ প্রদর্শিত Container State বা Reason।
ContainerCreating
NAME READY STATUS RESTARTS
nginx 0/1 ContainerCreating 0
এখানে Kubernetes Container Start করার Preparation করছে।
যেমন:
- Image Pull করা
- Container Create করা
- Networking Configure করা
- Storage Mount করা
Running
NAME READY STATUS RESTARTS
nginx 1/1 Running 0
এখানে NGINX Container Running এবং Ready রয়েছে।
CrashLoopBackOff
NAME READY STATUS RESTARTS
nginx 0/1 CrashLoopBackOff 5
এটি বোঝায় Container বারবার Fail করছে এবং Kubernetes Restart করার আগে Delay দিচ্ছে।
এই Demo-তে আমাদের Desired Output:
Running
সঙ্গে READY 1/1 থাকলে Test আরও পরিষ্কারভাবে Successful বোঝা যায়।
7. kubectl describe দিয়ে Detailed Pod Information দেখা
kubectl get pods ব্যবহার করে আমরা Pod-এর Basic Status দেখতে পারি।
কিন্তু যদি Pod সম্পর্কে আরও বিস্তারিত Information দরকার হয়, তাহলে kubectl describe ব্যবহার করতে হবে।
Command:
kubectl describe pod nginx
এই Command Pod-এর অনেক Detailed Information দেখাবে।
যেমন:
- Pod Name
- Labels
- Start Time
- Node Assignment
- Node IP Address
- Pod IP Address
- Container Image
- Container State
- Events
Example Structure
Name: nginx
Namespace: default
Node: minikube/192.168.49.2
Start Time: ...
Labels: run=nginx
Status: Running
IP: 10.244.0.3
Containers:
nginx:
Image: nginx
State: Running
Events:
...
এই Output শুধুমাত্র Example। Actual Cluster-এর IP Address, Timestamps এবং Other Details আলাদা হবে।
kubectl get vs describe
| Command | Purpose |
|---|---|
kubectl get pods | Basic Pod Status দেখা |
kubectl describe pod nginx | Detailed Pod Information এবং Events দেখা |
Troubleshooting-এর সময় kubectl describe খুব Useful।
8. Node Assignment — Pod কোন Node-এ Running?
Kubernetes Cluster-এ একটি বা একাধিক Nodes থাকতে পারে।
Pod Create করার পর Kubernetes Scheduler Determine করে কোন Suitable Node-এ Pod Run করবে।
kubectl describe pod nginx Output-এ Node Information দেখা যায়।
Example:
Node: minikube/192.168.49.2
এর অর্থ NGINX Pod minikube Node-এ Assigned হয়েছে। /-এর পরের অংশটি Node-এর IP Address।
Single-Node Minikube
Kubernetes Cluster
|
▼
Minikube
|
▼
NGINX Pod
এখানে সাধারণত একটি Node রয়েছে।
Multi-Node Kubernetes Cluster
ধরো, Cluster-এ একাধিক Worker Nodes আছে।
Kubernetes Cluster
|
+---+----------------+
| |
▼ ▼
Worker Node 1 Worker Node 2
|
▼
NGINX Pod
Scheduler Resource Availability এবং Scheduling Rules অনুযায়ী Pod কোনো Suitable Node-এ Assign করতে পারে।
Example:
Pod nginx → Node worker-2
এখানে nginx Pod worker-2 Node-এ Running রয়েছে।
9. Pod IP Address কী?
Kubernetes Cluster-এর মধ্যে প্রতিটি Regular Pod সাধারণত একটি Internal IP Address পায়।
এই IP Address Pod Networking-এর জন্য ব্যবহার করা হয়।
kubectl describe pod nginx Output-এ Pod IP দেখতে পাওয়া যায়।
Example:
IP: 10.244.0.3
Pod Networking
Kubernetes Cluster
|
▼
Node
|
▼
Pod
|
▼
IP: 10.244.0.3
|
▼
NGINX Container
একই Pod-এর Multiple Containers সাধারণত একই Network Namespace এবং Pod IP Share করে।
Pod IP কি বাইরে থেকে Access করা যায়?
সাধারণত Pod IP Cluster-এর Internal Networking-এর অংশ।
External Users সাধারণত Pod IP Directly Access করতে পারে না।
এজন্য Kubernetes-এর Service এবং Networking Configuration ব্যবহার করা হয়।
External User
|
▼
Kubernetes Service
|
▼
Pod IP
|
▼
NGINX Container
এই Tutorial-এ External Networking নয়, Pod Create এবং Inspect করার ওপর Focus করা হচ্ছে।
10. Container Information Check করা
kubectl describe pod nginx Command Container সম্পর্কেও Details দেখায়।
আমাদের Demo-তে একটি NGINX Container রয়েছে।
Example:
Containers:
nginx:
Image: nginx
State: Running
এখানে আমরা Confirm করতে পারি:
- Pod-এর মধ্যে NGINX Container রয়েছে।
- Container Image হলো
nginx। - Container Running অবস্থায় রয়েছে।
যদি একটি Pod-এর মধ্যে Multiple Containers থাকে, তাহলে প্রতিটি Container-এর Details এই Section-এ দেখতে পাওয়া যাবে।
Example:
Pod
|
├── NGINX Container
|
└── Helper Container
তাহলে describe Output-এ দুটি Containers-এর Information থাকবে।
11. Events Section — Pod-এর History বোঝা
kubectl describe pod nginx Command-এর নিচের দিকে একটি Events Section থাকে।
এটি Kubernetes Troubleshooting-এর জন্য খুব গুরুত্বপূর্ণ।
Events Section-এ Pod Create হওয়ার পর কী কী ঘটেছে, তার Timeline দেখা যায়।
Example:
Pod Scheduled to minikube Node
|
▼
NGINX Image Pulled
|
▼
NGINX Container Created
|
▼
NGINX Container Started
এভাবে Kubernetes Pod Lifecycle-এর বিভিন্ন Operations Track করা যায়।
Events কেন গুরুত্বপূর্ণ?
ধরো, তুমি একটি Pod Create করলে কিন্তু সেটি Running হচ্ছে না।
kubectl get pods
Output:
NAME READY STATUS RESTARTS
nginx 0/1 ImagePullBackOff 0
এখন Problem কী?
সম্ভবত Kubernetes Container Image Pull করতে পারছে না।
Detailed Information দেখতে:
kubectl describe pod nginx
Events Section-এ Image Pull-related Error দেখতে পাওয়া যেতে পারে।
যেমন:
Failed to pull image
এই Information ব্যবহার করে Problem Diagnose করা সহজ হয়।
Pod Troubleshooting-এর সময় Events Section Check করা খুব গুরুত্বপূর্ণ।
12. kubectl get pods -o wide
Pod-এর Basic Status-এর সঙ্গে আরও Information দেখতে চাইলে -o wide Option ব্যবহার করা যায়।
Command:
kubectl get pods -o wide
এই Command সাধারণত নিচের Information দেখায়:
- Pod Name
- Ready Status
- Pod Status
- Restart Count
- Age
- Pod IP
- Node Name
Example Output
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 1m 10.244.0.3 minikube
এখানে আমরা সহজেই দেখতে পাচ্ছি:
Pod Name: nginx
Pod Status: Running
Pod IP: 10.244.0.3
Assigned Node: minikube
এটি দ্রুত Pod-এর Node Assignment এবং Internal IP Check করার জন্য Useful।
13. এই Demo-এর গুরুত্বপূর্ণ Commands
| Command | Purpose |
|---|---|
kubectl run nginx --image=nginx | NGINX Pod Create করা |
kubectl get pods | Pods List করা |
kubectl describe pod nginx | Detailed Pod Information দেখা |
kubectl get pods -o wide | Pod IP এবং Node Information দেখা |
14. Complete Basic Pod Demo — Command Flow
পুরো Demo-এর Commands একসঙ্গে:
# 1. Create NGINX Pod
kubectl run nginx --image=nginx
# 2. Check Basic Pod Status
kubectl get pods
# 3. Inspect Pod Details
kubectl describe pod nginx
# 4. Check Pod IP and Node
kubectl get pods -o wide
এই চারটি Commands ব্যবহার করে আমরা একটি Pod Create এবং Inspect করতে পারি।
15. এই Demo থেকে কী শিখলাম?
এই Demo থেকে আমরা শিখলাম:
- Pod হলো Kubernetes-এর Smallest Deployable Unit।
kubectl runCommand দিয়ে Pod Create করা যায়।--imageOption দিয়ে Container Image Specify করা হয়।- Kubernetes Docker Hub অথবা অন্য Registry থেকে Image Pull করতে পারে।
kubectl get podsPod-এর Status দেখায়।kubectl describe podDetailed Information দেখায়।- সাধারণত প্রতিটি Pod নিজস্ব Internal IP Address পায়।
kubectl get pods -o wideদিয়ে Pod IP এবং Node Information দেখা যায়।
Basic Pod Workflow
kubectl run
|
▼
Pod Created
|
▼
Container Image Pulled
|
▼
Container Started
|
▼
kubectl get pods
|
▼
kubectl describe pod
|
▼
kubectl get pods -o wide
16. Important Note — kubectl run Command-এর Behavior Change
Kubernetes-এর পুরোনো Tutorials-এ kubectl run Command সম্পর্কে কিছু Different Examples পাওয়া যায়।
এখানে একটি গুরুত্বপূর্ণ Version-related Change রয়েছে।
Kubernetes 1.18 এবং পরবর্তী kubectl Versions-এ kubectl run Default হিসেবে একটি Pod Create করে, Deployment নয়।
kubectl run — Pod Create করে
kubectl run nginx --image=nginx
এই Command Create করে:
Pod
|
└── NGINX Container
এটি Deployment Create করে না।
Version History
Kubernetes 1.18-এর আগের বিভিন্ন Tutorials এবং Labs-এ kubectl run ব্যবহার করে Deployment Create করার Examples পাওয়া যায়।
কিন্তু Modern kubectl Behavior হলো:
kubectl run → Pod
এই Difference মনে রাখা গুরুত্বপূর্ণ, কারণ পুরোনো Tutorial Follow করলে Confusion হতে পারে।
17. kubectl দিয়ে Deployment Create করা
যদি আমরা শুধু একটি Standalone Pod না তৈরি করে একটি Deployment Create করতে চাই, তাহলে Different Command ব্যবহার করতে হবে।
Command:
kubectl create deployment nginx --image=nginx
এই Command একটি Deployment Create করে।
Deployment-এর মাধ্যমে Kubernetes Application Pods Manage করতে পারে।
Deployment Check করা
kubectl get deployments
Deployment-এর Managed Pods দেখতে:
kubectl get pods
Deployment Architecture
Deployment
|
▼
ReplicaSet
|
▼
Pod
|
▼
NGINX Container
এখানে Deployment একটি Higher-Level Kubernetes Object।
এটি ReplicaSet-এর মাধ্যমে Pods Manage করে।
18. Pod vs Deployment — পার্থক্য কী?
Pod এবং Deployment একই জিনিস নয়।
| Kubernetes Object | Purpose |
|---|---|
| Pod | এক বা একাধিক Containers Run করে |
| Deployment | Pods-এর Desired State এবং Lifecycle Manage করে |
Standalone Pod
kubectl run nginx --image=nginx
এই Command একটি Standalone Pod Create করে।
Pod
|
└── NGINX Container
Deployment
kubectl create deployment nginx --image=nginx
এই Command একটি Deployment Create করে।
Deployment
|
▼
ReplicaSet
|
▼
Pod
|
▼
NGINX Container
Standalone Pod Simple Testing-এর জন্য Useful।
কিন্তু Production Environment-এ Stateless Applications-এর জন্য সাধারণত Deployment Preferred।
কারণ Deployment Application-এর Desired State Maintain করতে সাহায্য করে।
19. Deployment কেন গুরুত্বপূর্ণ?
একটি Standalone Pod-এর কিছু Limitations আছে।
ধরো, তুমি একটি Pod Create করলে।
kubectl run nginx --image=nginx
এখন Container Crash করলে Kubelet Pod-এর Restart Policy অনুযায়ী Container Restart করার চেষ্টা করতে পারে।
কিন্তু Pod Delete হয়ে গেলে Standalone Pod Automatically নতুন করে Create হবে না।
অন্যদিকে Deployment ব্যবহার করলে Kubernetes নির্দিষ্ট সংখ্যক Pods Maintain করার চেষ্টা করে।
Deployment-এর গুরুত্বপূর্ণ Features:
- Replica Management
- Self-Healing
- Rolling Updates
- Rollbacks
- Scaling
- Declarative Management
Features Explained
| Feature | কেন গুরুত্বপূর্ণ |
|---|---|
| Self-Healing | Managed Pod Delete বা Fail হলে Replacement Pod Create করা যায় |
| Scaling | Application-এর Replica Count Increase বা Decrease করা যায় |
| Rolling Updates | Application-এর New Version Gradually Deploy করা যায় |
| Rollbacks | আগের Deployment Revision-এ ফিরে যাওয়া যায় |
| Declarative Management | YAML File-এর মাধ্যমে Desired State Define করা যায় |
Important: Deployment প্রধানত Stateless Applications Manage করার জন্য Commonly Used হয়।
20. Deployment দিয়ে Application Scaling
ধরো, আমরা একটি NGINX Deployment Create করেছি।
kubectl create deployment nginx --image=nginx
এখন Application-এর তিনটি Replicas দরকার।
Command:
kubectl scale deployment nginx --replicas=3
এই Command Kubernetes-কে বলে:
NGINX Application-এর তিনটি Pod Replicas Maintain করো।
Architecture
Deployment
|
▼
ReplicaSet
|
+----------+----------+
| | |
▼ ▼ ▼
Pod 1 Pod 2 Pod 3
| | |
▼ ▼ ▼
NGINX NGINX NGINX
এখন Kubernetes তিনটি Pods Running রাখার চেষ্টা করবে।
যদি একটি Pod Delete হয়ে যায়, ReplicaSet Replacement Pod Create করতে পারে।
Example
Before:
Deployment nginx
|
▼
1 Pod
After Scaling:
Deployment nginx
|
▼
3 Pods
এই Mechanism Application Availability এবং Scaling-এর জন্য গুরুত্বপূর্ণ।
21. Deployment YAML Example
Kubernetes Resources শুধু Commands দিয়ে নয়, YAML Manifest দিয়েও Create করা যায়।
ধরো, আমরা তিনটি NGINX Pods Maintain করতে চাই।
তাহলে deployment.yaml File Create করব।
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
YAML Breakdown
| Field | Meaning |
|---|---|
apiVersion | Kubernetes API Version |
kind | Resource Type |
metadata.name | Deployment Name |
replicas | Desired Number of Pods |
selector | কোন Pods Deployment Manage করবে |
template | Pod Template Definition |
containers | Pod-এর Container Configuration |
image | Container Image |
containerPort | Application Container Port |
Deployment Apply করা
kubectl apply -f deployment.yaml
এই Command YAML Manifest Kubernetes API Server-এ Submit করে।
Kubernetes তারপর Desired State অনুযায়ী Deployment, ReplicaSet এবং Pods Manage করে।
Verify করা
kubectl get deployments
তারপর:
kubectl get pods
Expected Example:
NAME READY STATUS
nginx-xxxxxxxxxx-aaaaa 1/1 Running
nginx-xxxxxxxxxx-bbbbb 1/1 Running
nginx-xxxxxxxxxx-ccccc 1/1 Running
এখানে তিনটি NGINX Pods Running রয়েছে।
22. kubectl কি সবসময় Deployment-এর মাধ্যমে কাজ করে?
না।
kubectl ব্যবহার করার জন্য Deployment বাধ্যতামূলক নয়।
kubectl Kubernetes-এর বিভিন্ন Resources Create, Update, Delete এবং Inspect করতে পারে।
যেমন:
- Pods
- Deployments
- Services
- ConfigMaps
- Secrets
- Jobs
- StatefulSets
- DaemonSets
অর্থাৎ kubectl একটি General Kubernetes Management CLI।
kubectl এবং Deployment-এর Relationship
kubectl
|
▼
Kubernetes API Server
|
├── Pod
|
├── Deployment
|
├── Service
|
├── ConfigMap
|
├── Secret
|
└── Other Resources
kubectl নিজে Deployment নয়।
Deployment হলো Kubernetes-এর একটি Resource Type।
একটি সহজ Rule
kubectl = Command-Line Tool
Deployment = Desired Application State
ReplicaSet = Desired Number of Pods Maintain করে
Pod = Container Run করে
23. কখন Pod আর কখন Deployment ব্যবহার করব?
এই Difference বোঝা গুরুত্বপূর্ণ।
| Use Case | Recommended Resource |
|---|---|
| Quick Container Test | Standalone Pod |
| Basic Kubernetes Learning | Standalone Pod |
| Temporary Debugging | Pod |
| Stateless Web Application | Deployment |
| Multiple Application Replicas | Deployment |
| Rolling Application Updates | Deployment |
| Automatic Pod Replacement | Deployment |
Quick Test-এর জন্য
kubectl run nginx --image=nginx
Proper Application Management-এর জন্য
kubectl create deployment nginx --image=nginx
Real Stateless Applications-এর জন্য সাধারণত Deployment বেশি Suitable।
24. Pod vs Deployment — Simple Mental Model
একটি সহজ Example দিয়ে পুরো Concept মনে রাখতে পারো।
ধরো, Pod হলো একজন Worker।
আর Deployment হলো এমন একজন Manager, যে নির্দিষ্ট সংখ্যক Workers Maintain করতে চায়।
Standalone Pod
Pod
|
▼
Worker
এই Worker Remove হয়ে গেলে তাকে Replace করার জন্য কোনো Higher-Level Controller নেই।
Deployment
Deployment Manager
|
▼
ReplicaSet
|
+---------+---------+
| | |
▼ ▼ ▼
Pod 1 Pod 2 Pod 3
| | |
Worker Worker Worker
এখন যদি একটি Pod Delete হয়ে যায়, ReplicaSet Desired Replica Count Maintain করার চেষ্টা করবে।
এটাই Deployment-এর Self-Healing এবং Replica Management-এর মূল ধারণা।
25. Complete Hands-On Commands — Pod এবং Deployment
এই Tutorial-এর সমস্ত গুরুত্বপূর্ণ Commands একসঙ্গে:
# ==========================================
# PART 1: STANDALONE POD
# ==========================================
# Check Kubernetes Cluster
kubectl get nodes
# Create NGINX Pod
kubectl run nginx --image=nginx
# List Pods
kubectl get pods
# Get Detailed Pod Information
kubectl describe pod nginx
# Show Pod IP and Node
kubectl get pods -o wide
# Delete Standalone Pod
kubectl delete pod nginx
# ==========================================
# PART 2: DEPLOYMENT
# ==========================================
# Create NGINX Deployment
kubectl create deployment nginx --image=nginx
# List Deployments
kubectl get deployments
# List Deployment Pods
kubectl get pods
# Scale Deployment to 3 Replicas
kubectl scale deployment nginx --replicas=3
# Verify Deployment
kubectl get deployments
# Verify Pods
kubectl get pods
# Delete Deployment
kubectl delete deployment nginx
26. Important Commands Summary
| Command | Purpose |
|---|---|
kubectl run nginx --image=nginx | Standalone Pod Create |
kubectl get pods | Pods List |
kubectl describe pod nginx | Detailed Pod Information |
kubectl get pods -o wide | Pod IP এবং Node Information |
kubectl delete pod nginx | Standalone Pod Delete |
kubectl create deployment nginx --image=nginx | Deployment Create |
kubectl get deployments | Deployments List |
kubectl scale deployment nginx --replicas=3 | Deployment Scale |
kubectl apply -f deployment.yaml | YAML Manifest Apply |
kubectl delete deployment nginx | Deployment Delete |
27. Final Takeaway — Kubernetes Pods & Deployments
এই Demo-এর সবচেয়ে গুরুত্বপূর্ণ বিষয় হলো Pod Create করা, Pod Inspect করা এবং Pod ও Deployment-এর Difference বোঝা।
একটি Pod Create করতে:
kubectl run nginx --image=nginx
Pod Status Check করতে:
kubectl get pods
Detailed Information দেখতে:
kubectl describe pod nginx
Pod IP এবং Node Information দেখতে:
kubectl get pods -o wide
আর Deployment Create করতে:
kubectl create deployment nginx --image=nginx
Application Scale করতে:
kubectl scale deployment nginx --replicas=3
Complete Kubernetes Workload Architecture
Developer
|
▼
kubectl
|
▼
Kubernetes API Server
|
▼
Deployment
|
▼
ReplicaSet
|
+-----------+-----------+
| | |
▼ ▼ ▼
Pod 1 Pod 2 Pod 3
| | |
▼ ▼ ▼
Container Container Container
| | |
▼ ▼ ▼
Application Application Application
Final Memory Rule
kubectl run
|
▼
Pod
kubectl create deployment
|
▼
Deployment
|
▼
ReplicaSet
|
▼
Pod
|
▼
Container
সবচেয়ে গুরুত্বপূর্ণ বিষয়: kubectl ব্যবহার করার জন্য Deployment বাধ্যতামূলক নয়। কিন্তু Real Stateless Applications-এর ক্ষেত্রে Deployment সাধারণত Preferred, কারণ Deployment Replica Management, Scaling, Self-Healing, Rolling Updates এবং Rollback Support Provide করে।
Official Documentation
- Kubernetes — Pods
- Kubernetes — Deployments
- Kubernetes — ReplicaSets
- kubectl run
- kubectl create deployment
- Kubernetes — Workload Management
One-Line Summary
Kubernetes-এ kubectl run দিয়ে একটি Standalone Pod Create করা যায়, আর kubectl create deployment দিয়ে একটি Deployment Create করা যায়। Deployment ReplicaSet-এর মাধ্যমে Pods Manage করে, যাতে Application-এর Desired Number of Replicas Running রাখা যায়।
