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.65k stars 174 forks source link

Check "deployment-replicas" should consider minReplicas in HPA configuration #581

Closed ManuelGerding closed 4 months ago

ManuelGerding commented 5 months ago

Which version of kube-score are you using?

kube-score version: v1.17.0

What did you do?

I validated the replicas of a deployment that is targeted by a service and an HPA. However, the minReplicas of the HPA is set to 1. This is, according to kubernetes.io docs, also the default value.

What did you expect to see?

The deployment-replicas check (score/deployment/deployment.go#L54 ) should have warned me about a single replica. In my opinion, when having an HPA, a replica of 1 isn't considered reliable either.

What did you see instead?

The deployment-replicas check (score/deployment/deployment.go#L54 ) didn't warn about single replica. Looking at the source code, it explicitly mentions marking deployments targeted by an HPA as good. However, what's missing is the part to check the HPA's configuration and the configured minReplicas to really ensure having at least two replicas.

Happy to hear some more thoughts on this!

ManuelGerding commented 4 months ago

Does someone have an opinion on this? I just want to ensure that filing a pull request eventually has a chance of success as it is aligned with Kube-score's community.

zegl commented 4 months ago

Hey @ManuelGerding, I 100% agree with this issue! A HPA with minReplicas: 1 should be treated the same as if the Deployment had replicas: 1.