本文整理汇总了Golang中k8s/io/kubernetes/pkg/client.Client.Events方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Events方法的具体用法?Golang Client.Events怎么用?Golang Client.Events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/client.Client
的用法示例。
在下文中一共展示了Client.Events方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewTurboScheduler
func NewTurboScheduler(kubeClient *client.Client, vmturboMeta *vmtmeta.VMTMeta) *TurboScheduler {
scheduledPodLister := &cache.StoreToPodLister{}
podQueue := cache.NewFIFO(cache.MetaNamespaceKeyFunc)
modeler := scheduler.NewSimpleModeler(&cache.StoreToPodLister{Store: podQueue}, scheduledPodLister)
bindPodsQPS := float32(15.0)
bindPodsBurst := 20
rateLimiter := util.NewTokenBucketRateLimiter(bindPodsQPS, bindPodsBurst)
config := &Config{
Modeler: modeler,
Binder: &binder{kubeClient},
BindPodsRateLimiter: rateLimiter,
}
eventBroadcaster := record.NewBroadcaster()
config.Recorder = eventBroadcaster.NewRecorder(api.EventSource{Component: "turboscheduler"})
eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(kubeClient.Events(""))
vmtSched := vmtscheduler.NewVMTScheduler(kubeClient, vmturboMeta)
glog.V(3).Infof("VMTScheduler is set: %++v", vmtSched)
defaultSched := defaultscheduler.NewDefaultScheduler(kubeClient)
glog.V(3).Infof("DefaultScheduler is set: %++v", defaultSched)
return &TurboScheduler{
config: config,
vmtScheduler: vmtSched,
defaultScheduler: defaultSched,
}
}
示例2: verifyResult
func verifyResult(c *client.Client, podName string, ns string, oldNotRunning int) {
allPods, err := c.Pods(api.NamespaceAll).List(labels.Everything(), fields.Everything())
expectNoError(err)
_, notRunningPods := getPodsNumbers(allPods)
schedEvents, err := c.Events(ns).List(
labels.Everything(),
fields.Set{
"involvedObject.kind": "Pod",
"involvedObject.name": podName,
"involvedObject.namespace": ns,
"source": "scheduler",
"reason": "FailedScheduling",
}.AsSelector())
expectNoError(err)
printed := false
printOnce := func(msg string) string {
if !printed {
printed = true
return msg
} else {
return ""
}
}
Expect(notRunningPods).To(Equal(1+oldNotRunning), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods)))
Expect(schedEvents.Items).ToNot(BeEmpty(), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods)))
}
示例3: NewKubeEvents
func NewKubeEvents(client *kubeclient.Client, ec cache.EventsCache) api.Source {
// Buffered channel to send/receive events from
eventsChan := make(chan eventsUpdate, 1024)
errorChan := make(chan error)
es := &eventsSourceImpl{
Client: client,
eventsChannel: eventsChan,
errorChannel: errorChan,
ec: ec,
}
go es.watchLoop(client.Events(kubeapi.NamespaceAll), eventsChan, errorChan)
// TODO: Inject Namespace Store in here to get namespace IDs for events.
return es
}
示例4: verifyResult
func verifyResult(c *client.Client, podName string, ns string) {
allPods, err := c.Pods(api.NamespaceAll).List(labels.Everything(), fields.Everything())
expectNoError(err)
runningPods := 0
notRunningPods := make([]api.Pod, 0)
for _, pod := range allPods.Items {
if pod.Status.Phase == api.PodRunning {
runningPods += 1
} else {
notRunningPods = append(notRunningPods, pod)
}
}
schedEvents, err := c.Events(ns).List(
labels.Everything(),
fields.Set{
"involvedObject.kind": "Pod",
"involvedObject.name": podName,
"involvedObject.namespace": ns,
"source": "scheduler",
"reason": "failedScheduling",
}.AsSelector())
expectNoError(err)
printed := false
printOnce := func(msg string) string {
if !printed {
printed = true
return msg
} else {
return ""
}
}
Expect(len(notRunningPods)).To(Equal(1), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods)))
Expect(schedEvents.Items).ToNot(BeEmpty(), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods)))
Expect(notRunningPods[0].Name).To(Equal(podName), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods)))
}
示例5:
config := RCConfig{Client: c,
Image: "gcr.io/google_containers/pause:go",
Name: RCName,
Namespace: ns,
PollInterval: itArg.interval,
PodStatusFile: fileHndl,
Replicas: totalPods,
MaxContainerFailures: &MaxContainerFailures,
}
// Create a listener for events.
events := make([](*api.Event), 0)
_, controller := framework.NewInformer(
&cache.ListWatch{
ListFunc: func() (runtime.Object, error) {
return c.Events(ns).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(rv string) (watch.Interface, error) {
return c.Events(ns).Watch(labels.Everything(), fields.Everything(), rv)
},
},
&api.Event{},
0,
framework.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
events = append(events, obj.(*api.Event))
},
},
)
stop := make(chan struct{})
go controller.Run(stop)