kubernetes-sigs/kubectl-validate

validation of apiregistration.k8s.io/v1 resource fails

monotek opened this issue · 1 comments

What happened?

Our ci pipline fails to validate a file with kind "apiregistration.k8s.io/v1".

kubectl-validate keda-metrics-apiserver-apiservice.yaml

keda-metrics-apiserver-apiservice.yaml...ERROR
failed to retrieve validator: failed to locate OpenAPI spec for GV: apiregistration.k8s.io/v1
Error: validation failed

What did you expect to happen?

Imho the file should be able to be validated as "apiregistration.k8s.io/v1" is not a custom resource but part of the kuberntes api, which should be included in kubectl-validate?

How can we reproduce it (as minimally and precisely as possible)?

validate that file without a kubecontext set:

---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  annotations:
    cert-manager.io/inject-ca-from: keda/keda-operator-tls-certificates
  labels:
    app.kubernetes.io/name: v1beta1.external.metrics.k8s.io
    app.kubernetes.io/part-of: keda-operator
    app.kubernetes.io/version: 2.13.1
  name: v1beta1.external.metrics.k8s.io
spec:
  service:
    name: keda-metrics-apiserver
    namespace: keda
    port: 443
  group: external.metrics.k8s.io
  version: v1beta1
  groupPriorityMinimum: 100
  versionPriority: 100
  insecureSkipTLSVerify: false
kubectl-validate keda-metrics-apiserver-apiservice.yaml

Anything else we need to know?

It does work if a kubecontext is set though:

 kubectl-validate keda-metrics-apiserver-apiservice.yaml

keda-metrics-apiserver-apiservice.yaml...OK

Kubernetes version

$ kubectl version
# 1.28.5

Ah, up to 1.27 the apiregistration resource schema information wasn't being published by Kubernetes...

kubernetes/kubernetes#118879

Will have to manually add it for older versions of k8s for the next build