cdk8s-team / cdk8s-plus

A software development framework that provides high level abstractions for authoring Kubernetes applications.
https://cdk8s.io/docs/latest/plus/
Apache License 2.0
136 stars 34 forks source link

Configure default replica count > 1 on workloads #812

Closed iliapolo closed 2 years ago

iliapolo commented 2 years ago

Let's just have 2 replicas by default.

Additional resources

iliapolo commented 2 years ago

Does it make sense for StatefulSet?

vinayak-kukreja commented 2 years ago

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?