Documentation
¶
Overview ¶
Package controller provides types and functions for building Controllers. Controllers implement Kubernetes APIs.
Creation ¶
To create a new Controller, first create a manager.Manager and pass it to the controller.New function. The Controller MUST be started by calling Manager.Start.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // Reconciler is called to reconcile an object by Namespace/Name reconcile.Reconciler // Watch takes events provided by a Source and uses the EventHandler to // enqueue reconcile.Requests in response to the events. // // Watch may be provided one or more Predicates to filter events before // they are given to the EventHandler. Events will be passed to the // EventHandler if all provided Predicates evaluate to true. Watch(src source.Source, eventhandler handler.EventHandler, predicates ...predicate.Predicate) error // Start starts the controller. Start blocks until stop is closed or a // controller has an error starting. Start(stop <-chan struct{}) error }
Controller implements a Kubernetes API. A Controller manages a work queue fed reconcile.Requests from source.Sources. Work is performed through the reconcile.Reconciler for each enqueued item. Work typically is reads and writes Kubernetes objects to make the system state match the state specified in the object Spec.
Example ¶
This example starts a new Controller named "pod-controller" to Watch Pods and call a no-op Reconciler.
Output:
Example (Unstructured) ¶
This example starts a new Controller named "pod-controller" to Watch Pods with the unstructured object and call a no-op Reconciler.
Output:
func New ¶
New returns a new Controller registered with the Manager. The Manager will ensure that shared Caches have been synced before the Controller is Started.
Example ¶
This example creates a new Controller named "pod-controller" with a no-op reconcile function. The manager.Manager will be used to Start the Controller, and will provide it a shared Cache and Client.
Output:
func NewUnmanaged ¶ added in v0.6.0
NewUnmanaged returns a new controller without adding it to the manager. The caller is responsible for starting the returned controller.
Example ¶
This example creates a new controller named "pod-controller" to watch Pods and call a no-op reconciler. The controller is not added to the provided manager, and must thus be started and stopped by the caller.
Output:
type Options ¶
type Options struct { // MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1. MaxConcurrentReconciles int // Reconciler reconciles an object Reconciler reconcile.Reconciler // RateLimiter is used to limit how frequently requests may be queued. // Defaults to MaxOfRateLimiter which has both overall and per-item rate limiting. // The overall is a token bucket and the per-item is exponential. RateLimiter ratelimiter.RateLimiter // Log is the logger used for this controller. Log logr.Logger }
Options are the arguments for creating a new Controller
Directories
¶
Path | Synopsis |
---|---|
Package controllertest contains fake informers for testing controllers When in doubt, it's almost always better to test against a real API server using envtest.Environment.
|
Package controllertest contains fake informers for testing controllers When in doubt, it's almost always better to test against a real API server using envtest.Environment. |
Package controllerutil contains utility functions for working with and implementing Controllers.
|
Package controllerutil contains utility functions for working with and implementing Controllers. |