willthames / kubernetes-validate

Other
45 stars 5 forks source link

Openshift case - io.k8s.api.core.v1.LimitRangeItem -> permit Images and ImageStream #20

Open mmv2010 opened 1 year ago

mmv2010 commented 1 year ago

Hi,

For kubernetes-validate module run from ansible, kubernetes version: v1.23.5 validation for size/number of Images and ImageSources on LimitRanges is not under definitions

https://docs.openshift.com/container-platform/4.10/nodes/clusters/nodes-cluster-limit-ranges.html

Defining those two limits and apply using ansible fails validation with error message: "msg": "LimitRange core-resource-limits: resource definition validation error at spec.limits.2.type: 'openshift.io/Images' is not one of ['Container', 'PersistentVolumeClaim', 'Pod']"

Validation process LimitRangeItem does not include these (or should be case for Openshift only) https://github.com/willthames/kubernetes-validate/blob/main/src/kubernetes_validate/kubernetes-json-schema/v1.23.0-local-strict/_definitions.json#L7209

Check with manual update under _definitions.json "type": { "enum": [ "Container", "PersistentVolumeClaim", "Pod", "openshift.io/Images", "openshift.io/ImageStream" ]}

Results in proper validation and therefore object is created on the cluster. localhost : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Alternative to bypass validate using "strict: no"

Thanks! Mihai