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

How to create clients via api #3865

Closed
shawkins opened this issue Feb 15, 2022 · 5 comments
Closed

How to create clients via api #3865

shawkins opened this issue Feb 15, 2022 · 5 comments
Assignees
Milestone

Comments

@shawkins
Copy link
Contributor

Is your enhancement related to a problem? Please describe

After #3654 DefaultKubernetesClient and DefaultOpenShiftClient ended up in their respective -client modules. So we need a way to construct clients via just the api.

Describe the solution you'd like

An initial proposal was 2d22886 - to introduce client specific builders.

They are using reflection - if that is not a good choice (for example for quarkus), we can switch to a service loader, or even do like slf4j and create/remove dummy classes in the api modules.

Whatever the outcome of this is, the highest level construct should be used to hold state for things like the Handlers - so that we can avoid static references.

Describe alternatives you've considered

Alternatives could include just a single client KubernetesClientBuilder:

new KubernetesClientBuilder().withConfig(...).build().adapt(OpenShiftClient.class)

Additional context

No response

@shawkins shawkins added this to the 6.0.0 milestone Feb 15, 2022
@shawkins
Copy link
Contributor Author

cc @rohanKanojia @metacosm @manusa

@manusa
Copy link
Member

manusa commented Feb 22, 2022

My personal preference would be for the single builder approach + adapt.

I guess that this is the closest approach to what we already have. In addition to minimize breakages, it's an existent pattern, so some users should already know their way around it.

I understand that the resulting scenarios would be:

  • Recommended approaches:
    • KubernetesClient kc = new KubernetesClientBuilder()./* configure */.build();
    • OpenShiftClient oc = new KubernetesClientBuilder()./* configure */.build().adapt(OpenShiftClient.class); (requires openshift-client-api module)
    • CamelKClient cc = new KubernetesClientBuilder()./* configure */.build().adapt(CamelKClient.class); (requires extension module)
  • Alternatives:
    • Legacy support: KubernetesClient kc = new DefaultKubernetesClient() (requires kubernetes-client module)
    • OpenShiftClient oc = new DefaultOpenShiftClient() (requires openshift-client module)

@shawkins
Copy link
Contributor Author

The consideration behind a separate OpenShiftClientBuilder was to explicitly reference the OpenShiftConfig.

@shawkins
Copy link
Contributor Author

shawkins commented Feb 22, 2022

It sounds like we'll keep just a single builder, and add a doc note about specific configs. The only danger is that the config must not be modified by the logic in the creation of the base client, otherwise the OpenShift specific nature of the config will be lost.

Also AutoAdaptableKubernetesClient - should be deprecated (since it's in -client, it is by default)

@manusa
Copy link
Member

manusa commented Mar 3, 2022

Also AutoAdaptableKubernetesClient - should be deprecated (since it's in -client, it is by default)

#3921

shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Mar 4, 2022
manusa pushed a commit to shawkins/kubernetes-client that referenced this issue Mar 8, 2022
@manusa manusa closed this as completed in 7d94b09 Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants