Hello,
we encountered memory issues while adding secondary ressources to our CR with go operator-sdk. Indeed, when secondary ressources (like secrets, connfigmaps...) are owned and watched by our CR controller, all these ressources are mounted in cache. This means that for a cluster-scoped operator, if our CR owns secret ressource all the secrets created in the cluster will be cached in memory.
In our case (big cluster) the controller consumes around 2Go memory even if we have only few CR's (because of several thousands secrets in the cluster).
We had two solutions :
- detach secondary ressources from CR (no more ressources owned by CR) but this means secondary ressources are not watched anymore by our controller (for ex no reconciliation if secret is removed),
- implement custom cache informer to filter secondary ressources by labels (labels should be generated when controller creates secondary ressources).
Would it be possible to make this custom cache implementation more intuitive thanks to operator-sdk and why not automate it for cluster-scoped operators (caching so many ressources seems really unuseful) ?
Thanks,
Olivier