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
✨ Add SelectorsByObject option to cache #1435
✨ Add SelectorsByObject option to cache #1435
Conversation
Hi @qinqon. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@qinqon Thanks for the PR. This will be very helpful.. |
@visheshtanksale this is just a PoC for the design document here #1419 |
551ced4
to
48fe9c7
Compare
2ff9e18
to
6d1af5b
Compare
/cc @alvaroaleman @estroz The PR to implement #1419 is ready. |
6d1af5b
to
79f3347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR, looking forward to the feature!
I have a few suggestions, see inline.
79f3347
to
37fe04e
Compare
@timebertt can you re-review ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
Nope lets get this in! /lgtm |
@alvaroaleman you will have to override apidiff, I don't have perms to do so |
Nevermind, that worked! |
@estroz @alvaroaleman can this be cherry picked to 0.8 and do a release with it ? |
It's optional :) |
Since this is a feature and not a bugfix, wouldn't it be best to just release in v0.9.0? |
Reduce the access to the cluster given to the ServiceAccount used by the controller. This leverages the changes introduced by kubernetes-sigs/controller-runtime#1435 to allow controllers to reduce the scope of watches. Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Controller-Runtime controllers use a cache to subscribe to events from
Kubernetes objects and to read those objects more efficiently by avoiding
to call out to the API. This cache is backed by Kubernetes informers.
The only way to filter this cache is by namespace and resource type.
In cases where a controller is only interested in a small subset of objects
(for example all pods on a node), this might end up not being efficient enough.
This change increase the "pkg/cache" interface adding the
"BuildWithOptins" function and the "Options.SelectorsByObject" option.
The SelectorsByObject restricts the cache's ListWatch to the desired
fields per GVK at the specified object, the map's value must implement
Selector [1] using for example a Set [2]
This is the implementation of the design document [3]
[1] https://pkg.go.dev/k8s.io/apimachinery/pkg/fields#Selector
[2] https://pkg.go.dev/k8s.io/apimachinery/pkg/fields#Set
[3] https://github.com/kubernetes-sigs/controller-runtime/blob/master/designs/use-selectors-at-cache.md