sentinel

package
v3.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneObject

func CloneObject[objectType comparable](o objectType) objectType

CloneObject permit to clone current object type

func GetItems

func GetItems[k8sObjectList client.ObjectList, k8sObject client.Object](o k8sObjectList) (items []k8sObject)

GetItems permit to get items contend from ObjectList interface

func GetObjectType

func GetObjectType(o schema.ObjectKind) string

GetObjectType print the current object type

func GetObjectWithMeta

func GetObjectWithMeta[k8sObject client.Object](o k8sObject, s runtime.ObjectTyper) k8sObject

GetObjectWithMeta return current object with TypeMeta to kwons the object type

Types

type DefaultSentinelAction

type DefaultSentinelAction[k8sObject client.Object] struct {
	controller.ReconcilerAction
	// contains filtered or unexported fields
}

DefaultSentinelAction is the default implementation of SentinelAction (simple variant, always-apply classification).

func (*DefaultSentinelAction[k8sObject]) Apply

func (h *DefaultSentinelAction[k8sObject]) Apply(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, logger *logrus.Entry) (res reconcile.Result, err error)

func (*DefaultSentinelAction[k8sObject]) Configure

func (h *DefaultSentinelAction[k8sObject]) Configure(ctx context.Context, req reconcile.Request, o k8sObject, data map[string]any, logger *logrus.Entry) (res reconcile.Result, err error)

func (*DefaultSentinelAction[k8sObject]) Delete

func (h *DefaultSentinelAction[k8sObject]) Delete(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, logger *logrus.Entry) (res reconcile.Result, err error)

Delete deletes objects

func (*DefaultSentinelAction[k8sObject]) Diff

func (h *DefaultSentinelAction[k8sObject]) Diff(ctx context.Context, o k8sObject, read SentinelRead, data map[string]any, logger *logrus.Entry) (diff multiphase.MultiPhaseDiff[client.Object], res reconcile.Result, err error)

func (*DefaultSentinelAction[k8sObject]) GetFieldManager

func (h *DefaultSentinelAction[k8sObject]) GetFieldManager() string

func (*DefaultSentinelAction[k8sObject]) OnError

func (h *DefaultSentinelAction[k8sObject]) OnError(ctx context.Context, o k8sObject, data map[string]any, currentErr error, logger *logrus.Entry) (res reconcile.Result, err error)

func (*DefaultSentinelAction[k8sObject]) OnSuccess

func (h *DefaultSentinelAction[k8sObject]) OnSuccess(ctx context.Context, o k8sObject, data map[string]any, diff multiphase.MultiPhaseDiff[client.Object], logger *logrus.Entry) (res reconcile.Result, err error)

func (*DefaultSentinelAction[k8sObject]) Read

func (h *DefaultSentinelAction[k8sObject]) Read(ctx context.Context, o k8sObject, data map[string]any, logger *logrus.Entry) (read SentinelRead, res reconcile.Result, err error)

type DefaultSentinelActionWithDiff added in v3.0.2

type DefaultSentinelActionWithDiff[k8sObject client.Object] struct {
	*DefaultSentinelAction[k8sObject]
}

DefaultSentinelActionWithDiff is the default implementation of SentinelReconcilerActionWithDiff. It embeds the simple default action, overrides Diff to use SSA dry-run classification, and adds an OnDiff hook that returns nil by default.

func (*DefaultSentinelActionWithDiff[k8sObject]) Diff added in v3.0.2

func (h *DefaultSentinelActionWithDiff[k8sObject]) Diff(ctx context.Context, o k8sObject, read SentinelRead, data map[string]any, logger *logrus.Entry) (diff multiphase.MultiPhaseDiff[client.Object], res reconcile.Result, err error)

func (*DefaultSentinelActionWithDiff[k8sObject]) OnDiff added in v3.0.2

func (h *DefaultSentinelActionWithDiff[k8sObject]) OnDiff(ctx context.Context, o k8sObject, data map[string]any, diff multiphase.MultiPhaseDiff[client.Object], logger *logrus.Entry) (res reconcile.Result, err error)

type DefaultSentinelRead

type DefaultSentinelRead struct {
	// contains filtered or unexported fields
}

DefaultSentinelRead is the default implementation of SentinelRead

func (*DefaultSentinelRead) AddCurrentObject

func (h *DefaultSentinelRead) AddCurrentObject(o client.Object)

func (*DefaultSentinelRead) AddExpectedObject

func (h *DefaultSentinelRead) AddExpectedObject(o client.Object)

func (*DefaultSentinelRead) GetReads

func (*DefaultSentinelRead) SetCurrentObjects

func (h *DefaultSentinelRead) SetCurrentObjects(objects []client.Object)

func (*DefaultSentinelRead) SetExpectedObjects

func (h *DefaultSentinelRead) SetExpectedObjects(objects []client.Object)

type DefaultSentinelReconciler

type DefaultSentinelReconciler[k8sObject client.Object] struct {
	controller.Reconciler
}

DefaultSentinelReconciler is the default implementation of SentinelReconciler interface

func (*DefaultSentinelReconciler[k8sObject]) Reconcile

func (h *DefaultSentinelReconciler[k8sObject]) Reconcile(ctx context.Context, req reconcile.Request, o k8sObject, data map[string]interface{}, reconcilerAction SentinelReconcilerAction[k8sObject]) (res reconcile.Result, err error)

No need to add finalizer and manage delete All sub resources must be children of main parent. So the clean is handled by kubelet in lazy effort

type SentinelRead

type SentinelRead interface {
	// GetAllCurrentObjects premit to get the map of current objects, mapped by type
	GetReads() map[string]multiphase.MultiPhaseRead[client.Object]

	// SetCurrentObjects will add object on the right list
	SetCurrentObjects(objects []client.Object)

	// AddCurrentObject will add object on the right list
	AddCurrentObject(o client.Object)

	// AddExpectedObject will add object on the right list
	AddExpectedObject(o client.Object)

	// SetExpectedObjects will add object on the right list
	SetExpectedObjects(objects []client.Object)
}

SentinelRead is the interface to store the result of read from sentinel reconciler objectType is the key if you need to handle some type of object to not shuffle them

func NewSentinelRead

func NewSentinelRead(scheme runtime.ObjectTyper) SentinelRead

NewSentinelRead is the default implementation of SentinelRead interface

type SentinelReconciler

type SentinelReconciler[k8sObject client.Object] interface {
	controller.Reconciler

	// Reconcile permit to orchestrate all phase needed to successfully reconcile the object
	Reconcile(ctx context.Context, req reconcile.Request, o k8sObject, data map[string]interface{}, reconciler SentinelReconcilerAction[k8sObject]) (res reconcile.Result, err error)
}

SentinelReconciler must be used when you look resource that your operator is not the owner like ingress, secret, configMap, etc. Some time you should to generate some resource from labels or annotations ... It the use case of this controller

func NewSentinelReconciler

func NewSentinelReconciler[k8sObject client.Object](client client.Client, name string, logger *logrus.Entry, recorder record.EventRecorder) (sentinelReconciler SentinelReconciler[k8sObject])

NewSentinelReconciler is the default implementation of SentinelReconciler interface

type SentinelReconcilerAction

type SentinelReconcilerAction[k8sObject client.Object] interface {
	controller.ReconcilerAction

	// Configure permit to init external provider driver (API client REST)
	// It can also permit to init condition on status
	Configure(ctx context.Context, req reconcile.Request, o k8sObject, data map[string]any, logger *logrus.Entry) (res reconcile.Result, err error)

	// Read permit to read the actual resource state from provider and set it on data map
	Read(ctx context.Context, o k8sObject, data map[string]any, logger *logrus.Entry) (read SentinelRead, res reconcile.Result, err error)

	// Apply permit to apply resources on kubernetes using Server-Side Apply
	Apply(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, logger *logrus.Entry) (res reconcile.Result, err error)

	// Delete permit to delete resources on kubernetes
	Delete(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, logger *logrus.Entry) (res reconcile.Result, err error)

	// OnError is call when error is throwing
	// It the right way to set status condition when error
	OnError(ctx context.Context, o k8sObject, data map[string]any, currentErr error, logger *logrus.Entry) (res reconcile.Result, err error)

	// OnSuccess is call at the end if no error
	// It's the right way to set status condition when everything is good
	OnSuccess(ctx context.Context, o k8sObject, data map[string]any, diff multiphase.MultiPhaseDiff[client.Object], logger *logrus.Entry) (res reconcile.Result, err error)

	// Diff permit to compare the actual state and the expected state.
	// The simple variant always uses always-apply classification: all expected objects
	// with current counterparts go to the update list (legacy always-apply).
	Diff(ctx context.Context, o k8sObject, read SentinelRead, data map[string]any, logger *logrus.Entry) (diff multiphase.MultiPhaseDiff[client.Object], res reconcile.Result, err error)

	// GetFieldManager returns the field manager name for SSA
	GetFieldManager() string
}

SentinelReconcilerAction is the interface that use by sentinel reconciler It uses Server-Side Apply to manage child resources. This is the simple variant: it has no OnDiff hook and Diff always uses always-apply classification (all expected objects with current counterparts are applied).

func NewSentinelAction

func NewSentinelAction[k8sObject client.Object](client client.Client, recorder record.EventRecorder, fieldManager string) (sentinelReconciler SentinelReconcilerAction[k8sObject])

NewSentinelAction creates a new sentinel action using Server-Side Apply. The fieldManager parameter identifies this controller as the owner of the fields it manages. This is the simple variant: Diff always uses always-apply classification and no OnDiff hook is available.

type SentinelReconcilerActionWithDiff added in v3.0.2

type SentinelReconcilerActionWithDiff[k8sObject client.Object] interface {
	SentinelReconcilerAction[k8sObject]

	// OnDiff is called between Diff and Apply, after the diff has been computed.
	// The diff variant always uses SSA dry-run classification. The default implementation
	// returns nil (safe no-op); override it to run pre-apply tasks.
	OnDiff(ctx context.Context, o k8sObject, data map[string]any, diff multiphase.MultiPhaseDiff[client.Object], logger *logrus.Entry) (res reconcile.Result, err error)
}

SentinelReconcilerActionWithDiff is the diff variant of SentinelReconcilerAction. It embeds the base interface and adds OnDiff. Diff always uses SSA dry-run classification, so diff.NeedUpdate() / diff.GetObjectsToUpdate() are reliable in OnDiff.

func NewSentinelActionWithDiff added in v3.0.2

func NewSentinelActionWithDiff[k8sObject client.Object](client client.Client, recorder record.EventRecorder, fieldManager string) (sentinelReconciler SentinelReconcilerActionWithDiff[k8sObject])

NewSentinelActionWithDiff creates a new sentinel action using Server-Side Apply. The fieldManager parameter identifies this controller as the owner of the fields it manages. This is the diff variant: Diff always uses SSA dry-run classification and OnDiff defaults to a safe no-op.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL