-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 Use Field Selectors with Controller-Runtime to Filter CRD Events on Api-Server side? #3000
Comments
same here. I could not find that in the docs. I found that design doc: https://github.com/kubernetes-sigs/controller-runtime/blob/main/designs/use-selectors-at-cache.md Which is implemented in #1435 In my case: I want to watch one configMap. But I don't want to filter the cache for that, because I want to also read other configMaps. Afaik I can't get objects via the default (cached) client, if the cache is filtered. @jimmyyuhao maybe this conversation helps: https://kubernetes.slack.com/archives/C02MRBMN00Z/p1731692196792769 |
Here's an example from my setup in SetupWithManager. In the last function, you can filter objects based on any of their fields, and tell the reconciler about which resource u want to be reconciled using reconcile.Request. You can also filter the cache if you are sure that your objects are of particular selector/namespaces. But then you wont be able to get events outside of those options. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
@MuneebAijaz afaik your example filters on the client-side. This question is about filtering at the server-side. |
right in that case @guettli your answer covers it. Cache can be filtered based on namespace and object level, so only those objects are stored in informer cache and will be returned when queried. |
Body:
Hello,
I am working with the controller-runtime package in Kubernetes and I need to implement a functionality where the API server only notifies my controller about specific Custom Resource Definitions (CRDs). Specifically, I want to filter events so that I only receive notifications for CRDs where metadata.name is equal to a specific value, such as nodeName.
I would like to know:
How can I configure the manager initialization to achieve this?
Is there a way to set up a field selector to filter these events at the API server level?
If direct support for field selectors is not available, what would be the best approach to implement this functionality in my controller?
Any guidance or examples would be greatly appreciated!
Thank you!
The text was updated successfully, but these errors were encountered: