📘 Kubernetes Notes – Labels, ReplicaSet & Deployment
🔹 LABELS
Labels are key-value pairs attached to Kubernetes objects like:
-
Pods
-
ReplicaSets
-
Deployments
-
Services
-
Nodes
They are mainly used for:
-
Identification
-
Grouping
-
Selection
-
Management
Features
-
Can be added during creation or runtime
-
Multiple labels per object allowed
-
ReplicaSet/Service manages Pods only using labels
Example
Extra useful commands
🔹 SELECTORS
Selectors filter Pods using labels.
Used by:
-
ReplicaSet
-
Deployment
-
Service
Types
1️⃣ Equality-based
2️⃣ Set-based
Example
🔹 REPLICASET (RS)
ReplicaSet ensures desired number of Pods are always running.
Features
-
Creates multiple replicas
-
Auto recreates if Pod crashes/deletes
-
All Pods use same template
-
Uses Labels + Selectors
-
Supports scaling
-
No rolling updates (manual only)
Flow
Important
-
ReplicationController = Old version
-
ReplicaSet = New version
ReplicaSet YAML
ReplicaSet Commands
❌ ReplicaSet Limitations
-
No rolling updates
-
No rollback
-
No version control
-
Not preferred in production
👉 Mostly managed indirectly via Deployment.
🔹 DEPLOYMENT
Deployment = ReplicaSet + Advanced Features
It is the recommended way to manage Pods in production.
Features
✅ Rolling updates
✅ Rollback
✅ Zero downtime
✅ Version history
✅ Easy scaling
✅ Self-healing
Flow
Deployment YAML
Deployment Commands
Create
List
Scale
Edit image (update)
Rollout commands
Delete
🔹 Rolling Update Strategy (Important for Interviews)
Types
1️⃣ RollingUpdate (Default)
-
No downtime
-
Gradually replaces Pods
2️⃣ Recreate
-
Deletes all Pods first
-
Then creates new Pods
-
Causes downtime
🔹 Useful Extra Concepts
Scale automatically (HPA)
Check events
Logs
Exec into container
🔹 Quick Comparison Table
| Feature | ReplicaSet | Deployment |
|---|---|---|
| Scaling | ✅ | ✅ |
| Self-healing | ✅ | ✅ |
| Rolling update | ❌ | ✅ |
| Rollback | ❌ | ✅ |
| Version history | ❌ | ✅ |
| Production use | ❌ | ✅ |
Comments
Post a Comment