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

kube-score container gives error on variable #441

Closed Purneau closed 2 years ago

Purneau commented 2 years ago

Which version of kube-score are you using?

kube-score version: v.1.14.0

What did you do?

We try to include kube-score in our CI pipeline following this example: https://github.com/Azure/arc-cicd-demo-src/blob/master/.pipelines/code-quality-template.yaml When we scan the Chart.yaml we get no output. Based on your example, we instead scan the <chart_folder>/templates/*.yaml but then we get the following error:

Failed to score files: Failed to parse /, Kind=: err=yaml: invalid map key: map[interface {}]interface {}{".Values.frontend.hostname":interface {}(nil)}

However, if we use the kube-score:latest-helm3 container, log into it and repeat the same command there manually, we get a correct scan report. So we don't really suspect something is wrong with our yaml files.

What did you expect to see?

Based on the refered to Chart.yaml a correct scan report of all underlying templates.

What did you see instead?

Above error

Can you please indicate if we should use the latest of latest-helm3 container if we want to scan a helm chart in our pipeline non-interactively? Which file(s) should we point to to scan?

Thanks

zegl commented 2 years ago

Hey @Purneau,

kube-score can only scan and validate valid YAML files (of the same type as the Kubernetes API is using). If you're using any templating language or tool to create your YAML files, you'll need to generate the files first, before sending them to kube-score.

Here's an example of how to do this with Helm: https://github.com/zegl/kube-score#example-with-helm

Thanks