1

I am looking to create a CRD, which has some of the Specs of an existing k8s object. Is there a way of importing the schema and validation checks of the existing spec instead of manually repeating it again?

For reference, I am registering the CRD with the API like this - https://gist.github.com/tallclair/2491c8034f62629b224260fb8a1854d9#file-dynamic_crds-go-L56 And I would like to add a PodSpec into this CRD type.

1 Answers1

1

CRD are managed by a controller specific to that CRD.

Validation of an object concerning the CRD is achieved through a service that takes a call from the API, in this case validation would work along these lines, admission controller validating webhook

More generally, your CRD does not need to concern itself with podspec per se. The CRD is just some declarative representation of the resource you want your controller to manage.

Extending the k8s api mostly works something like this;

  1. think up some bundled functionality you would like to represent declaratively in one schema (the CRD)
  2. create a controller that handles your CRD
  3. add some validation to make sure the API will reject objects that will confuse the controller you made, and hook it up to the API by way of the Dynamic Admission Control
  4. your controller manages the resources required to fullfil the functionality described

I'm sure you could use a podspec in your CRD, but I wouldn't. Generally that's an abstraction better left to the controller managing that specific resource.

Ernst
  • 174
  • 1
  • 3