Closed iliapolo closed 2 years ago
Does it make sense for StatefulSet
?
I believe it's good to have this for StatefulSet
too. As mentioned in their documentation,
In the above, stable is synonymous with persistence across Pod (re)scheduling. If an application doesn't require any stable identifiers or ordered deployment, deletion, or scaling, you should deploy your application using a workload object that provides a set of stateless replicas. [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) or [ReplicaSet](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/) may be better suited to your stateless needs.
For instance, considering we have a MySQL cluster. We would want to have its replica for availability and reliability in case the main pod has an issue. Till the main pod is refreshed, the traffic would be routed to the replica instead.
One more thing to note here is,
If a [HorizontalPodAutoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) (or any similar API for horizontal scaling) is managing scaling for a Statefulset, don't set .spec.replicas. Instead, allow the Kubernetes [control plane](https://kubernetes.io/docs/reference/glossary/?all=true#term-control-plane) to manage the .spec.replicas field automatically.
This probably can be a check in our L2?
Let's just have 2 replicas by default.
Additional resources