Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRD does not support `uniqueItems: true` validation: ``` The CustomResourceDefinition "routegroups.zalando.org" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[hosts].uniqueItems: Forbidden: uniqueItems cannot be set to true since the runtime complexity becomes quadratic ``` This change adds [validation rule](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) to enforce unique hosts. It also adds maxItems limit to overcome rule cost error: ``` The CustomResourceDefinition "routegroups.zalando.org" is invalid: * spec.validation.openAPIV3Schema.properties[spec].properties[hosts].x-kubernetes-validations[0].rule: Forbidden: estimated rule cost exceeds budget by factor of more than 100x (try simplifying the rule, or adding maxItems, maxProperties, and maxLength where arrays, maps, and strings are declared) * spec.validation.openAPIV3Schema.properties[spec].properties[hosts].x-kubernetes-validations[0].rule: Forbidden: contributed to estimated rule cost total exceeding cost limit for entire OpenAPIv3 schema * spec.validation.openAPIV3Schema: Forbidden: x-kubernetes-validations estimated rule cost total for entire OpenAPIv3 schema exceeds budget by factor of more than 100x (try simplifying the rule, or adding maxItems, maxProperties, and maxLength where arrays, maps, and strings are declared) ``` Note that validation rule is not added to `tls` spec because then rule cost error re-appears apparently due to exciiding total allowed schema cost. Example validation error: ``` Error from server (Invalid): error when creating "rg.yaml": RouteGroup.zalando.org "duplicate-hosts" is invalid: spec.hosts: Invalid value: "array": hosts must be unique ``` Signed-off-by: Alexander Yastrebov <[email protected]>
- Loading branch information