Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier Custom Resource client creation #2670

Closed
metacosm opened this issue Dec 16, 2020 · 5 comments
Closed

Easier Custom Resource client creation #2670

metacosm opened this issue Dec 16, 2020 · 5 comments
Assignees

Comments

@metacosm
Copy link
Collaborator

From @manusa in #2611:

So far we've worked on the CRD>CR consumption part. We've provided the tools to generate a CRD API client that works with any CRD API version (v1beta1 or v1). The main reason for this is that CRDs comply to a standard RESTful API with strong conventions around resource naming and location. Instead of working with CRD instances to declare this client we use a more abstract CustomResourceDefinitionContext which contains the required fields to be able to interact with via REST with Kubernetes. (So we could say that CustomResourceOperations implementation is more or less complete. ✔️

However, there's still another requirement/feature (and maybe this belongs more to the SDK) "As a Kubernetes Java developer I want to infer the Custom Resource Definitions for my Java objects automatically". ✨

Considering an abstract CusomtResourceDefinitionOperations interface (has the standard CRUD methods) which would have implementations for every API version (v1beta1 or v1), we could define a client method T crdClientFrom(Class<? extends CustomResource> customResourceClazz) (A).
The method implementation logic should run as follows:

Check latest CRD API version available in the connected cluster
Return applicable CusomtResourceDefinitionOperations interface implementation instance

Besides, another method to infer a CRD instance from a POJO would be good to have (again, this may probably fit better within the SDK project). This is trickier (probably needs a few more iterations), because there are (as of now) 2 types that represent CustomResourceDefinition. It would make sense some method such as T crdFrom(Class<? extends CustomResource> customResourceClazz) (B), depending on the APIs available on the cluster, a v1 or v1beta1 CRD instance is returned.
The implementation for this method is were we should be really creative in terms of inferring OpenAPIV3Schema from the POJO fields, annotations, JSR 303, etc.

With both A & B in place, something like this should be feasible:

kubernetesClient.crdClientFrom(MyCustomResource.class).create(CRDToolset.crdFrom(MyCustomResource.class));

or any other CRUD operation on the represented CRD k8s resource.

(IMHO)

@stale
Copy link

stale bot commented Apr 8, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Apr 8, 2021
@alxbl
Copy link

alxbl commented Apr 8, 2021

However, there's still another requirement/feature (and maybe this belongs more to the SDK) "As a Kubernetes Java developer I want to infer the Custom Resource Definitions for my Java objects automatically". ✨

I think this is a very good use-case for people who are developing Operators in Java using javaoperator-sdk and I would like to see this supported as well.

Cheers,
Alex

@stale
Copy link

stale bot commented Jul 29, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Jul 29, 2021
@stale stale bot closed this as completed Aug 5, 2021
@manusa
Copy link
Member

manusa commented Aug 10, 2021

This should already be possible right?

@shawkins
Copy link
Contributor

kubernetesClient.crdClientFrom(MyCustomResource.class)

That is now possible as client.resources(MyCustomResource.class) - it will look at the Group, Version, and Plural annotations, and if it implements Namespaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants