stackrox / kube-linter

KubeLinter is a static analysis tool that checks Kubernetes YAML files and Helm charts to ensure the applications represented in them adhere to best practices.
https://docs.kubelinter.io/
Apache License 2.0
2.97k stars 234 forks source link

[FEATURE_REQUEST] Support HPA maxReplicas #608

Open BlythMeister opened 1 year ago

BlythMeister commented 1 year ago

Description of the problem/feature request Add check for HPA maxReplicas which functions in the same way as minReplicas

Additional context We are migrating from datree and this was a check they have: https://hub.datree.io/built-in-rules/ensure-hpa-maximum-replicas

janisz commented 1 year ago

As @BlythMeister pointed we already have https://github.com/stackrox/kube-linter/blob/6ba361ac592fbb27e520ff04610799bdbeb21624/pkg/templates/hpareplicas/template.go#L18 template but it's limited to check minimum. Maybe we should add a new template that will check if replicas is in range and reuse it in min replicas to keep backward compatibility.

BlythMeister commented 1 year ago

As a use case, maximum is useful in a larger org to ensure someone doesn't go crazy on HPA and set like max 50 (don't ask me why...please don't ask me why!)