-
Hello, I'm implementing my own Kubernetes operator in Rust and I was wondering if it was ok to have 2 Controllers in the same project that both watch a different custom resource. Otherwise I don't really see how to go about it and what features I have to use to achieve what I want! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
heyhey. Yep, it will work, but with one caveat: We don't currently a controller-manager equivalent here so there's no efficient sharing of streams across controllers. If any of the two controllers is for the same resource, or watch the same child resource, you end up querying the apiserver twice for that resource. This is because they set up their watches independently. Using the Been planning on opening an issue for this. We barely explored some thoughts on this semi-recently. |
Beta Was this translation helpful? Give feedback.
-
There is a resource where I need to keep it in a valid state all the time so I will use one controller, the other I only need to read it at certain time to retrieve information from it, in this case the it is better to use the Reflector, isn't it? |
Beta Was this translation helpful? Give feedback.
heyhey. Yep, it will work, but with one caveat:
We don't currently a controller-manager equivalent here so there's no efficient sharing of streams across controllers. If any of the two controllers is for the same resource, or watch the same child resource, you end up querying the apiserver twice for that resource. This is because they set up their watches independently.
Using the
applier
directly (i.e. passing in raw streams) allows for doing this more efficiently, but it is a lot less ergonomic.Been planning on opening an issue for this. We barely explored some thoughts on this semi-recently.