How to change DefaultNamespaces at runtime
lmeunier-talend opened this issue · comments
Hello
For security reason our operator must only watch certain namespace, in order to do that I have used
Cache: cache.Options{DefaultNamespaces: map[string]cache.Config{
"namespace1": {},
}},
when starting the controller and it's working nicely.
But when of our CR is created, we have to watch another namespace.
Is it possible to update the DefaultNamespaces
at runtime ? i did not see how
Else i was thinking on relying on a configmap to hold the namespace and restart the operator on change but that kind of sucks
Thanks you for your answer
There is no builtin mechanism today to do this at runtime. It's also quite complex as we would have to adjust the currently running informers according to the changed config.
Thanks for the answer, i will close the ticket then
Hi, just our xp with this, this is supported in Java Operator SDK
https://javaoperatorsdk.io/docs/features#dynamically-changing-target-namespaces
basically what happens is that the event processing is stopped until the new informers are started and after sync the processing is started again.
It seems to working well, and helps a lot for some teams, where the controller watches a set of namespaces and this set is sometimes extended with a new namespace, then there is no need to sync again the informers for other namespaces, what might take a long time in case of lot of objects.