skip to content
Alvin Lucillo

Recreate and RollingUpdate strategies

/ 2 min read

With the k describe output below, we can see the difference between the two strategies.

First one is a from a deployment that uses Rolling Update strategy. Before updating the image via k set image, the old replica frontend-6765b99794 has 4 pods. After setting the image, you can see that incrementally, 1 by 1, new replica set frontend-854b57fbbf is scaled up while new replica set frontend-6765b99794 is scaled down. Scaling up adds new pod/replica, scaling down reduces pod/replica. The total replicas set in the deployment is 4. The maximum number of replicas that can be added is determined by maxUnavailable, which is set to 25% (i.e., 1 replica since 25% of 4 total replicas is 1). On the other hand, the maximum number of replicas that can be unavailable is also 25% of the total replicas.

This is the default strategy of a deployment.

RollingUpdateStrategy:  25% max unavailable, 25% max surge
...
OldReplicaSets:  frontend-6765b99794 (0/0 replicas created)
NewReplicaSet:   frontend-854b57fbbf (4/4 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  7m41s  deployment-controller  Scaled up replica set frontend-6765b99794 from 0 to 4
  Normal  ScalingReplicaSet  88s    deployment-controller  Scaled up replica set frontend-854b57fbbf from 0 to 1
  Normal  ScalingReplicaSet  88s    deployment-controller  Scaled down replica set frontend-6765b99794 from 4 to 3
  Normal  ScalingReplicaSet  88s    deployment-controller  Scaled up replica set frontend-854b57fbbf from 1 to 2
  Normal  ScalingReplicaSet  66s    deployment-controller  Scaled down replica set frontend-6765b99794 from 3 to 1
  Normal  ScalingReplicaSet  66s    deployment-controller  Scaled up replica set frontend-854b57fbbf from 2 to 4
  Normal  ScalingReplicaSet  44s    deployment-controller  Scaled down replica set frontend-6765b99794 from 1 to 0

Now, for the Recreate strategy, notice that all at once, the old replica set frontend-6765b99794 was scaled down to 0 and subsequently, the new replica set frontend-7c594bbd6d is scaled up to 4.

StrategyType:       Recreate
...
OldReplicaSets:  frontend-854b57fbbf (0/0 replicas created)
NewReplicaSet:   frontend-7c594bbd6d (4/4 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  ...
  Normal  ScalingReplicaSet  52s    deployment-controller  Scaled down replica set frontend-854b57fbbf from 4 to 0
  Normal  ScalingReplicaSet  20s    deployment-controller  Scaled up replica set frontend-7c594bbd6d from 0 to 4