Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type K8sPhaseReconciler ¶ added in v0.1.0
type K8sPhaseReconciler interface {
// Configure permit to init condition on status
Configure(ctx context.Context, req ctrl.Request, resource client.Object) (res ctrl.Result, err error)
// Read permit to read kubernetes resources
Read(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
// Create permit to create resources on kubernetes
Create(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
// Update permit to update resources on kubernetes
Update(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
// Delete permit to delete resources on kubernetes
Delete(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
// OnError is call when error is throwing on current phase
// It the right way to set status condition when error
OnError(ctx context.Context, r client.Object, data map[string]any, currentErr error) (res ctrl.Result, err error)
// OnSuccess is call at the end of current phase, if not error
// It's the right way to set status condition when everithink is good
OnSuccess(ctx context.Context, r client.Object, data map[string]any, diff K8sDiff) (res ctrl.Result, err error)
// Diff permit to compare the actual state and the expected state
Diff(ctx context.Context, r client.Object, data map[string]any) (diff K8sDiff, res ctrl.Result, err error)
// GetName return the reconciler name
GetName() string
}
type K8sReconciler ¶ added in v0.1.0
type K8sReconciler interface {
// Configure permit to init condition on status
Configure(ctx context.Context, req ctrl.Request, resource client.Object) (res ctrl.Result, err error)
// Read permit to read kubernetes resources
Read(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
// Delete permit to delete resources on kubernetes
Delete(ctx context.Context, r client.Object, data map[string]any) (err error)
// OnError is call when error is throwing on current phase
// It the right way to set status condition when error
OnError(ctx context.Context, r client.Object, data map[string]any, currentErr error) (res ctrl.Result, err error)
// OnSuccess is call at the end of current phase, if not error
// It's the right way to set status condition when everithink is good
OnSuccess(ctx context.Context, r client.Object, data map[string]any) (res ctrl.Result, err error)
}
type Reconciler ¶
type Reconciler interface {
// Confirgure permit to init external provider driver (API client REST)
// It can also permit to init condition on status
Configure(ctx context.Context, req ctrl.Request, resource client.Object) (meta any, err error)
// Read permit to read the actual resource state from provider and set it on data map
Read(ctx context.Context, r client.Object, data map[string]any, meta any) (res ctrl.Result, err error)
// Create permit to create resource on provider
// It only call if diff.NeeCreated is true
Create(ctx context.Context, r client.Object, data map[string]any, meta any) (res ctrl.Result, err error)
// Update permit to update resource on provider
// It only call if diff.NeedUpdated is true
Update(ctx context.Context, r client.Object, data map[string]any, meta any) (res ctrl.Result, err error)
// Delete permit to delete resource on provider
// It only call if you have specified finalizer name when you create reconciler and if resource as marked to be deleted
Delete(ctx context.Context, r client.Object, data map[string]any, meta any) (err error)
// OnError is call when error is throwing
// It the right way to set status condition when error
OnError(ctx context.Context, r client.Object, data map[string]any, meta any, err error)
// OnSuccess is call at the end if no error
// It's the right way to set status condition when everithink is good
OnSuccess(ctx context.Context, r client.Object, data map[string]any, meta any, diff Diff) (err error)
// Diff permit to compare the actual state and the expected state
Diff(r client.Object, data map[string]any, meta any) (diff Diff, err error)
}
type StdK8sReconciler ¶ added in v0.1.0
func NewStdK8sReconciler ¶ added in v0.1.0
func NewStdK8sReconciler(client client.Client, finalizer string, reconciler K8sReconciler, logger *logrus.Entry, recorder record.EventRecorder) (stdK8sReconciler *StdK8sReconciler, err error)
func (*StdK8sReconciler) Reconcile ¶ added in v0.1.0
func (h *StdK8sReconciler) Reconcile(ctx context.Context, req ctrl.Request, r client.Object, data map[string]interface{}, reconcilers ...K8sPhaseReconciler) (res ctrl.Result, err error)
ReconcileK8sResources permit to reconcile kubernetes resources, so the step is not the same on Reconcile. When handle kubernetes resources, you should to chain the reconcile on multiple resources It will run on following steps 1. Read the main object 2. Configure finalizer on the main object 3. Execute each phase that concist of: 3.1 Read kubernetes objects 3.2 Diff kubernetes resources with expected resources 3.3 Update / create resources if needed 3.4 Delete resources if needed 4. Delete finalizer if on delete action
type StdReconciler ¶
func NewStdReconciler ¶
func NewStdReconciler(client client.Client, finalizer string, reconciler Reconciler, logger *logrus.Entry, recorder record.EventRecorder) (stdReconciler *StdReconciler, err error)
func (*StdReconciler) Reconcile ¶
func (h *StdReconciler) Reconcile(ctx context.Context, req ctrl.Request, r client.Object, data map[string]interface{}) (res ctrl.Result, err error)
Reconcile permit to reconcile resource one external service, throughtout API It will handle all aspect of that 1. Read resource on kubernetes 2. Configure finalizer 3. Read external resources 4. Check if on delete phase, delete external resources if on it 5. Diff external resources with the expected resources 6. Create or update external resources if needed