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

✨ Add SelectorsByObject option to cache #1435

Commits on Apr 27, 2021

  1. Add SelectorsByObject option to cache

    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
    
    Signed-off-by: Quique Llorente <ellorent@redhat.com>
    qinqon committed Apr 27, 2021
    Configuration menu
    Copy the full SHA
    cd065bf View commit details
    Browse the repository at this point in the history