<p>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?</p>
<p>For reference, I am registering the CRD with the API like this - <a href="https://gist.github.com/tallclair/2491c8034f62629b224260fb8a1854d9#file-dynamic_crds-go-L56" rel="nofollow noreferrer">https://gist.github.com/tallclair/2491c8034f62629b224260fb8a1854d9#file-dynamic_crds-go-L56</a>
And I would like to add a PodSpec into this CRD type.</p>

<p>CRD are managed by a controller specific to that CRD.</p>
<p>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, <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/" rel="nofollow noreferrer">admission controller validating webhook</a></p>
<p>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.</p>
<p>Extending the k8s api mostly works something like this;</p>
<ol>
<li>think up some bundled functionality you would like to represent declaratively in one schema (the CRD)</li>
<li>create a controller that handles your CRD</li>
<li>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 <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#write-an-admission-webhook-server" rel="nofollow noreferrer">Dynamic Admission Control</a></li>
<li>your controller manages the resources required to fullfil the functionality described</li>
</ol>
<p>I'm sure you <em>could</em> use a podspec in your CRD, but I wouldn't. Generally that's an abstraction better left to the controller managing that specific resource.</p>
