multicluster-controller: admiralty.io/multicluster-controller/pkg/controller Index | Files

package controller

import "admiralty.io/multicluster-controller/pkg/controller"

Package controller implements the controller pattern.

Index

Package Files

controller.go

type Cluster Uses

type Cluster interface {
    GetClusterName() string
    AddEventHandler(context.Context, runtime.Object, cache.ResourceEventHandler) error
    manager.Cache
}

Cluster decouples the controller package from the cluster package.

type Controller Uses

type Controller struct {
    Options
    // contains filtered or unexported fields
}

Controller implements the controller pattern. A Controller owns a client-go workqueue. Watch methods set up the queue to receive reconcile Requests, e.g., on resource CRUD events in a cluster. The Requests are processed by the user-provided Reconciler. A Controller can watch multiple resources in multiple clusters. It saves those clusters in a set, so the Manager knows which caches to start and sync before starting the Controller.

func New Uses

func New(r reconcile.Reconciler, o Options) *Controller

New creates a new Controller.

func (*Controller) GetCaches Uses

func (c *Controller) GetCaches() manager.CacheSet

GetCaches gets the current set of clusters (which implement manager.Cache) watched by the Controller. Manager uses this to ensure the necessary caches are started and synced before it starts the Controller.

func (*Controller) Start Uses

func (c *Controller) Start(stop <-chan struct{}) error

Start starts the Controller's control loops (as many as MaxConcurrentReconciles) in separate channels and blocks until an empty struct is sent to the stop channel.

func (*Controller) WatchResource Uses

func (c *Controller) WatchResource(ctx context.Context, cluster Cluster, objectType runtime.Object, h cache.ResourceEventHandler) error

WatchResource configures the Controller to watch resources of the same Kind as objectType, in the specified cluster, generating reconcile Requests an arbitrary ResourceEventHandler.

func (*Controller) WatchResourceReconcileController Uses

func (c *Controller) WatchResourceReconcileController(ctx context.Context, cluster Cluster, objectType runtime.Object, o WatchOptions) error

WatchResourceReconcileController configures the Controller to watch resources of the same Kind as objectType, in the specified cluster, generating reconcile Requests from the Cluster's context and the namespaces and names of the watched objects' controller references.

func (*Controller) WatchResourceReconcileObject Uses

func (c *Controller) WatchResourceReconcileObject(ctx context.Context, cluster Cluster, objectType runtime.Object, o WatchOptions) error

WatchResourceReconcileObject configures the Controller to watch resources of the same Kind as objectType, in the specified cluster, generating reconcile Requests from the Cluster's context and the watched objects' namespaces and names.

func (*Controller) WatchResourceReconcileObjectOverrideContext Uses

func (c *Controller) WatchResourceReconcileObjectOverrideContext(ctx context.Context, cluster Cluster, objectType runtime.Object, o WatchOptions, contextOverride string) error

WatchResourceReconcileObjectOverrideContext configures the Controller to watch resources of the same Kind as objectType, in the specified cluster, generating reconcile Requests from the watched objects' namespaces and names with the specified context override. This is useful when you want to reuse a Cluster with different names.

type Options Uses

type Options struct {
    // JitterPeriod is the time to wait after an error to start working again.
    JitterPeriod time.Duration
    // MaxConcurrentReconciles is the number of concurrent control loops.
    // Use this if your Reconciler is slow, but thread safe.
    MaxConcurrentReconciles int
    // Queue can be used to override the default queue.
    Queue workqueue.RateLimitingInterface
    // Logger can be used to override the default logger.
    Logger *log.Logger
}

Options is used as an argument of New.

type WatchOptions Uses

type WatchOptions struct {
    Namespace          string
    Namespaces         []string
    LabelSelector      labels.Selector
    AnnotationSelector labels.Selector
    CustomPredicate    func(obj interface{}) bool
}

WatchOptions is used as an argument of WatchResource methods to filter events *on the client side*. You can filter on the server side with cluster.Options.

func (WatchOptions) Predicate Uses

func (o WatchOptions) Predicate(obj interface{}) bool

Package controller imports 13 packages (graph) and is imported by 6 packages. Updated 2020-06-07. Refresh now. Tools for package owners.