Documentation ¶
Overview ¶
Package controller defines common interfaces to be implemented by the controllers and controller runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { Name() string Inputs() []Input Outputs() []Output Run(context.Context, Runtime, *zap.Logger) error }
Controller interface should be implemented by Controllers.
type DependencyEdge ¶
type DependencyEdge struct { ControllerName string ResourceNamespace resource.Namespace ResourceType resource.Type ResourceID resource.ID EdgeType DependencyEdgeType }
DependencyEdge represents relationship between controller and resource(s).
type DependencyEdgeType ¶
type DependencyEdgeType int
DependencyEdgeType is edge type in controller graph.
const ( EdgeOutputExclusive DependencyEdgeType = iota EdgeInputStrong EdgeInputWeak EdgeInputDestroyReady )
Controller graph edge types.
type DependencyGraph ¶
type DependencyGraph struct {
Edges []DependencyEdge
}
DependencyGraph is the exported information about controller/resources dependencies.
type Engine ¶
type Engine interface { // RegisterController registers new controller. RegisterController(ctrl Controller) error // Run the controllers. Run(ctx context.Context) error }
Engine is the entrypoint into Controller Runtime.
type Input ¶
type Input struct { ID *resource.ID Namespace resource.Namespace Type resource.Type Kind InputKind }
Input of the controller (dependency on some resource(s)).
Each controller might have multiple inputs, it might depend on all the objects of some type under namespace, or on specific object by ID.
Input might be either Weak or Strong. Any kind of input triggers cascading reconcile on changes, Strong dependencies in addition block deletion of parent object until all the dependencies are torn down.
Input can also be "DestroyReady" which means that the controller is watching some of its outputs to be ready to be destroyed. Controller will be notified when the resource enters "teardown" phase and has no finalizers attached. Resources are filtered to be owned by the controller.
type Output ¶
type Output struct { Type resource.Type Kind OutputKind }
Output of the controller.
Controller can only modify resources which are declared as outputs.
type OutputKind ¶
type OutputKind = int
OutputKind for outputs.
const ( OutputExclusive OutputKind = iota )
Output kinds.
type OutputTracker ¶ added in v0.3.1
type OutputTracker interface { StartTrackingOutputs() CleanupOutputs(ctx context.Context, outputs ...resource.Kind) error }
OutputTracker provides automatic cleanup of the outputs based on the calls to Modify function.
OutputTracker is optional, it is enabled by calling StartTrackingOutputs at the beginning of the reconcile cycle. Every call to Modify will be tracked and the outputs which are not touched will be destroyed. Finalize the cleanup by calling CleanupOutputs at the end of the reconcile cycle, it also automatically calls ResetRestartBackoff.
CleanupOutputs doesn't support finalizers on output resources.
type Reader ¶
type Reader interface { Get(context.Context, resource.Pointer, ...state.GetOption) (resource.Resource, error) List(context.Context, resource.Kind, ...state.ListOption) (resource.List, error) WatchFor(context.Context, resource.Pointer, ...state.WatchForConditionFunc) (resource.Resource, error) }
Reader provides read-only access to the state.
state.State also satisfies this interface.
type ReaderWriter ¶ added in v0.3.0
ReaderWriter combines Reader and Writer interfaces.
type ReconcileEvent ¶
type ReconcileEvent struct{}
ReconcileEvent is a signal for controller to reconcile its resources.
type Runtime ¶
type Runtime interface { EventCh() <-chan ReconcileEvent QueueReconcile() ResetRestartBackoff() UpdateInputs([]Input) error Reader Writer OutputTracker }
Runtime interface as presented to the controller.
type Writer ¶
type Writer interface { Create(context.Context, resource.Resource) error Update(context.Context, resource.Resource) error Modify(context.Context, resource.Resource, func(resource.Resource) error) error Teardown(context.Context, resource.Pointer, ...Option) (bool, error) Destroy(context.Context, resource.Pointer, ...Option) error AddFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error RemoveFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error }
Writer provides write access to the state.
Only output objects can be written to by the controller.
Directories ¶
Path | Synopsis |
---|---|
Package conformance implements tests which verify conformance of the implementation with the spec.
|
Package conformance implements tests which verify conformance of the implementation with the spec. |
Package generic provides implementations of generic controllers.
|
Package generic provides implementations of generic controllers. |
cleanup
Package cleanup provides a generic implementation of controller which waits for and cleans up resources.
|
Package cleanup provides a generic implementation of controller which waits for and cleans up resources. |
transform
Package transform provides a generic implementation of controller which transforms resources A into resources B.
|
Package transform provides a generic implementation of controller which transforms resources A into resources B. |
Package protobuf provides wrappers/adapters between gRPC service and runtime.Engine.
|
Package protobuf provides wrappers/adapters between gRPC service and runtime.Engine. |
client
Package client provides a wrapper around gRPC Runtime client to present it as controller.Engine interface.
|
Package client provides a wrapper around gRPC Runtime client to present it as controller.Engine interface. |
server
Package server provides a wrapper around controller.Runtime over gRPC.
|
Package server provides a wrapper around controller.Runtime over gRPC. |
Package runtime implements the controller runtime.
|
Package runtime implements the controller runtime. |
dependency
Package dependency implements the dependency handling database.
|
Package dependency implements the dependency handling database. |