instrumenta / kubeval

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

Unexpected strict mode failures #42

Closed elblivion closed 6 years ago

elblivion commented 6 years ago

Hi,

Since about 10 days ago we are getting failures validating manifests which have not changed in weeks, specifically with horizontalPodAutoscaler:

$ kubeval --strict horizontalPodAutoscaler.yaml
The document horizontalPodAutoscaler.yaml contains an invalid HorizontalPodAutoscaler
---> targetCPUUtilizationPercentage: Additional property targetCPUUtilizationPercentage is not allowed
$ kubeval --version
Version:      0.7.0
Git commit:   2fcbe11d06671ae19210067529cb0fecf336f630
Built:        2017-09-16 04:46:25 UTC
Go version:   go1.8.3
OS/Arch:      linux/amd64

This is a property which has indeed been dropped from the master schemas but kubeval is failing even when specifying our actual k8s version (e.g. --kubernetes-version 1.7.8), which should accept it: https://github.com/garethr/kubernetes-json-schema/blob/master/v1.7.8-standalone-strict/horizontalpodautoscalerspec.json#L40

johanneswuerbach commented 6 years ago

It looks like the HPA schema only includes v2alpha1 https://github.com/garethr/kubernetes-json-schema/blob/master/v1.7.8-standalone-strict/horizontalpodautoscaler.json#L7, but not v1, which includes the reference to https://github.com/garethr/kubernetes-json-schema/blob/master/v1.7.8-standalone-strict/horizontalpodautoscalerspec.json

garethr commented 6 years ago

Mmmm, interesting. Sorry for taking a while to respond. Would you be able to provide a sanitised copy of horizontalPodAutoscaler.yaml which fails? I'll add this to the test cases and try and work out the fix.

garethr commented 6 years ago

Ah, so I've spend some time debugging #57, and a) found it's the same problem and b) come to the same conclusion. I'll close this simply as a duplicate. The solution will be in regenerating the schemas to include the version skew, and to update kubeval to use the schema based on kind AND version. Thanks for the details.