kubeval
kubeval copied to clipboard
XXXXX.yaml contains an invalid HorizontalPodAutoscaler (openshift 3.11 strict)
I am seeing this error:
WARN - web_hpa.yaml contains an invalid HorizontalPodAutoscaler (app-x-hpa) - targetCPUUtilizationPercentage: Additional property targetCPUUtilizationPercentage is not allowed`
using flags --openshift --strict -v 3.11.0 on the following yaml construct:
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: app-x-hpa
spec:
maxReplicas: 15
minReplicas: 3
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: app-x-deployment
targetCPUUtilizationPercentage: 60
status:
conditions: []
currentMetrics: []
currentReplicas: 0
desiredReplicas: 0
furthermore, the status values are not required, yet --strict fails if they are not defined.
Using kubeval version :
15:03 $ kubeval --version
Version: 0.16.1
Commit: f5dba6b486fa18b9179b91e15eb6f2b0f7a5a69e
Date: 2021-03-30T15:17:06Z
Originally posted by @davidmalott in https://github.com/instrumenta/kubeval/issues/57#issuecomment-911972927
https://github.com/instrumenta/kubeval/blob/062c99a2ad6554ca5798c07599fa6c06db975325/kubeval/kubeval.go#L70
appears to be the culprit, for openshift schemas, the logic to determine apiVersion for reference is ignored since you are returning before it is processed.
I have created a PR to fix this: https://github.com/instrumenta/kubeval/pull/314