Wondered what happens when controller manager starts in your operator?
- Start metrics endpoint
- Start health probes
- Start web hooks servers
- Start and wait for caches to sync
- Start non-leader election runnables
- Start leader election and all required runnables
You can see that caches are sync’ed in both leader and non-leader operator pods which makes transition quick if leader pod exits and another operator pod becomes leader (if you run multiple pods of your operator for HA)
Code for all these in here: https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/manager/internal.go#L441-L496