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

Fix handling of generic resource in the kubernetes deployer #23031

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

iocanel
Copy link
Contributor

@iocanel iocanel commented Jan 19, 2022

Resolves: #19379
The pull request adds handling for generic resources in the KubernetesDeployer.

This is done by querying the api server for information based on the generic APIResource.
Then it uses the information in order to construct the generic url etc.
This is aligned with how kubectl handles unknown resources.

@quarkus-bot

This comment has been minimized.

@geoand geoand changed the title fix: handling of generic resource in the kubernetes deployer Fix handling of generic resource in the kubernetes deployer Jan 20, 2022
@gsmet
Copy link
Member

gsmet commented Jan 21, 2022

@iocanel any chance this could be finalized before I release 2.7.0.Final (i.e. before Tuesday evening)?

@iocanel iocanel merged commit 6948093 into quarkusio:main Jan 25, 2022
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Jan 25, 2022
.withGroup(ApiVersionUtil.trimGroup(resource.getApiVersion()))
.withVersion(ApiVersionUtil.trimVersion(resource.getApiVersion()))
.withKind(r.getKind())
.withNamespaced(r.getNamespaced())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the whole point is to figure out whether the resource is namespaced and what its plural is? Would it make sense to first try the operation with some assumptions (i.e. that the resource is namespaced and what its plural is (using fabric8's Pluralize) and only query the cluster for the information if that failed? Or we could even try twice: once namespaced, once cluster and finally query the cluster if it still doesn't work?
Not sure what's the cluster impact performance-wise of enumerating all resources…
LGTM otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is already present in the client:

https://github.com/fabric8io/kubernetes-client/blob/7ef49cd34e2de0d68422e17ce24fe15e48b63f17/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Handlers.java#L83

It can be reused by using client#resources(Class<T> resourceType, Class<L> listClass) or client#genericKubernetesResources(String apiVersion, String kind)

I'm not sure if you are aware of this.

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