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

fix(k8sprocessor): store only necessary Pod data #593

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

swiatekm
Copy link

@swiatekm swiatekm commented May 23, 2022

Informers are a convenient mechanism for maintaining an eventually-consistent local cache of Kubernetes objects. One of the problems with them used to be that it was difficult to customize the object data stored in the cache, leading to unnecessarily large memory usage even when the client only cared about a small subset of the data. client-go 0.23.0 added a mechanism to do this, where it's possible to provide the informer with a transform function applied to the object before it's stored and event handlers are fired.

We supply a transform function to only retain the Pod data we use in our cache. Truthfully, we could get rid of all of it, as we keep the computed metadata in a separate data structure, but that would require implementing a custom Store. The transform function approach is much simpler in comparison.

The result is a close to 10x reduction in processor memory usage in large clusters (5000+ Pods).

@swiatekm swiatekm requested a review from a team as a code owner May 23, 2022 14:37
@github-actions github-actions bot added the go label May 23, 2022
@swiatekm swiatekm force-pushed the fix/k8sprocessor/cache-optimization branch from d55e0d5 to 5917908 Compare May 24, 2022 08:05
@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants