根据我的了解(和经验)-kubernetes通知程序将updateFunc
调用其缓存的每个“同步”事件-从我收集的信息来看,这是由于this令人讨厌的代码和平。
通知者定义示例:
informer:= NewInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.Batch().Jobs(api.NamespaceAll).List(options)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.Batch().Jobs(api.NamespaceAll).Watch(options)
},....)
...
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}){},
// Make this function be called *only* on update.
UpdateFunc: func(old, current interface{}){},
DeleteFunc: func(current interface{}){},
})
但是对于我的用例-调用updateFunc
仅应在资源更新时才真正发生(例如,我每次更新或进入I / O时都要进行大量计算)。
我一直在流浪,有没有办法仅在更新时致电updateFunc
?