Documentation
¶
Overview ¶
Package reconciler provides the core reconciliation abstractions for Δ-controller sources and targets, implementing the bridge between Kubernetes resources and the controller pipeline.
This package handles the complexity of watching Kubernetes resources, converting them to controller requests, and writing results back to target resources. It supports both native Kubernetes resources and view objects with consistent semantics.
Key components:
- Source: Configurable watch source with label/field selector support.
- Target: Configurable write target with Updater/Patcher semantics.
- Resource: Base abstraction for Kubernetes resource types.
- Request: Reconciliation request with event metadata.
Sources support:
- Multiple resource types (native Kubernetes and views).
- Label and field selectors for filtering.
- Configurable predicates for change detection.
- Namespace-scoped and cluster-scoped resources.
Targets support:
- Updater: Replaces target object content completely.
- Patcher: Applies strategic merge patches to target objects.
Example usage:
source := reconciler.NewSource(mgr, "my-op", opv1a1.Source{
Resource: opv1a1.Resource{Kind: "Pod"},
LabelSelector: &metav1.LabelSelector{...},
})
target := reconciler.NewTarget(mgr, "my-op", opv1a1.Target{
Resource: opv1a1.Resource{Kind: "PodView"},
Type: "Patcher",
})
Index ¶
- func CreateOrUpdate(ctx context.Context, c client.Client, obj object.Object, ...) (controllerutil.OperationResult, error)
- type EventHandler
- func (h EventHandler[O]) Create(ctx context.Context, evt event.TypedCreateEvent[O], ...)
- func (h EventHandler[O]) Delete(ctx context.Context, evt event.TypedDeleteEvent[O], ...)
- func (h EventHandler[O]) Generic(ctx context.Context, evt event.TypedGenericEvent[O], ...)
- func (h EventHandler[O]) Update(ctx context.Context, evt event.TypedUpdateEvent[O], ...)
- type Reconciler
- type Request
- type Resource
- type Source
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOrUpdate ¶
func CreateOrUpdate(ctx context.Context, c client.Client, obj object.Object, f controllerutil.MutateFn) (controllerutil.OperationResult, error)
CreateOrUpdate creates or updates the given object in the Kubernetes cluster. The object's desired state must be reconciled with the existing state inside the passed in callback MutateFn.
The MutateFn is called regardless of creating or updating an object.
It returns the executed operation and an error.
Note: this version differs from default controllerutil.CreateOrUpdate in two subtle ways
- it uses the unstructured API via object.Object,
- changes made by MutateFn to the status subresource will be handled, changes to any other sub-resource will be discarded,
- errors produced by the `Create` branch (after a failed `Get`) will be ignored.
Types ¶
type EventHandler ¶
func (EventHandler[O]) Create ¶
func (h EventHandler[O]) Create(ctx context.Context, evt event.TypedCreateEvent[O], q workqueue.TypedRateLimitingInterface[Request])
Create createa a "create" event.
func (EventHandler[O]) Delete ¶
func (h EventHandler[O]) Delete(ctx context.Context, evt event.TypedDeleteEvent[O], q workqueue.TypedRateLimitingInterface[Request])
Delete creates a "deletion" event.
func (EventHandler[O]) Generic ¶
func (h EventHandler[O]) Generic(ctx context.Context, evt event.TypedGenericEvent[O], q workqueue.TypedRateLimitingInterface[Request])
Generic create a generic event/
func (EventHandler[O]) Update ¶
func (h EventHandler[O]) Update(ctx context.Context, evt event.TypedUpdateEvent[O], q workqueue.TypedRateLimitingInterface[Request])
Update createa an "update" event.
type Reconciler ¶
type Reconciler = reconcile.TypedReconciler[Request]
type Request ¶
type Request struct {
Namespace, Name string
EventType object.DeltaType
GVK schema.GroupVersionKind
}
Definition of a reconciliation request.
type Resource ¶
type Resource interface {
fmt.Stringer
// GetGVK returns the GVK for a resource.
GetGVK() (schema.GroupVersionKind, error)
}
Resource defines a generic resource, either a source or a target.
func NewResource ¶
NewResource creates a new resource.
type Source ¶
type Source interface {
Resource
GetSource() (runtimeSource.TypedSource[Request], error)
fmt.Stringer
}
Source is a generic watch source that knows how to create controller runtime sources.