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 Use Field Selectors with Controller-Runtime to Filter CRD Events on Api-Server side? #3000

Open
jimmyyuhao opened this issue Oct 30, 2024 · 1 comment

Comments

@jimmyyuhao
Copy link

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!

@guettli
Copy link

guettli commented Nov 15, 2024

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

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