question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add apiVersion, kind, and metadata to CRD schema

See original GitHub issue

Is 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scholzjcommented, Dec 9, 2021

Anyway, lets keep it open and see how it goes.

0reactions
scholzjcommented, May 10, 2022

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?).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extend the Kubernetes API with CustomResourceDefinitions
This page shows how to install a custom resource into the Kubernetes ... apiVersion: "stable.example.com/v1" kind: CronTab metadata: name: ...
Read more >
Learn to use Kubernetes CRDs in this tutorial example
With the CRD registered in our cluster, we can create records for the custom resource. The manifest below creates a new instance of...
Read more >
4. Using Custom Resources - Programming Kubernetes [Book]
Validating Custom Resources. CRs can be validated by the API server during creation and updates. This is done based on the OpenAPI v3...
Read more >
Update CRDs from v1beta1 - Certified Operator Build Guide
Here's a sample CRD shown before and after conversion. The apiVersion is changed to v1, and the schema is now defined per CR...
Read more >
How to Create a Kubernetes Custom Resource Definition (CRD)
Understanding CRD Schema · apiVersion : To define the version of the CRD we will be using. · kind : The type of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found