zegl / kube-score

Kubernetes object analysis with recommendations for improved reliability and security. kube-score actively prevents downtime and bugs in your Kubernetes YAML and Charts. Static code analysis for Kubernetes.
https://kube-score.com
MIT License
2.75k stars 177 forks source link

Add check for replicas > 1 #569

Closed joshiste closed 9 months ago

joshiste commented 9 months ago

There is no check for the configured number of replicas.

From a resilience perspective, it would be reasonable to add a warning for statefulsets/deployments targeted by a service, and have the replica unset or = 1 and not have a horizontal pod autoscaler. For the same reason, if they have a horizontal pod auto scaler, it should be checked for minReplicas = 1.

KubeLinter has both of these checks. Let me know what you think. If you find this acceptable, I'd happily contribute a PR.

zegl commented 9 months ago

I think that this makes sense.

We should have a warning for: Deployments, that are not targeted by a HorizontalPodAutoscaler, that are targeted by Services, where replicas is unset or explicitly set to 1.

I don't think that the same can be said for StatefulSets. StatefulSets are usually trickier to scale, and the warning would in many cases not be actionable. Which would just lead to the warning being ignored.

PRs are very welcome :)