liveBook · Manning

OnDelete update strategy

As explained in Kubernetes in Action, Second Edition

A Kubernetes StatefulSet update strategy that applies a new pod template only when an existing pod is manually deleted.

OnDelete is a StatefulSet update strategy for replacing pods at your own pace. Applying a changed Pod template does nothing immediately; the controller creates a new-template replacement only after you manually delete an existing pod. section 16.3 section 16.3.3

Configure and perform a controlled update

Set the strategy in the StatefulSet manifest: `spec: updateStrategy: type: OnDelete`. After applying a template that changes the `quiz-api` image from version 0.1 to 0.2, delete `quiz-0`. The controller recreates `quiz-0` from the new template; delete the remaining pods when their workloads are ready for replacement. section 16.3.3

OnDelete changes the normal StatefulSet rollout responsibilities:

  • Chooses which pod to update and when; pods can be deleted in any order and at any rate. section 16.3 section 16.3.3
  • Requires readiness judgment from the operator; the controller replaces a deleted pod even when it was not ready, and continues if the replacement is not ready. section 16.3.3
  • Makes rollback semi-automatic as well: `kubectl rollout undo` changes the revision, but each pod must still be deleted to receive it. section 16.3.3
  • Differs from RollingUpdate, which replaces StatefulSet pods automatically one by one, and from Deployment Recreate, which replaces all pods automatically. section 16.3
Table 16.2 The supported StatefulSet update strategies
Value
Description
RollingUpdate
In this update strategy, the pods are replaced one by one. The pod with the highest ordinal number is deleted first and replaced with a pod created with the new template. When this new pod is ready, the pod with the next highest ordinal number is replaced. The process continues until all pods have been replaced. This is the default strategy.
OnDelete
The StatefulSet controller waits for each pod to be manually deleted. When you delete the pod, the controller replaces it with a pod created with the new template. With this strategy, you can replace pods in any order and at any rate.

Compare StatefulSet update strategies and see how OnDelete delegates replacement timing and ordering to manual pod deletion. section 16.3

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains configuration, replacement lifecycle, ordering, readiness implications, and rollback, but does not detail controller internals.
Examples
Uses an apps/v1 quiz StatefulSet, a versioned container image, manual deletion of quiz-0, and mixed-version pod listings.
What it assumes
Assumes familiarity with StatefulSets, pods, Pod templates, kubectl apply, pod deletion, and rollout undo.
What you can do after
Operate/configure a StatefulSet rollout by applying a template, deleting selected pods, checking readiness, and manually completing or rolling back updates.
How it connects
Connects StatefulSets with Pod templates, RollingUpdate, Deployment strategies, readiness, revisions, and rollback.

Related concepts

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