package
0.0.0-20220404121130-c510420a75d1
Repository: https://github.com/darkowlzz/operator-toolkit.git
Documentation: pkg.go.dev

# README

Composite Controller

Composite controller pattern is used to implement controllers that have a parent or main CRD, based on which the child objects are configured and created. The status of the child objects may be reflected on the parent object status. Changes in the parent object results in update of the child objects.

The lifecycle of the child objects are dependent on the parent object. The dependency can be in the form of owner reference or finalizer. In case of owner reference, the child objects have an owner reference metadata with the parent's reference. When the parent is deleted, the child objects are automatically deleted by the garbage collector. In case of finalizer based dependency, the parent object waits for some custom cleanup operations to complete. Once the cleanup operation is completed successfully, the finalizer on the parent object is removed and the parent is deleted.

Finalizer based cleanup strategy

The finalizer based cleanup strategy is relatively complex compared to the owner reference based cleanup. Following diagrams try to explain the sequence of the actions when finalizer based cleanup is used.

Create reconcile

create sequence diagram

Update reconcile

update sequence diagram

Delete reconcile

delete sequence diagram

# Packages

Package mocks is a generated GoMock package.

# Functions

WithCleanupStrategy sets the CleanupStrategy of the CompositeReconciler.
WithClient sets the k8s client in the reconciler.
WithFinalizer sets the name of the finalizer used by the CompositeReconciler.
WithInitCondition sets the initial status Condition to be used by the CompositeReconciler on a resource object.
WithInstrumentation configures the instrumentation of the CompositeReconciler.
WithName sets the name of the CompositeReconciler.
WithPrototype sets a prototype of the object that's reconciled.
WithScheme sets the runtime Scheme of the CompositeReconciler.

# Constants

FinalizerCleanup allows using custom cleanup logic.
OwnerReferenceCleanup depends on k8s garbage collector.

# Variables

DefaultInitCondition is the default init condition used by the composite reconciler to add to the status of a new resource.

# Structs

CompositeReconciler defines a composite reconciler.

# Interfaces

Controller is the controller interface that must be implemented by a composite controller.

# Type aliases

CleanupStrategy is the resource cleanup strategy used by the reconciler.
CompositeReconcilerOption is used to configure CompositeReconciler.