instrumenta / kubeval

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

Validate k8s API versions #106

Closed PabloCastellano closed 5 years ago

PabloCastellano commented 5 years ago

Hello.

I'm interested on a new feature for kubeval to validate the apiVersion field given a specific Kubernetes version. Do you have any plans to add it? I am willing to contribute.

This tool could be powerfully used together with helm template. This command generates the kubernetes manifest from the Helm chart, and allows specifying the --kube-version parameter to generate a manifest compatible with a specific version of Kubernetes. This parameter is used by helpers like this one.

Ideally kubeval should also be able to validate that the generated manifest is valid for 1.9 (uses apiVersion: rbac.authorization.k8s.io/v1) and for 1.6 (requires apiVersion: rbac.authorization.k8s.io/v1beta1 instead).

retr0h commented 5 years ago

Ya, this seems like it would be useful.

[jodewey:~/git/konfig] % kubeval foo.yaml
The document foo.yaml contains a valid DaemonSet
[jodewey:~/git/konfig] % cat foo.yaml
apiVersion: invalid
kind: DaemonSet
metadata:
  namespace: foo
  labels:
    foo: bar

Especially when kubectl barfs

[jodewey:~/git/konfig] % kubectl apply --dry-run --validate -f foo.yaml
error: unable to recognize "foo.yaml": no matches for kind "DaemonSet" in version "invalid"
retr0h commented 5 years ago

I have a feeling this project has fallen by the wayside. :(

garethr commented 5 years ago

I've not had much time of late to work on the project but I'm hoping I should have a bunch more time now. Proper handling of APIVersion is definitely desirable.

garethr commented 5 years ago

This should now be correctly handled in the newly released 0.8.0 version.