Hi All
Following on from my last post about the Kubernetes type schemas, I've
pushed a simple tool that makes use of them.
https://github.com/garethr/kubeval
On the Kubernetes type schemas thread William Stewart said "Totally
looked for something similar awhile ago so I could do client-side
validation of resources rendered from templates."
Kubeval is a tool to do exactly that. Just point it at one or more
YAML or JSON files and it will validate them against the schemas and
return relevant errors and a non-zero exit code if it finds anything
amiss.
kubeval my-invalid-rc.yaml a-deployment.yaml
This also allows for validating against specific versions of the
published schemas, and against the OpenShift definitions which add a
few more types.
kubeval -v 1.6.6 my-deployment.yaml
kubeval --openshift -v 1.5.1 my-deployment.yaml
I envisage this being useful locally when writing or generating
configuration files. I've been using entr to run the validator when a
file changes for instance:
ls configs/* | entr kubeval configs/*
This should also be useful in a continuous integration system as well.
If you have Kubernetes configs in a Git repo, either as examples or as
the main artefact, then you should be able to add a simple step in
Travis or anything else to check there validity.
This is the first release so there are undoubtedly some issues. I
intend to clean up the code a bunch when I get a moment but this is
working now and I'd love folks to try it out and let me know what you
think.
Cheers
Gareth
--
Gareth Rushgrove
@garethr
devopsweekly.com
morethanseven.net
garethrushgrove.com