-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 cluster.NewClientFunc with options #2054
✨ Add cluster.NewClientFunc with options #2054
Conversation
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.
I understand the use-case of caching unstructured objects especially since most of them are CRs in controllers. But going through the discussion in the issue, we would still be hitting the same issue of caching all the arbitrary objects accidentally. The evolution of uncached client was that we initially used to hit the API server to read all the unstructured objects (https://github.com/kubernetes-sigs/controller-runtime/blob/release-0.5/pkg/client/split.go#L45-L61) which then turned out to be expensive. Which is why the option of specifying uncached objects was introduced so that we could hit the api server only when needed (
controller-runtime/pkg/client/split.go
Line 115 in accd262
if !d.cacheUnstructured { |
But why are more concerned about this for |
f0c054d
to
c7c2185
Compare
c7c2185
to
cca5160
Compare
cca5160
to
791d496
Compare
Motivated by the ability to create a client caching Unstructured when configuring manager.
791d496
to
cdbd4b7
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, erikgb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
thanks! |
Thanks for the review @alvaroaleman. I really like your suggestion, which makes this change extensible for future improvements! 👍 |
This adds a new
cluster.ClientBuilderWithOptions
alongside thecluster.DefaultNewClient
, which will allow users to easily get a client that cachesUnstructured
- which the default client intentionally doesn't, ref #615 (comment).Almost all the operators I work on seem to benefit from enabling caching of
Unstructured
. While not "that" common, I have also seen users asking for this on Slack. 😉 Adding this new func to controller-runtime will avoid having to implement the workaround explained in this blog.