0
0
Kubernetesdevops~10 mins

Recreate update strategy in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Recreate update strategy
Start Deployment
Delete all old Pods
Wait for all old Pods to terminate
Create new Pods
Wait for new Pods to be Ready
Deployment Complete
The Recreate update strategy deletes all old pods before creating new ones, ensuring no overlap between old and new versions.
Execution Sample
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deploy
spec:
  strategy:
    type: Recreate
This YAML snippet defines a Deployment using the Recreate update strategy to replace pods.
Process Table
StepActionOld Pods StateNew Pods StateDeployment Status
1Start Deployment3 Running0In Progress
2Delete all old Pods3 Terminating0In Progress
3Wait for old Pods to terminate00In Progress
4Create new Pods03 PendingIn Progress
5New Pods become Ready03 RunningComplete
💡 All old pods terminated and new pods are running, deployment complete.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Old Pods3 Running3 Terminating000
New Pods0003 Pending3 Running
Deployment StatusNot StartedIn ProgressIn ProgressIn ProgressComplete
Key Moments - 2 Insights
Why are all old pods deleted before new pods are created?
Because the Recreate strategy ensures no overlap between old and new pods to avoid conflicts, as shown in execution_table steps 2 and 4.
What happens if new pods fail to become ready after old pods are deleted?
Deployment will be stuck waiting at step 5, since the strategy waits for new pods to be ready before completing.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the state of old pods at step 3?
A3 pods running
B0 pods running
C3 pods terminating
D0 pods pending
💡 Hint
Refer to the 'Old Pods State' column at step 3 in the execution_table.
At which step do new pods start to be created?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Check the 'Action' column for when new pods are created in the execution_table.
If the strategy was changed to RollingUpdate, how would the execution_table change?
AOld and new pods would run simultaneously during update
BAll old pods would be deleted before new pods start
CNew pods would never be created
DDeployment would complete immediately
💡 Hint
Recreate deletes old pods first; RollingUpdate allows overlap, so see difference in pod states.
Concept Snapshot
Recreate update strategy in Kubernetes:
- Deletes all old pods before creating new ones
- Ensures no overlap between old and new pods
- Deployment waits for old pods termination before new pods start
- Simple but causes downtime during update
- Defined in Deployment spec under strategy.type = Recreate
Full Transcript
The Recreate update strategy in Kubernetes replaces all old pods by first deleting them all, then creating new pods. This means there is downtime because no pods run during the switch. The deployment process starts by deleting old pods, waits for them to terminate, then creates new pods and waits for them to be ready before marking deployment complete. This strategy is simple and ensures no overlap between old and new versions, but causes downtime during updates.