Slide 27
Slide 27 text
_, controller := cache.NewInformer(
&cache.ListWatch{
// List should return a list type object
ListFunc: func(lo metav1.ListOptions) (runtime.Object, error) {
return client.Core().Nodes().List(lo)
},
// Watch should return a watch Interface. begin a watch at the specified version.
WatchFunc: func(lo metav1.ListOptions) (watch.Interface, error) {
return client.Core().Nodes().Watch(lo)
},
},
// The types of objects this informer will return
&v1.Node{},
// The resync period of this object
10*time.Second,
// the object you want notifications sent to
cache.ResourceEventHandlerFuncs{
// AddFunc: func(obj interface{}) {}
UpdateFunc: func(old, newObj interface{}) { … },
// DeleteFunc: func(obj interface{}) {}
},
)