controller

package
Version: v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Overview

Package controller implements the controller pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

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

New creates a new Controller.

func (*Controller) GetCaches

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

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 added in v0.2.0

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

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

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 added in v0.2.0

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

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

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 added in v0.2.0

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL