How to trigger a Kubernetes controller reconciler for an arbitrary object? How to trigger a Kubernetes controller reconciler for an arbitrary object? kubernetes kubernetes

How to trigger a Kubernetes controller reconciler for an arbitrary object?


You do indeed use a map function and a normal watch. https://github.com/coderanger/migrations-operator/blob/088a3b832f0acab4bfe02c03a4404628c5ddfd97/components/migrations.go#L64-L91 shows an example. You do end up often having to do I/O in the map function to work out which of the root objects this thing corresponds to, but I agree it kind of sucks that there's no way to do much other than log or panic if those calls fail.

You can also use non-controller owner references or annotations as a way to store the mapped target for a given deployment which makes the map function much simpler, but also usually less responsive. Overall it depends on how dynamic this needs to be. Feel free to pop on the #kubebuilder Slack channel for help.