Documentation ¶
Index ¶
- type Advanced
- type AdvancedObject
- func (ar *AdvancedObject) CreateOrUpdateAllResources(maxCreation uint16, stopOnError bool) error
- func (ar *AdvancedObject) Mutate(entry oktres.MutableResourceType) error
- func (ar *AdvancedObject) MutateAllResources(stopOnError bool) error
- func (ar *AdvancedObject) Update(resource oktres.MutableResourceType) error
- type Basic
- type BasicObject
- func (r *BasicObject) Create(resource oktres.Resource, maxCreation uint16) error
- func (r *BasicObject) CreateAllResources(maxCreation uint16, stopOnError bool) error
- func (r *BasicObject) FetchCR(namespacedName types.NamespacedName) error
- func (r *BasicObject) GetCR() client.Object
- func (r *BasicObject) GetCRMeta() v1.Object
- func (r *BasicObject) GetLog() logr.Logger
- func (r *BasicObject) GetManagedStatusConditionType() string
- func (r *BasicObject) GetName() string
- func (r *BasicObject) GetRegisteredResources() []oktres.Resource
- func (r *BasicObject) GetResource(index string) oktres.Resource
- func (r *BasicObject) GetScheme() *runtime.Scheme
- func (r *BasicObject) Init(env string, cr client.Object, statusConditions *[]v1.Condition) error
- func (r *BasicObject) ManageError()
- func (r *BasicObject) ManageSuccess()
- func (r *BasicObject) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
- func (r *BasicObject) RegisterResource(resource oktres.Resource) error
- func (r *BasicObject) RemoveCRFinalizer() error
- func (r *BasicObject) SetEngine(engine Engine)
- type Engine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced interface { Basic Mutate(resource oktres.MutableResourceType) error Update(resource oktres.MutableResourceType) error CreateOrUpdateAllResources(maxCreation uint16, stopOnError bool) error }
Advanced xx
type AdvancedObject ¶
type AdvancedObject struct {
BasicObject
}
AdvancedObject Implementation of the Advanced Reconciler Object based on the Reconciler This reconciler deals with mutable resources.
func (*AdvancedObject) CreateOrUpdateAllResources ¶
func (ar *AdvancedObject) CreateOrUpdateAllResources(maxCreation uint16, stopOnError bool) error
CreateOrUpdateAllResources Utility method to Create or Update all OKT resources (taking care of their types and created/mutation status) The parameter maxCreation specified the maximum count of resources to create in one shot Return immediatley if a raised or current consolidated error is GiveUpReconciliation If stopOnError is true, stop as soon as an error is raised Return the last raised error during the updates
func (*AdvancedObject) Mutate ¶
func (ar *AdvancedObject) Mutate(entry oktres.MutableResourceType) error
Mutate Mutates a mutable resource by applying defaults and values brougth by the Custom Resource (CR) of the Operator After potential mutation or modification, compute new object's fingerprint (Hash) and compare it with the existing fingerprint (hash code). Store the new fingerprint in the expected object. The entry's synch status property (NeedResync) is updated as well. This function adds operation's result in Results list Returns the error if any.
func (*AdvancedObject) MutateAllResources ¶
func (ar *AdvancedObject) MutateAllResources(stopOnError bool) error
MutateAllResources Mutate all Mutable resources Return immediatley if a raised or current consolidated error is GiveUpReconciliation If stopOnError is true, stop as soon as an error is raised Return the last raised error during a resource Mutation
func (*AdvancedObject) Update ¶
func (ar *AdvancedObject) Update(resource oktres.MutableResourceType) error
Update update a mutable resource (so, having a Mutator interface) and modified against its Cluster Peer (NeerResync() = true). The resource passed as arguement must be a Mutable resource This function adds operation's result in reconciler's Results list Returns the error if any.
type Basic ¶
type Basic interface { sigsreconcile.Reconciler //GetLog() logr.Logger //GetScheme() *runtime.Scheme //GetCR() runtime.Object //GetCRMeta() v1.Object okterr.Results Init(env string, cr client.Object, statusConditions *[]v1.Condition) error SetEngine(engine Engine) // Return A base name for resource creation (CRName-env) GetName() string FetchCR(namespacedName types.NamespacedName) error Create(resource oktres.Resource, maxCreation uint16) error CreateAllResources(maxCreation uint16, stopOnError bool) error }
Basic xx
type BasicObject ¶
type BasicObject struct { client.Client // Should be set by the controller-runtime Manager Log logr.Logger // Should be set by the controller-runtime Manager Scheme *runtime.Scheme // Should be set by the controller-runtime Manager // Results is a buffer of errors and/or misc. operations that happened during reconciliation okterr.Results // Indicates wether or not te CR has to be finalized CRHasToBeFinalized bool Params map[string]string // contains filtered or unexported fields }
BasicObject Elemantary implementation of a Reconciler only able to Create resource. Do not mutate them nor update them. Right for an initial deployement only. For a complete set of features, use the Advanced Reconciler object.
Basic Example:
type MyReconciler struct { oktreconciler.BasicObject CR myopv1alpha1.MyApp }
// Blank assignement to check type var _ oktreconciler.Engine = &MyReconciler{}
func (r *MyReconciler) ReconcileWithCR() { // Your reconciliation logic, here! // Note that the CR is already fetched from the Cluster (if it exists) }
func (r *MyReconciler) SetupWithManager(mgr ctrl.Manager) error { r.Client = mgr.GetClient() r.Log = ctrl.Log.WithName("Memcached") r.Scheme = mgr.GetScheme() r.Init("dev", &r.CR, r.CR.Status) engine := oktengines.NewFreeStyle(r) r.SetEngine(engine) r.Params = parameters // Not mandatory // Same as the standard way return ctrl.NewControllerManagedBy(mgr). For(&r.CR). Owns(&v1.Secret{}). ... Complete(r) }
func (r *MyReconciler) Run() { // Manage your reconciliation code here and take benefit of OKT Reconciler facilities // Store all your error(s) and success operation(s) by using the OKT Results interface // CR is already picked from the K8S Cluster // Check CR if r.CR.xxx .... { do_something } if r.CR.yyy .... { raisedError = EEE // Something is wrong in CE We have to giveup here err := okterr.ErrGiveUpReconciliation.Reason(raisedError) r.Results.AddOp(r.CR, okterr.OperationResultCRSemanticError, err, 0) return // Giveup the reconciliation } // Create your resources mysecret := &oktk8s.IngressResource{} mysecret.Init(r.Client, r.CR.Namespace(), r.CR.Name()+"-secret1", nil) r.Results.AddSuccess(mysecret, oktresults.OperationResultRegistrationSuccess, nil) }
func (*BasicObject) Create ¶
func (r *BasicObject) Create(resource oktres.Resource, maxCreation uint16) error
Create creates the given K8S resource on Kubernetes Cluster Warning!! Before calling this function you must ensure (with res.IsCreation() test) that the resource need to be created and does not yet exist (else it will raise an error) MaxCreation is a limit you want to set to avoid to create too much resources during one reconciliation phase. If set to 0, there's NO limit. In case where the max creation count were reached, the create request is not called and a new reconciliation request dealyed at later time (set by requeueDurationOnCreateDelayed seconds) This function adds operation's result in reconciler's Results list Returns the error if any.
func (*BasicObject) CreateAllResources ¶
func (r *BasicObject) CreateAllResources(maxCreation uint16, stopOnError bool) error
CreateAllResources is a convenient method to Create all OKT resources (taking care of their created status) The parameter maxCreation specified the maximum count of resources to create in one shot Return immediatley if a raised or current consolidated error is GiveUpReconciliation If stopOnError is true, stop as soon as an error is raised Return the last raised error during the updates
func (*BasicObject) FetchCR ¶
func (r *BasicObject) FetchCR(namespacedName types.NamespacedName) error
FetchCR Fetch Custom (primary) Resource from the K8S Cluster using the Client provided by the Operator's Manager for this Reconciler
func (*BasicObject) GetCR ¶
func (r *BasicObject) GetCR() client.Object
GetCR return Custom Resource
func (*BasicObject) GetCRMeta ¶
func (r *BasicObject) GetCRMeta() v1.Object
GetCRMeta return CR's metadata DEPRECATED: kept to not break interface with older implementations (before sigs.k8s/.../client.Object introduction). Use GetCR instead.
func (*BasicObject) GetManagedStatusConditionType ¶
func (r *BasicObject) GetManagedStatusConditionType() string
GetManagedStatusConditionType Return the status condition type managed by the Reconciler If no condition list has been provided during the Init() call for this reconciler, return an empty string ("").
func (*BasicObject) GetName ¶
func (r *BasicObject) GetName() string
GetName return the application name based on the CR name + the environement specified at the application Init Return "" if the CR is not yet fetched from the Cluster
func (*BasicObject) GetRegisteredResources ¶
func (r *BasicObject) GetRegisteredResources() []oktres.Resource
GetRegisteredResources Return a slice on all entry pointers in the registry
func (*BasicObject) GetResource ¶
func (r *BasicObject) GetResource(index string) oktres.Resource
GetResource Return the OKT resource from its index in the registry
func (*BasicObject) GetScheme ¶
func (r *BasicObject) GetScheme() *runtime.Scheme
GetScheme return Custom Resource
func (*BasicObject) Init ¶
Init initialize this reconciler for the current environement (env name) and the CR type provided engine argument is a reconciliation engine to link with. The Status type must fulfill the interface OKT Status (okt/results/Status interface) to be taken into account. Else, it is ignored.
func (*BasicObject) ManageError ¶
func (r *BasicObject) ManageError()
ManageError Take care of the Status data conditions of the CR for this reconciler and update it if possible The condition Type managed here is "Reconciliation" with a Status set to True in case of Success or False in case of Error In case of recurrent error, the timer interval growth up exponentialy at each reconciliation cycle (except for an Update Status problem).
func (*BasicObject) ManageSuccess ¶
func (r *BasicObject) ManageSuccess()
ManageSuccess Take care of the Status data of the CR for this reconciler and update it if possible The Status type must fulfill the interface OKT Status (okt/results/Status)
func (*BasicObject) Reconcile ¶
func (r *BasicObject) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
Reconcile is the native Reconcile method (sigs.k8s.io) called by the Operator manager This is the interface between OKT Reconciler and the OperatorSDK
func (*BasicObject) RegisterResource ¶
func (r *BasicObject) RegisterResource(resource oktres.Resource) error
RegisterResource Register OKT Resource in Reconciler registry. Sync OKT Resource with Peer and check its modification status. The modification status is obtained thanks to a hash key computed on the objects' spec. Any modification is thus detected because a new computed key will produce a new hash different than the one stored in the annotations. TODO: Later let the possibility to specify the client to use for each resource (as parameter ?) and not use systematicaly the client provided by the Manager ?
func (*BasicObject) RemoveCRFinalizer ¶
func (r *BasicObject) RemoveCRFinalizer() error
RemoveCRFinalizer Remove CR finalizer (based on Controller Name) and update CR on Cluster. You must Ensure first that the CR has a finalizer to remove!
func (*BasicObject) SetEngine ¶
func (r *BasicObject) SetEngine(engine Engine)
SetEngine Set the OKT engine to use with this reconciler
Directories ¶
Path | Synopsis |
---|---|
* This file is intended to replace the reconciler engine file in `reconciler/engine/stepper.go` For the moment the test does not pass since a weird behaviour of the Build() function that should be fixed quickly.
|
* This file is intended to replace the reconciler engine file in `reconciler/engine/stepper.go` For the moment the test does not pass since a weird behaviour of the Build() function that should be fixed quickly. |