instrumenta / kubeval

Validate your Kubernetes configuration files, supports multiple Kubernetes versions
https://kubeval.com
Other
3.17k stars 229 forks source link

kubeval of "helm create test-helm" fails #340

Open gmacario opened 2 years ago

gmacario commented 2 years ago

Hello and apologies in advance if this is a newbie question.

I have been experiencing troubles in having kubeval validate even simple Helm charts - see https://github.com/aquariophilie/node-koa-boilerplate/pull/9 as an example.

I managed to reproduce the problem with one of the easiest test I could think about

helm version
helm create test-helm

docker run -it \
    -v `pwd`/test-helm:/test-helm \
    garethr/kubeval test-helm/*

Here is the result:

gmacario@gmpowerhorse:~ $ helm version
version.BuildInfo{Version:"v3.7.0", GitCommit:"eeac83883cb4014fe60267ec6373570374ce770b", GitTreeState:"clean", GoVersion:"go1.16.8"}
gmacario@gmpowerhorse:~ $ helm create test-helm
Creating test-helm
gmacario@gmpowerhorse:~ $ docker run -it \
>     -v `pwd`/test-helm:/test-helm \
>     garethr/kubeval test-helm/*
ERR  - Could not open file test-helm/charts
ERR  - test-helm/Chart.yaml: Missing 'metadata' key
ERR  - Could not open file test-helm/templates
ERR  - test-helm/values.yaml: Missing 'metadata' key
gmacario@gmpowerhorse:~ $

You can find more details at https://github.com/aquariophilie/node-koa-boilerplate/issues/7 and https://github.com/aquariophilie/node-koa-boilerplate/pull/10

Thanks for your attention -- Gianpaolo

jakuboskera commented 2 years ago

According docs https://www.kubeval.com/#helm.

If you do helm template for generating RAW YAML manifests, then this output contains comments with path for these templates e.g. # Source: my-chart/templates/frontend.yaml. This output can be sent to kubeval which will validate every YAML manifest according the path in the comment.

Something like this could work

$ helm template my-chart ./my-chart | kubeval

PASS - my-chart/templates/frontend.yaml contains a valid Deployment (default.frontend)