instrumenta / kubeval

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

Include schema into binary/docker image for offline validation #21

Closed adrianchifor closed 7 years ago

adrianchifor commented 7 years ago

It would be great if the project had a version of the binary or docker image that included the schema needed for validation and didn't do any network calls as part of the execution.

In our use case, we want to validate our k8s templates offline with the docker image, but currently it needs network access to do anything.

Let me know if this would be feasible, maybe some references to where you download external dependencies at runtime?

Thanks!

garethr commented 7 years ago

@adrianchifor good idea. I had planned to allow the schema URL to be over-ridden. So you could point at your own local schemas. Publishing a Docker image with those locally would be a nice touch. I'll update this issue when I get some time to take a run at this.

bbaja42 commented 7 years ago

A possible solution, that allows user to specify schema URL as the CLI argument: https://github.com/garethr/kubeval/pull/25

garethr commented 7 years ago

@bbaja42 thanks. I'm thinking that we can extend the work in #25 to accept an ENV for the location as well. With that, I can build a Docker image which downloads the latest schemas as part of the build and sets a local ENV to use them rather than the upstream. Note here as I don't have time to get to straight away but thanks again.

bbaja42 commented 7 years ago

Perfect, thnx :)

On 10 Aug 2017 11:04 a.m., "Gareth Rushgrove" notifications@github.com wrote:

@bbaja42 https://github.com/bbaja42 thanks. I'm thinking that we can extend the work in #25 https://github.com/garethr/kubeval/pull/25 to accept an ENV for the location as well. With that, I can build a Docker image which downloads the latest schemas as part of the build and sets a local ENV to use them rather than the upstream. Note here as I don't have time to get to straight away but thanks again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/garethr/kubeval/issues/21#issuecomment-321508887, or mute the thread https://github.com/notifications/unsubscribe-auth/AAufRHcft_RBtd1jhbWxXnO3B7ITy7mDks5sWtWtgaJpZM4Oss_c .

garethr commented 7 years ago

@adrianchifor thanks for this suggestion. #28 has a Dockerfile which will build a new offline image with the schemas bundled. Once that's merged I'll ship an 0.5.0 release and push those images to Hub, but feel free to try out if you like before then.

adrianchifor commented 7 years ago

@garethr Fantastic, thanks a lot!

garethr commented 7 years ago

This is now published as the offline tags on https://hub.docker.com/r/garethr/kubeval/tags/. So for instance the following won't hit the network:

docker run -it -v `pwd`/fixtures:/fixtures garethr/kubeval:offline fixtures/valid.yaml

You can do this with the binary release, but you'll need to download the schemas you're self. You can follow the instructions in https://github.com/garethr/kubeval/blob/master/Dockerfile.offline.

estevao90 commented 4 years ago

The offline tag was discontinued?

There is a way to use kubeval with offline schemas?

Thanks!

bacongobbler commented 4 years ago

@estevao90 did you read @garethr's comment above? The comment demonstrates instructions on how to validate against a set of schemas cached locally.

estevao90 commented 4 years ago

Yes, I read. But I want to know if the offline tag was discontinued. Thanks!

srueg commented 4 years ago

Any news on this? Would be great to build the offline versions as well (i.e. also latest-offline)! Our CI job takes almost 17 minutes by now :disappointed: