Course contentsShow
← Cloud and Infrastructure
Lesson 1182 of 2,98923. Kubernetes WorkloadsFree lesson

StatefulSet Update Strategies

Configuring RollingUpdate and OnDelete strategies for StatefulSet pod updates.

StatefulSet Update Strategies

What you'll learn: How to control how StatefulSet pods are replaced during updates using RollingUpdate and OnDelete strategies.

Why Update Strategies Matter

When you modify a StatefulSet's pod template (new image version, changed config), Kubernetes needs a plan for replacing the existing pods. Unlike Deployments that can update any replica in parallel, StatefulSets respect pod identity and order—so your update strategy directly affects availability and safety.

The Two Update Strategies

RollingUpdate (Default)

With RollingUpdate, Kubernetes automatically replaces pods one at a time, in reverse ordinal order (highest to lowest). If you have pods myapp-0, myapp-1, and myapp-2, Kubernetes updates myapp-2 first, waits for it to become ready, then moves to myapp-1, then myapp-0.

Analogy: Like upgrading train cars while the train is running—you replace the caboose first, wait until it's stable, then move forward car by car.

You can configure a partition parameter to control how many pods stay on the old version. For example, partition: 2 means only pods with ordinal ≥2 get updated, leaving lower-numbered pods alone (useful for canary testing).

OnDelete

With OnDelete, Kubernetes does nothing automatically. Pods keep running the old version until you manually delete them. When you delete a pod, the StatefulSet controller recreates it with the new template.

Analogy: Manual gear shift—you decide exactly when each pod gets replaced by explicitly deleting it.

This gives you complete control over update timing and sequence, useful when you need careful coordination or custom rollout logic.

Configuration

Set the update strategy in your StatefulSet manifest:

spec:
  updateStrategy:
    type: RollingUpdate  # or OnDelete

Key Takeaway: RollingUpdate automates ordered pod replacement (with optional partitioning), while OnDelete lets you manually trigger updates by deleting pods—choose based on how much control you need over the rollout process.