Scale a StatefulSet
Not all stateful applications scale nicely. If you are unsure about whether to scale your StatefulSets, see or StatefulSet tutorial for further information.
You should perform scaling only when you are confident that your stateful application cluster is completely healthy.
Change the number of replicas of your StatefulSet:
Alternatively, you can do in-place updates on your StatefulSets.
If your StatefulSet was initially created with kubectl apply
, update of the StatefulSet manifests, and then do a kubectl apply
:
Or use kubectl patch
:
You cannot scale down a StatefulSet when any of the stateful Pods it manages is unhealthy. Scaling down only takes place after those stateful Pods become running and ready.
If spec.replicas > 1, Kubernetes cannot determine the reason for an unhealthy Pod. It might be the result of a permanent fault or of a transient fault. A transient fault can be caused by a restart required by upgrading or maintenance.
If the Pod is unhealthy due to a transient fault and the Pod might become available again, the transient error may interfere with your scale-up or scale-down operation. Some distributed databases have issues when nodes join and leave at the same time. It is better to reason about scaling operations at the application level in these cases, and perform scaling only when you are sure that your stateful application cluster is completely healthy.
- Learn more about deleting a StatefulSet.