Documentation ¶
Index ¶
Constants ¶
const ( // OperationSync is the Sync operation of the Operator. OperationSync = "Sync" // OperationTriggerDelete is the TriggerDelete operation of the Operator. OperationTriggerDelete = "TriggerDelete" // OperationGetExistingResourceNames is the GetExistingResourceNames operation of the Operator. OperationGetExistingResourceNames = "GetExistingResourceNames" )
constants for common operations that an Operator can perform. This is used across components to provide context when reporting error. However, it can also be used where ever operation context is required to be specified. Each component can in turn define their own fine-grained operation labels as well.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind string
Kind represents the kind of component that an operator manages.
const ( // StatefulSetKind indicates that the kind of component is a StatefulSet. StatefulSetKind Kind = "StatefulSet" // ServiceAccountKind indicates that the kind of component is a ServiceAccount. ServiceAccountKind Kind = "ServiceAccount" // RoleKind indicates that the kind of component is a Role. RoleKind Kind = "Role" // RoleBindingKind indicates that the kind of component is RoleBinding RoleBindingKind Kind = "RoleBinding" // MemberLeaseKind indicates that the kind of component is a Lease used for an etcd member heartbeat. MemberLeaseKind Kind = "MemberLease" // SnapshotLeaseKind indicates that the kind of component is a Lease used to capture snapshot information. SnapshotLeaseKind Kind = "SnapshotLease" // ConfigMapKind indicates that the kind of component is a ConfigMap. ConfigMapKind Kind = "ConfigMap" // PeerServiceKind indicates that the kind of component is a Service used for etcd peer communication. PeerServiceKind Kind = "PeerService" // ClientServiceKind indicates that the kind of component is a Service used for etcd client communication. ClientServiceKind Kind = "ClientService" // PodDisruptionBudgetKind indicates that the kind of component is a PodDisruptionBudget. PodDisruptionBudgetKind Kind = "PodDisruptionBudget" )
type Operator ¶
type Operator interface { // GetExistingResourceNames gets all resources that currently exist that this Operator manages. GetExistingResourceNames(ctx OperatorContext, etcdObjMeta metav1.ObjectMeta) ([]string, error) // TriggerDelete triggers the deletion of all resources that this Operator manages. TriggerDelete(ctx OperatorContext, etcdObjMeta metav1.ObjectMeta) error // Sync synchronizes all resources that this Operator manages. If a component does not exist then it will // create it. If there are changes in the owning Etcd resource that transpires changes to one or more resources // managed by this Operator then those component(s) will be either be updated or a deletion is triggered. Sync(ctx OperatorContext, etcd *druidv1alpha1.Etcd) error // PreSync performs any preparatory operations that are required before the actual sync operation is performed, // to bring the component to a sync-ready state. If the sync-ready state is already satisfied, // then this method will be a no-op. PreSync(ctx OperatorContext, etcd *druidv1alpha1.Etcd) error }
Operator manages one or more resources of a specific Kind which are provisioned for an etcd cluster.
type OperatorContext ¶
type OperatorContext struct { context.Context // RunID is unique ID identifying a single reconciliation run. RunID string // Logger is the logger that can be used by a reconcile flow or sub-flow. Logger logr.Logger // Data is place-holder for steps to record data that can be accessed by steps ahead in the reconcile flow. Data map[string]string }
OperatorContext holds the underline context.Context along with additional data that needs to be passed from one reconcile-step to another in a multistep reconciliation run.
func NewOperatorContext ¶
NewOperatorContext creates a new instance of OperatorContext.
func (*OperatorContext) SetLogger ¶
func (o *OperatorContext) SetLogger(logger logr.Logger)
SetLogger sets the logger for the OperatorContext.
type Registry ¶
type Registry interface { // Register provides consumers to register a component operator against the kind of component it operates on. Register(kind Kind, operator Operator) // AllOperators gives a map, where the key is the Kind of component that an operator manages and the value is an Operator itself. AllOperators() map[Kind]Operator // GetOperator gets a component operator that operates on the kind. // Returns the component operator if found, else nil will be returned. GetOperator(kind Kind) Operator }
Registry is a facade which gives access to all component operators.