美文网首页
controller-runtime WithEventFilt

controller-runtime WithEventFilt

作者: allenhaozi | 来源:发表于2020-09-19 15:52 被阅读0次
    // Setup adds a controller that schedules KubernetesApplications.
    func Setup(mgr ctrl.Manager, l logging.Logger) error {
        name := "scheduler/" + strings.ToLower(workloadv1alpha1.KubernetesApplicationGroupKind)
    
        return ctrl.NewControllerManagedBy(mgr).
            Named(name).
            For(&workloadv1alpha1.KubernetesApplication{}).
            WithEventFilter(&predicate.Funcs{CreateFunc: CreatePredicate, UpdateFunc: UpdatePredicate}).
            Complete(&Reconciler{
                kube:      mgr.GetClient(),
                scheduler: &roundRobinScheduler{kube: mgr.GetClient()},
                log:       l.WithValues("controller", name),
            })
    }
    
    // Funcs is a function that implements Predicate.
    type Funcs struct {
        // Create returns true if the Create event should be processed
        CreateFunc func(event.CreateEvent) bool
    
        // Delete returns true if the Delete event should be processed
        DeleteFunc func(event.DeleteEvent) bool
    
        // Update returns true if the Update event should be processed
        UpdateFunc func(event.UpdateEvent) bool
    
        // Generic returns true if the Generic event should be processed
        GenericFunc func(event.GenericEvent) bool
    }
    

    相关文章

      网友评论

          本文标题:controller-runtime WithEventFilt

          本文链接:https://www.haomeiwen.com/subject/mzieyktx.html