Documentation ¶
Index ¶
- func EnqueueTracked(by runtime.Object, t tracker.Tracker, s *runtime.Scheme) *handler.EnqueueRequestsFromMapFunc
- func IndexControllersOfType(mgr ctrl.Manager, field string, owner, ownee runtime.Object, ...) error
- func MergeMaps(maps ...map[string]string) map[string]string
- func RetrieveValue(ctx context.Context, key StashKey) interface{}
- func StashValue(ctx context.Context, key StashKey, value interface{})
- func WithStash(ctx context.Context) context.Context
- type Builder
- type ChildReconciler
- type Config
- type Kind
- type Manager
- type ParentReconciler
- type StashKey
- type SubReconciler
- type SyncReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnqueueTracked ¶
func IndexControllersOfType ¶
func MergeMaps ¶
MergeMaps flattens a sequence of maps into a single map. Keys in latter maps overwrite previous keys. None of the arguments are mutated.
func RetrieveValue ¶
func StashValue ¶
Types ¶
type ChildReconciler ¶
type ChildReconciler struct { // ParentType of resource to reconcile ParentType apis.Object // ChildType is the resource being created/updated/deleted by the // reconciler. For example, a parent Deployment would have a ReplicaSet as a // child. ChildType apis.Object // ChildListType is the listing type for the child type. For example, // PodList is the list type for Pod ChildListType runtime.Object // Setup performs initialization on the manager and builder this reconciler // will run with. It's common to setup field indexes and watch resources. // // +optional Setup func(mgr ctrl.Manager, bldr *builder.Builder) error // DesiredChild returns the desired child object for the given parent // object, or nil if the child should not exist. // // Expected function signature: // func(parent apis.Object) (apis.Object, error) // func(ctx context.Context, parent apis.Object) (apis.Object, error) DesiredChild interface{} // ReflectChildStatusOnParent updates the parent object's status with values // from the child. Select types of error are passed, including: // - apierrs.IsConflict // // Expected function signature: // func(parent, child apis.Object, err error) ReflectChildStatusOnParent interface{} // HarmonizeImmutableFields allows fields that are immutable on the current // object to be copied to the desired object in order to avoid creating // updates which are guaranteed to fail. // // Expected function signature: // func(current, desired apis.Object) // // +optional HarmonizeImmutableFields interface{} // MergeBeforeUpdate copies desired fields on to the current object before // calling update. Typically fields to copy are the Spec, Labels and // Annotations. // // Expected function signature: // func(current, desired apis.Object) MergeBeforeUpdate interface{} // SemanticEquals compares two child resources returning true if there is a // meaningful difference that should trigger an update. // // Expected function signature: // func(a1, a2 apis.Object) bool SemanticEquals interface{} // Sanitize is called with an object before logging the value. Any value may // be returned. A meaningful subset of the resource is typically returned, // like the Spec. // // Expected function signature: // func(child apis.Object) interface{} // // +optional Sanitize interface{} Config // IndexField is used to index objects of the child's type based on their // controlling owner. This field needs to be unique within the manager. IndexField string }
ChildReconciler is a sub reconciler that manages a single child resource for a parent. The reconciler will ensure that exactly one child will match the desired state by: - creating a child if none exists - updating an existing child - removing an unneeded child - removing extra children
The flow for each reconciliation request is: - DesiredChild - if child is desired:
- HarmonizeImmutableFields (optional)
- SemanticEquals
- MergeBeforeUpdate
- ReflectChildStatusOnParent
During setup, the child resource type is registered to watch for changes. A field indexer is configured for the owner on the IndexField.
func (*ChildReconciler) SetupWithManager ¶
type Config ¶
type Config struct { client.Client APIReader client.Reader Recorder record.EventRecorder Log logr.Logger Scheme *runtime.Scheme Tracker tracker.Tracker }
Config holds common resources for controllers. The configuration may be passed to sub-reconcilers.
type ParentReconciler ¶
type ParentReconciler struct { // Type of resource to reconcile Type runtime.Object // SubReconcilers are called in order for each reconciler request. If a sub // reconciler errs, further sub reconcilers are skipped. SubReconcilers []SubReconciler Config }
ParentReconciler is a controller-runtime reconciler that reconciles a given existing resource. The ParentType resource is fetched for the reconciler request and passed in turn to each SubReconciler. Finally, the reconciled resource's status is compared with the original status, updating the API server if needed.
func (*ParentReconciler) SetupWithManager ¶
func (r *ParentReconciler) SetupWithManager(mgr ctrl.Manager) error
type SubReconciler ¶
type SubReconciler interface { SetupWithManager(mgr ctrl.Manager, bldr *builder.Builder) error Reconcile(ctx context.Context, parent apis.Object) (ctrl.Result, error) }
SubReconciler are participants in a larger reconciler request. The resource being reconciled is passed directly to the sub reconciler. The resource's status can be mutated to reflect the current state.
type SyncReconciler ¶
type SyncReconciler struct { // Setup performs initialization on the manager and builder this reconciler // will run with. It's common to setup field indexes and watch resources. // // +optional Setup func(mgr ctrl.Manager, bldr *builder.Builder) error // Sync does whatever work is necessary for the reconciler // // Expected function signature: // func(ctx context.Context, parent apis.Object) error // func(ctx context.Context, parent apis.Object) (ctrl.Result, error) Sync interface{} Config }
SyncReconciler is a sub reconciler for custom reconciliation logic. No behavior is defined directly.