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
