0
0
Kubernetesdevops~10 mins

Scaling Deployments in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Scaling Deployments
Start: Deployment with 1 replica
Check desired replicas
kubectl scale command issued
Kubernetes updates Deployment spec
ReplicaSet adjusts pods count
New pods created or removed
Deployment reaches desired replicas
End
This flow shows how Kubernetes scales a Deployment by changing the number of pod replicas to match the desired count.
Execution Sample
Kubernetes
kubectl get deployment myapp
kubectl scale deployment myapp --replicas=3
kubectl get pods
This sequence checks current deployment, scales it to 3 replicas, then lists pods to show the change.
Process Table
StepCommandActionDeployment ReplicasPods RunningResult
1kubectl get deployment myappCheck current replicas11Shows 1 replica running
2kubectl scale deployment myapp --replicas=3Request scale to 3 replicas1 -> 31Deployment spec updated, pods not yet changed
3Kubernetes ReplicaSetCreates 2 new pods33Pods count matches desired replicas
4kubectl get podsList pods after scaling33Shows 3 pods running
5-No further action33Scaling complete
💡 Scaling stops when pods running equals desired replicas (3)
Status Tracker
VariableStartAfter Step 2After Step 3Final
Deployment Replicas1333
Pods Running1133
Key Moments - 2 Insights
Why does the number of pods not change immediately after the scale command?
After the scale command (Step 2), the Deployment spec updates but Kubernetes needs time to create new pods, which happens in Step 3.
What ensures the pods count matches the desired replicas?
The ReplicaSet controller monitors the Deployment and creates or deletes pods to match the desired replicas, as seen in Step 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step do the pods running first reach 3?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Check the 'Pods Running' column in the execution table rows
According to the variable tracker, what is the value of Deployment Replicas after Step 2?
A1
B2
C3
D0
💡 Hint
Look at the 'Deployment Replicas' row under 'After Step 2' in variable_tracker
If the scale command was to 5 replicas instead of 3, how would the pods running change in Step 3?
APods running would be 3
BPods running would be 5
CPods running would stay at 1
DPods running would be 0
💡 Hint
Refer to how pods running match desired replicas in the execution_table Step 3
Concept Snapshot
Scaling Deployments in Kubernetes:
- Use 'kubectl scale deployment <name> --replicas=N' to set desired pods
- Deployment updates desired replicas count
- ReplicaSet creates or deletes pods to match desired replicas
- Pods running eventually equals desired replicas
- Check status with 'kubectl get deployment' and 'kubectl get pods'
Full Transcript
Scaling a Kubernetes Deployment means changing how many copies of your app run. You start with a Deployment having 1 pod. When you run 'kubectl scale deployment myapp --replicas=3', Kubernetes updates the Deployment to want 3 pods. The ReplicaSet then creates 2 more pods to reach 3 total. You can see this by listing pods. The process stops when pods running equals the desired replicas. This ensures your app can handle more or less load by adjusting pod count.