Partition-Based Rolling Updates
What you'll learn: How to use the partition parameter in StatefulSets to implement controlled, canary-style rollouts by dividing your pods into updating and stable groups.
The Core Idea
When using RollingUpdate strategy in StatefulSets, you can specify a partition value that acts as a boundary. Only pods with an ordinal greater than or equal to the partition number will be updated when you change the pod template. Pods below that ordinal remain untouched, running the old version.
Think of it like renovating hotel rooms floor-by-floor. If you set a partition at floor 5, only rooms on floor 5 and above get renovated. Floors 1-4 keep their existing setup until you lower the partition number.
How It Works
In your StatefulSet manifest, add the partition field under updateStrategy:
spec:
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 3
If you have a StatefulSet with 5 replicas (pods 0-4), setting partition: 3 means:
- Pods 3 and 4 will update to the new template immediately
- Pods 0, 1, and 2 stay on the old version
This enables canary deployments: test your changes on higher-ordinal pods first, verify they work correctly, then gradually lower the partition (e.g., to 2, then 1, then 0) to roll out to all pods.
Phased Rollout Control
By adjusting the partition incrementally, you gain fine-grained control over rollout speed and blast radius. If issues arise with pods 3-4, you haven't impacted the majority of your StatefulSet.
Key Takeaway: The partition parameter gives you precise control over StatefulSet updates, letting you roll out changes to specific pods first—perfect for canary testing and low-risk, phased deployments.