β οΈ IMPORTANT NOTE (Pehle padh lo)
Ye README sirf command list nahi hai.
Ye ek story + logic + live proof hai.Agar tum isko step-by-step follow kar loge na,
to RollingUpdate zindagi bhar nahi bhoologe.
Kubernetes Deployment ke andar mainly 2 strategies hoti hain:
π Is poore lab me hum RollingUpdate ko andar tak khol ke samjhenge.
Is lab ke baad tum confidently ye bol paoge:
kubectl get rs kyun sabse important command haimaxSurge aur maxUnavailable ka real mathskubectl configureddocker push riteshatri/deploymentrollingupdate:v1
docker push riteshatri/deploymentrollingupdate:v2
docker push riteshatri/deploymentrollingupdate:v3
π Har image ke andar alag index.html hai
taaki browser me clearly pata chale kaunsa version chal raha hai.
| File | Purpose |
|---|---|
| deployment.yaml | RollingUpdate Deployment |
| service.yaml | Application expose |
| index.html | Visual proof |
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploymentrollingupdate
spec:
replicas: 20
selector:
matchLabels:
humhai: rollingupdate
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
humhai: rollingupdate
spec:
containers:
- name: ritcontainer
image: riteshatri/deploymentrecreate:v1
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: ritservice
spec:
selector:
humhai: rollingupdate
ports:
- port: 6541
targetPort: 80
type: LoadBalancer
Tumne Kubernetes ko ye bola:
Minimum pods alive = 20 - 1 = 19
Maximum pods allowed = 20 + 1 = 21
π Isi maths ki wajah se downtime nahi hota.
kubectl apply -f deployment.yaml
kubectl get deployment
kubectl get pods
kubectl get rs
Browser me open:
http://<EXTERNAL-IP>:6541
Deployment file me image update karo:
image: riteshatri/deploymentrecreate:v2
Apply:
kubectl apply -f deployment.yaml
Ab turant check karo:
kubectl get pods
kubectl get rs
π PEHLE NAYA POD BANTA HAI
Old RS β 20 Pods
New RS β 1 Pod
Total β 21 Pods (maxSurge allow karta hai)
Website UP Rehti hai β
Old RS β 19 Pods
New RS β 1 Pod
Total β 20 Pods
π Minimum availability maintained.
+1 New Pod β -1 Old Pod
+1 New Pod β -1 Old Pod
...
(20 times)
kubectl get pods -w
kubectl get rs -w
Tum literally dekhoge:
Browser refresh karte raho β β downtime nahi
image: riteshatri/deploymentrecreate:v3
kubectl apply -f deployment.yaml
kubectl get pods
kubectl get rs
Browser me: π RollingUpdate β Version 3
Sirf is case me:
maxSurge: 0
maxUnavailable: 1
Flow:
-1 Old Pod β +1 New Pod
β οΈ Ye risky hota hai.
| Setting | Behaviour |
|---|---|
| maxSurge: 1 | Pehle new pod |
| maxUnavailable: 1 | Phir old pod delete |
| Dono = 1 | Create β Delete |
| Recreate | Delete β Create |
RollingUpdate = Pehle naya lao, phir purana hatao π₯
Agar:
π RollingUpdate hi use hota hai.
RITESH SHARMA
Created for Kubernetes Hands-on Learning
Happy Learning βΈοΈπ₯
Content type
Image
Digest
sha256:14fa6395bβ¦
Size
21.9 MB
Last updated
9 months ago
docker pull riteshatri/deploymentrollingupdate:v3