-
Notifications
You must be signed in to change notification settings - Fork 154
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
Performance issue with K8S Secret Provider #3442
Comments
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
I believe this is happening in this function which indeed has no cache elastic-agent/internal/pkg/composable/providers/kubernetessecrets/kubernetes_secrets.go Line 54 in 69cc860
|
The fastest way to get this fixed will be to open a PR adding the cache yourself, the changes needed should be contained to a single source file. |
Adding caching always has the issue of what invalidates the cache. Which I think needs to be discussed before a cache is added. I think updating the provider to be more efficient as well as more responsive to changes could be done. The order of operations I believe could fix this issue as well as make it more responsive. First loopFor each fetched secret the provider makes we store the key and value fetched, as well as subscribe to kubernetes events for a change in that secrets value. Sequential loopMark all current secret keys as old. Then do the same as above from the first loop, except don't fetch the value unless it was marked dirty from a secret change event. Then all secrets that are marked old can be removed from the cache and unsubscribe from the events. |
@blakerouse the idea is to reuse the cache from the controller runtime: https://github.com/kubernetes-sigs/controller-runtime/blob/d5bc8734caccabddac6a1bea250b0b9d771d318d/pkg/cache/cache.go#L61-L70 |
@bturquet after discussing with @michalpristas and team it looks that this rather falls into your area. |
@constanca-m as you are on rotation this week, could you have a look please ? |
I wrongly assumed that my experience building K8s controllers might help, however to solve this issue I think I would have to invest more time understanding the Agent architecture, which is not possible given my current priorities.
I think you are in a better position to answer this question 😄 |
I created a separate issue for this #3594 and added it to our boards. |
Hi 👋 ,
We have an Agent configuration which is referencing 2
Secrets
using the K8S Secret Provider, for example:While investigating a global performance issue in our K8S cluster we observed a fair amount of requests to our K8S API server, with a constant rate of around 4 to 8
GET
requests on these 2 Secrets per second. The audit trace suggests that that those requests are made by Agents managed by aDaemonSet
on our clusters:Audit Event Sample
I think these
Secrets
should be cached, as it is usually the case when using the K8S client from the controller runtime for example. It would definitely help in our case.We tried to have a look at the code and we were wondering if the client calls are coming from here.
Thanks!
For confirmed bugs, please report:
docker.elastic.co/beats/elastic-agent:8.8.2
The text was updated successfully, but these errors were encountered: