0
0
Kubernetesdevops~10 mins

Desired replicas vs actual replicas in Kubernetes - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Desired replicas vs actual replicas
User sets desired replicas
Kubernetes Controller Manager
Check current actual replicas
Actual < Desired
Create pods
Update actual replicas count
Match desired replicas?
NoRepeat check
Yes
Stable state
This flow shows how Kubernetes compares desired replicas with actual pods and adjusts by creating or deleting pods until they match.
Execution Sample
Kubernetes
kubectl scale deployment myapp --replicas=3
kubectl get deployment myapp
Set desired replicas to 3 and check actual replicas running in the deployment.
Process Table
StepDesired ReplicasActual ReplicasAction TakenResult
131Create 2 podsActual replicas increase to 3
233No actionDesired matches actual, stable state
323Delete 1 podActual replicas decrease to 2
422No actionDesired matches actual, stable state
💡 Execution stops when actual replicas equal desired replicas, indicating stable deployment state.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4
Desired Replicas33322
Actual Replicas13322
Key Moments - 2 Insights
Why does Kubernetes create or delete pods instead of instantly matching desired replicas?
Kubernetes adjusts pods gradually to ensure stability and avoid sudden disruptions, as shown in steps 1 and 3 where pods are created or deleted step-by-step.
What happens if actual replicas are already equal to desired replicas?
No action is taken and the system remains stable, as seen in steps 2 and 4 where desired equals actual and no changes occur.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the actual replicas count after step 1?
A3
B1
C2
D0
💡 Hint
Refer to the 'Actual Replicas' column in row for step 1.
At which step does Kubernetes delete a pod to match desired replicas?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'Action Taken' column for the step where pods are deleted.
If desired replicas were set to 4 at start, how would the actual replicas change after step 1?
AIncrease to 3
BIncrease to 4
CDecrease to 1
DStay at 1
💡 Hint
Look at how actual replicas adjust to match desired replicas in the variable_tracker.
Concept Snapshot
Desired replicas are the number of pods you want running.
Actual replicas are the pods currently running.
Kubernetes controller compares these and creates or deletes pods to match.
This ensures your app runs the right number of instances.
Stable state is when desired equals actual replicas.
Full Transcript
In Kubernetes, you set the desired number of pod replicas for your app. The system checks how many pods are actually running. If fewer pods run than desired, Kubernetes creates more pods. If more pods run than desired, it deletes some. This process repeats until the actual number matches the desired number. When they match, the deployment is stable. This ensures your app has the right capacity to handle traffic.