Closed jeff-minard-ck closed 5 years ago
Same issue for me: try to run kubeval --strict --kubernetes-version 1.12.0 (or other versions supposed to be supporting custom metrics hpa) on an hpa.yaml containing exactly the custom metrics conf example of the official k8s doc, or any other example you may find on the net, and the validation will fail with "---> metrics: Additional property metrics is not allowed".
I read the definitions.json, and it looks like io.k8s.api.autoscaling.v2beta2.MetricSpec and io.k8s.api.autoscaling.v2beta1.MetricSpec are well defined.
It really looks like a bug. Hope to have some feedback on it !
Otherwise... very nice tool ! Great job !
Thanks for flagging, I'll take a look when I get a moment at opening an upstream issue and seeing if I can patch in the schema conversion.
Upgrading to version 0.8.1, recently released, I'm not encountering any issue on HPA anymore !
@claudod thanks for letting me know.
Agreed; I see this working now as well. Thanks!
(Possibly related to #57)
So, have run across this issue that, in strict mode, HPAs will fail to validate, despite being correct according to the spec.
Taken directly from https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/:
Results in:
The problem is that the JSON schema, as of today, isn't setup to deal with the fact that the metrics is a list of objects with varying types. Specifically this section:
A proper HPA will have both the
type
property and one other, according to what the type is.I do not come to this bug tracker empty handed, however. After learning up a bit of JSON schema, it seems the solution lies in
oneOf
validation on the items in the metrics array.Here's a demo schema I came up with that makes an example of how this could be modeled to function correctly:
As tested against:
Where you can tweak the type value and alternative pod/resource keys to watch it pass/fail for misconfigured objects. (I trialed this fun at https://www.jsonschemavalidator.net/)
I've no idea how to translate this through the code generation system, however.