-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 search for resources #887
Comments
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! |
still looks like a relevant issue to me. It would be nice if we could add something like |
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! |
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! |
Hi, I'd need this feature too. Is there any chance that this will get implemented in the future? |
I don't think this will be directly implemented in the near future. The best workaround is to enumerate the resource classes, then apply the same logic, search for a label or whatever, over each:
|
This only works if you know what kind of resources to expect beforehand and if it's practical to enumerate them. This feels rather cumbersome for a use case that's quite common, imo. |
As discussed internally, after the many improvements to the GenericKubernetesResource handling and the addition of the methods to list groups and resources, this should be much easier to implement now. We'll probably give it a spin in the next weeks. |
After #4065 you should be able to walk the APIResources for each APIGroup and "v1", and perform a filtered list operation on those without a '/' in their name and that support the get verb - it appears that not everything that supports list reports supporting the list verb. |
Something like this:
|
Since this one is extremely expensive, it's also a good candidate for a reactive approach. |
Also, this really isn't straightforward to do either… I think we should provide a top-level operation similar to #887 (comment) |
I think Steven was proposing the implementation of such method. If I'm not mistaken, I think we all agree to include this operation and no one is against it. My argumentation was that this might be a very expensive operation in large clusters, so providing a reactive approach that can be stopped/cancelled at any point (e.g. the user retrieves what he/she is looking for), would be a good option for this. However, I'm not sure consumer-side cancellation would be possible with Java8 Streams only. |
Looking at the openshift console the search functionality by label makes you select resource types - there is no option for selecting all. It would be sensible to follow the same approach, which alleviates much of the concern of how expensive the operation could be. Specifically for filtering / searching it could look like: client.search(ConfigMap.class).search("foo/v1", "kind")...withLabels(...).resources() - returns a Stream of KubernetesResource But you could make an argument for composite operations in general: client.resources(ConfigMap.class).resources("foo/v1", "kind")...withLabels(...).delete() I'm not sure how easily that could be added to the existing resources entry point, or if a new one would be needed. |
Looked at the above again - it's not really worth the effort vs just using lambdas against a list of types. A more concrete proposal is https://github.com/fabric8io/kubernetes-client/compare/master...shawkins:search?expand=1 - this just assumes that it will be a while before we have reactive versions of the relevant operations available (we kind of do for list, but submitList is not exposed). This adds a visitor / walking entry point similar to java's file visiting:
There are additional hooks for a visitor to skip / terminate on a given api name, or apiVersion. |
Is there a way to search for resources by label or annotation? For example, to search for all resources that include the label app=my-app. This would return Pods, Deployments, Services, StatefulSets, etc.
Thanks!
The text was updated successfully, but these errors were encountered: