Add apiVersion, kind, and metadata to CRD schema
See original GitHub issueIs your feature request related to a problem? Please describe.
I am trying to make my CI pipeline stricter to catch unknown fields at the root of the Kubernetes manifests, but it fails on Strimzi CRs, because their schema misses the fields apiVersion
, kind
, and metadata
.
Describe the solution you’d like
Could we add these fields to the schema of all CRDs, please?
This is the typical properties the CRD schema should have at spec.versions.schema.openAPIV3Schema.properties
:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Describe alternatives you’ve considered
Patch the schema myself with Kustomize for example
Additional context
I use instrumenta/kubeval or yannh/kubeconform to validate the manifests. And this script to create a JSON schema out of the CRDs and inject additionalProperties: false
to all objects with properties
: https://github.com/yannh/kubeconform/blob/master/scripts/openapi2jsonschema.py
$ openapi2jsonschema.py https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.26.0/strimzi-crds-0.26.0.yaml
JSON schema written to kafka_v1beta2.json
JSON schema written to kafkaconnect_v1beta2.json
JSON schema written to kafkatopic_v1beta2.json
JSON schema written to kafkatopic_v1beta1.json
JSON schema written to kafkatopic_v1alpha1.json
JSON schema written to kafkauser_v1beta2.json
JSON schema written to kafkauser_v1beta1.json
JSON schema written to kafkauser_v1alpha1.json
JSON schema written to kafkamirrormaker_v1beta2.json
JSON schema written to kafkabridge_v1beta2.json
JSON schema written to kafkaconnector_v1beta2.json
JSON schema written to kafkamirrormaker2_v1beta2.json
JSON schema written to kafkarebalance_v1beta2.json
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top GitHub Comments
Anyway, lets keep it open and see how it goes.
Triaged on 10.5.2022: There are backwards-compatibility concerns whether adding this to the schema for existing resources will break some other tools. We should consider adding this in the next API version (probably
v1
?).