use SharedInformer on watch
@@ -1486,11 +1486,8 @@ func (w *Watcher) configureKubeWatch() (cache.Controller, chan struct{}) {
localPodMap := map[string]struct{}{}
- _, controller := cache.NewInformer(
- watchlist,
- &v1.Pod{},
- 0,
- cache.ResourceEventHandlerFuncs{
+ si := cache.NewSharedInformer(watchlist, &v1.Pod{}, 0)
+ si.AddEventHandler(cache.ResourceEventHandlerFuncs{
// --- Kube Create
AddFunc: func(obj interface{}) {
logger := w.Logger.WithFields(logrus.Fields{
@@ -1571,8 +1568,7 @@ func (w *Watcher) configureKubeWatch() (cache.Controller, chan struct{}) {
logger.Error("obj received is not of type *v1.Pod")
}
},
- },
- )
+ })
- return controller, make(chan struct{})
+ return si, make(chan struct{})
}
