本文整理汇总了Golang中k8s/io/kubernetes/pkg/controller/framework.Controller.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang Controller.Run方法的具体用法?Golang Controller.Run怎么用?Golang Controller.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/controller/framework.Controller
的用法示例。
在下文中一共展示了Controller.Run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: watchForServices
func watchForServices(kubeClient *kclient.Client, ks *kube2consul) {
var serviceController *kcontrollerFramework.Controller
_, serviceController = kframework.NewInformer(
createServiceLW(kubeClient),
&kapi.Service{},
resyncPeriod,
kframework.ResourceEventHandlerFuncs{
AddFunc: ks.newService,
DeleteFunc: ks.removeService,
UpdateFunc: ks.updateService,
},
)
go serviceController.Run(util.NeverStop)
}
示例2:
},
&api.Pod{},
0,
controllerframework.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
tracker.remember(obj.(*api.Pod), ADD)
},
UpdateFunc: func(oldObj, newObj interface{}) {
tracker.remember(newObj.(*api.Pod), UPDATE)
},
DeleteFunc: func(obj interface{}) {
tracker.remember(obj.(*api.Pod), DEL)
},
},
)
go controller.Run(stopCh)
})
AfterEach(func() {
close(stopCh)
})
It("Controller Manager should not create/delete replicas across restart", func() {
restarter := NewRestartConfig(
getMasterHost(), "kube-controller", ports.ControllerManagerPort, restartPollInterval, restartTimeout)
restarter.restart()
// The intent is to ensure the replication controller manager has observed and reported status of
// the replication controller at least once since the manager restarted, so that we can determine
// that it had the opportunity to create/delete pods, if it were going to do so. Scaling the RC