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.77k stars 178 forks source link

Feature Request: ignore specific test but keep the error presented #371

Open devopsmash opened 3 years ago

devopsmash commented 3 years ago

Hi!

I'm using the kube-score to check my k8s objects/resources and it will be awesome if you can present the error even if I ignored that test but still exit without error.

Example without ignore

helm template mychart . | kube-score score

# output
apps/v1/Deployment appclient                                                  ๐Ÿ’ฅ
    [CRITICAL] Deployment targeted by HPA does not have replicas configured
        ยท The deployment is targeted by a HPA, but a static replica count is configured in the DeploymentSpec
            When replicas is both statically set and managed by the HPA, the
            replicas will be changed to the statically configured count when the
            spec is applied, even if the HPA wants the replica count to be
            higher.
autoscaling/v2beta2/HorizontalPodAutoscaler appclient                         โœ…
networking.k8s.io/v1beta1/Ingress appclient                                   โœ…
v1/Service appclient                                                          โœ…

# exit 1

with ignore

helm template mychart . | kube-score score --ignore-test deployment-targeted-by-hpa-does-not-have-replicas-configured

# output:
apps/v1/Deployment appclient                                                  โœ…
autoscaling/v2beta2/HorizontalPodAutoscaler appclient                         โœ…
networking.k8s.io/v1beta1/Ingress appclient                                   โœ…
v1/Service appclient                                                          โœ…

# exit 0

suggestion --show-ignored-test-error:

helm template mychart . | kube-score score --show-ignored-test-error --ignore-test deployment-targeted-by-hpa-does-not-have-replicas-configured

# output:
apps/v1/Deployment appclient                                                  ๐Ÿ’ฅ
    [CRITICAL] Deployment targeted by HPA does not have replicas configured
        ยท The deployment is targeted by a HPA, but a static replica count is configured in the DeploymentSpec
            When replicas is both statically set and managed by the HPA, the
            replicas will be changed to the statically configured count when the
            spec is applied, even if the HPA wants the replica count to be
            higher.
autoscaling/v2beta2/HorizontalPodAutoscaler appclient                         โœ…
networking.k8s.io/v1beta1/Ingress appclient                                   โœ…
v1/Service appclient                                                          โœ…

# exit 0

Thank you for your great work!

hans-d commented 3 years ago

Yes, showing as warning instead of error would be great.