liveBook · Manning

Recreate strategy

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A recreate strategy terminates all old workload instances before starting instances of the new version.

A recreate strategy stops every pod from the old ReplicaSet before starting pods from the new version. The application therefore experiences downtime, but the rollout is fast and avoids running multiple application versions simultaneously. section 5.1.2

Use this strategy when:

  • The application cannot support multiple versions running together, such as when database locks create compatibility problems. section 5.1.2
  • The fastest rollout is preferred and planned downtime is acceptable. section 5.1.2
  • Set spec.strategy.type to Recreate and remove rollingUpdate, maxSurge, and maxUnavailable fields. section 5.1.2

Configure and verify a recreate rollout

Edit the Deployment with kubectl edit deploy apache, change the strategy type from RollingUpdate to Recreate, and remove the rolling-update fields. Use kubectl explain deploy.spec.strategy when checking valid YAML fields. section 5.1.2

Figure 5.9 The update process for a Deployment when deleting and creating new replicas
figure

Follow the update sequence showing old replicas being deleted before new replicas are created. section 5.1.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains pod replacement order, YAML changes, speed, and downtime without detailing controller internals.
Examples
Uses kubectl edit deploy apache, strategy YAML fields, kubectl explain, and an update-process diagram.
What it assumes
Assumes familiarity with Deployments, ReplicaSets, pods, and Deployment YAML.
What you can do after
Operate/configure a Deployment with Recreate and verify its rollout sequence using kubectl.
How it connects
Connects Deployments, ReplicaSets, rolling updates, database locks, and downtime.

Also explained in

Compare how 3 books explain Recreate strategy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.