Reputation: 523
Is there a way to ensure that pods are scaled one at a time when setting replica greater than one?
Example: Replica set to 3
Upvotes: 3
Views: 1236
Reputation: 2422
You can acomplish this behavior using StatefulSets
. As it goes from Kubernetes docs
- For a StatefulSet with N replicas, when Pods are being deployed, they are created sequentially, in order from {0..N-1}.
- When Pods are being deleted, they are terminated in reverse order, from {N-1..0}.
- Before a scaling operation is applied to a Pod, all of its predecessors must be Running and Ready.
- Before a Pod is terminated, all of its successors must be completely shutdown.
So, as you can see here, new pod is not booted up until previous one is initializing.
Note: this behavior is guranteed by Kubernetes when OrderedReady
pod management policy is used (which is default).
Upvotes: 4