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

Specifically cached client #2940

Merged
merged 2 commits into from
Oct 5, 2020

Conversation

timebertt
Copy link
Member

How to categorize this PR?

/area cost networking
/kind enhancement
/priority normal

What this PR does / why we need it:
This PR add an implementation of the client.{Reader,Client} interfaces that can disable the cache or enable the cache only for a given set of GroupKinds.

The problem with the cached controller-runtime client is, that one Get or List call triggers the client to start a watch for the respective object and therefore caches all object of that kind. This leads to an unnecessarily increased memory footprint for controllers that start caches, although they don't need to.
This implementation is useful for extension controllers that e.g. create ManagedResources and corresponding Secrets but don't want to cache all Secrets in the Seed cluster (which might be a lot).
For an example usage see gardener/gardener-extension-networking-calico#55.

This PR also enables configuring these cache settings for our clientsets that we use in g/g, if we see the necessity to do so in the future.

Which issue(s) this PR fixes:
Related to #2822 and #1953

Special notes for your reviewer:
/cc @timuthy @MartinWeindel

Release note:

The newly added `client.Client` implementation under `pkg/client/kubernetes/utils` can be used to enable/disable the controller-runtime cache only for a given set of object kinds.
- e.g. you can pass `utils.NewClientFuncWithDisabledCacheFor(&corev1.Secret{})` to `manager.Options.NewClient` to use a client, that always reads Secrets directly from the API server instead of caching all Secrets in the cluster.

@timebertt timebertt requested a review from a team as a code owner October 2, 2020 11:20
@gardener-robot gardener-robot added area/cost Cost related area/networking Networking related kind/enhancement Enhancement, improvement, extension priority/normal labels Oct 2, 2020
@timuthy
Copy link
Member

timuthy commented Oct 2, 2020

/assign

Copy link
Member

@timuthy timuthy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR. I don't have much to add except the nits I described in the comments.

pkg/client/kubernetes/options.go Show resolved Hide resolved
pkg/client/kubernetes/client.go Outdated Show resolved Hide resolved
Copy link
Member

@timuthy timuthy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link
Member

@rfranzke rfranzke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Very nice PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cost Cost related area/networking Networking related kind/enhancement Enhancement, improvement, extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants