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.74k stars 176 forks source link

Feature request: a configuration file #384

Open alexppg opened 3 years ago

alexppg commented 3 years ago

It would be awesome to have the possibility to have a .kube-score.yml file in which we could configure whatever we need. I think at the time it would mostly be tests to ignore, but it may be interesting for the future.

This might serve as inspiration: https://docs.kubelinter.io/#/configuring-kubelinter

PD: Thanks for your work, kube-score is awesome!

day1118 commented 2 years ago

This would make using CI much easier, rather than having a long command line full of flags.

kmarteaux commented 2 years ago

@alexppg, @day1118, and @zegl

I have been playing around with this, since I agree a configuration file would be useful. My current local implementation is to generate the configuration file on-demand (kube-score mkconfig). The configuration file directives could be overridden at command line, preserving existing functionality/behavior. For example, one could still exclude a test using the --ignore-test flag without editing .kube-score.yml.

At present, the configuration looks as such --

$ ./kube-score mkconfig $ cat ./kube-score.yml (### BTW I know this isn't actually valid YAML yet. I'm still trying to settle on what it should look like ###)

object: CronJob checks:

object: Deployment checks:

object: HorizontalPodAutoscaler checks:

object: Ingress checks:

object: NetworkPolicy checks:

object: Pod checks:

object: PodDisruptionBudget checks:

object: Service checks:

object: StatefulSet checks:

object: all checks:

Is this in line with what you were envisioning as a user?

day1118 commented 2 years ago

Hi @kmarteaux - This is great news!

I had assumed the syntax would be as simple as matching the cli flags. This would make it very easy to follow and reason about:

disableIgnoreChecksAnnotations: false
enableOptionalTest:
 - test1
 - test2
ignoreTest:
 - test3
 - test4

I do think the syntax that you have proposed feels like overkill, but either way, I think it would be more natural to replace status: "on" with enabled: true

Thanks

kmarteaux commented 2 years ago

Anthony, thanks for the feedback. That is why I asked, it felt like I was overthinking it. I will adjust accordingly.

alexppg commented 2 years ago

I agree with @day1118. It seems a pretty understandable approach. Thanks @kmarteaux !