I'm not quite sure if which of the following approaches is the better approach to create a controller in kubernetes however I know that:
- I don't want to create a custom resource by any means.
- I do only want to fetch information about k8s native resources (pods, ...) given that there might be a lot of pods in each namespace
I have seens some patterns like:
ctrl, err := controller.New("name-here", mgr, controller.Options{
Reconciler: &ReconcilePod{Client: mgr.GetClient(), Logger: log},
})
which ReconcilePod is a struct that has a function Reconcile that keep whole business logic.
Another approach I have seens is like following:
type Controller struct {
indexer cache.Indexer
queue workqueue.RateLimitingInterface
informer cache.Controller
}
and then defining shared informer and watcher etc.
And the third pattern that I have seen is using operators
what I don't get perhaps is what is the main differences between mentioned approaches above and which one fits my need at scale.