Scaling, and Rollback Techniques – Practical Assessment Covers
All Tasks – Tasks 1–5 include:
| Rolling updates (Task 4) |Blue-green deployments (Task 5) | Scaling
(Task 3) Service routing (Task 2) | Basic deployments (Task 1 ) |
500+ epert curated questions and answers
1. What is a Deployment Object?
A Deployment is a Kubernetes controller that provides declarative
updates for Pods and ReplicaSets. It allows you to:
Deploy and manage stateless applications
Scale replica Pods up/down
Perform rolling updates and rollbacks
Ensure self-healing (auto-replaces failed Pods)
Key Characteristics
Declarative: You describe the desired state in YAML/JSON
Managed: Kubernetes continuously works to match actual state to
desired state
Versioned: Maintains rollout history for rollbacks
2. Deployment vs Other Objects
Managed
Object Purpose Best For
By
Deploym Manages Pods via Kubernete Stateless apps (web
ent ReplicaSets s servers, APIs)
StatefulS Manages stateful Kubernete Databases (MySQL,
et applications s MongoDB)
Daemon Runs one Pod per Kubernete Node-level services
Set node s (logging, monitoring)
Single instance of a You
Pod Testing, one-off tasks
container (manually)
3. Core Components of a Deployment
,A Deployment consists of:
Pod Template: Defines the container(s) to run
ReplicaSet: Ensures the desired number of Pods are running
Update Strategy: Controls how updates are applied
4. Deployment YAML Structure
Here's a complete annotated example:
yaml
Copy
apiVersion: apps/v1 # API version (always apps/v1 for
Deployments)
kind: Deployment # Resource type
metadata:
name: nginx-deployment # Unique identifier
labels:
app: nginx # Labels for selection
spec:
replicas: 3 # Number of Pod replicas
selector:
matchLabels: # MUST match template labels
app: nginx
strategy:
type: RollingUpdate # Default strategy
rollingUpdate:
maxSurge: 1 # Extra Pods allowed during update
maxUnavailable: 0 # Max unavailable Pods during update
template: # Pod template
metadata:
, labels:
app: nginx # MUST match selector
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
resources:
limits:
cpu: "500m" # CPU limit
memory: "512Mi" # Memory limit
livenessProbe: # Health check
httpGet:
path: /
port: 80
initialDelaySeconds: 15
5. How Deployments Work
You create a Deployment (via CLI or YAML)
Deployment creates a ReplicaSet
ReplicaSet creates Pods
During updates:
New ReplicaSet is created
Pods are gradually replaced (unless Recreate strategy)
If failure occurs:
Auto-rollback to previous version (if configured)
Auto-replacement of failed Pods
6. Key Features
, A. Rolling Updates
Default strategy (RollingUpdate)
Gradually replaces old Pods with new ones
Zero downtime when configured properly
Example update flow:
Current: 3 Pods (v1)
Update triggered: 1 new Pod (v2) created
1 old Pod (v1) terminated
Repeat until all Pods are v2
B. Rollbacks
sh
Copy
kubectl rollout undo deployment/nginx-deployment
kubectl rollout history deployment/nginx-deployment
C. Scaling
sh
Copy
kubectl scale deployment/nginx-deployment --replicas=5
D. Auto-healing
Continuously monitors Pod health
Replaces failed Pods automatically
Respects PodDisruptionBudgets
7. Common Use Cases
Web Applications: Nginx, Apache, Node.js
APIs: REST, GraphQL services
Microservices: Stateless backend services
Workers: Background job processors
8. Best Practices