Documentation
¶
Index ¶
- func CloneObject[objectType comparable](o objectType) objectType
- func GetItems[k8sObjectList client.ObjectList, k8sObject client.Object](o k8sObjectList) (items []k8sObject)
- func GetObjectType(o schema.ObjectKind) string
- func GetObjectWithMeta[k8sObject client.Object](o k8sObject, s runtime.ObjectTyper) k8sObject
- type DefaultSentinelAction
- func (h *DefaultSentinelAction[k8sObject]) Apply(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, ...) (res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) Configure(ctx context.Context, req reconcile.Request, o k8sObject, data map[string]any, ...) (res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) Delete(ctx context.Context, o k8sObject, data map[string]any, objects []client.Object, ...) (res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) Diff(ctx context.Context, o k8sObject, read SentinelRead, data map[string]any, ...) (diff multiphase.MultiPhaseDiff[client.Object], res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) GetFieldManager() string
- func (h *DefaultSentinelAction[k8sObject]) OnDiff(ctx context.Context, o k8sObject, data map[string]any, ...) (res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) OnError(ctx context.Context, o k8sObject, data map[string]any, currentErr error, ...) (res reconcile.Result, err error)
- func (h *DefaultSentinelAction[k8sObject]) OnSuccess(ctx context.Context, o k8sObject, data map[string]any, ...) (res reconcile.Result, err error)
- 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 DefaultSentinelRead
- func (h *DefaultSentinelRead) AddCurrentObject(o client.Object)
- func (h *DefaultSentinelRead) AddExpectedObject(o client.Object)
- func (h *DefaultSentinelRead) GetReads() map[string]multiphase.MultiPhaseRead[client.Object]
- func (h *DefaultSentinelRead) SetCurrentObjects(objects []client.Object)
- func (h *DefaultSentinelRead) SetExpectedObjects(objects []client.Object)
- type DefaultSentinelReconciler
- type SentinelRead
- type SentinelReconciler
- type SentinelReconcilerAction
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
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]) OnDiff ¶
func (h *DefaultSentinelAction[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 (h *DefaultSentinelRead) GetReads() map[string]multiphase.MultiPhaseRead[client.Object]
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) // OnDiff is called between Diff and Apply, after the diff has been computed. // When dry-run diff detection is disabled, the default implementation returns ErrDiffDisabled. // Controllers that need pre-apply tasks can check diff.NeedUpdate() / diff.GetObjectsToUpdate() here. OnDiff(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 // When dryRun is enabled, uses SSA dry-run to classify objects into create/update/delete. // When dryRun is disabled, all expected objects 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.
func NewSentinelAction ¶
func NewSentinelAction[k8sObject client.Object](client client.Client, recorder record.EventRecorder, fieldManager string, dryRun bool) (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. The dryRun parameter enables SSA dry-run diff detection (one extra API call per existing object).