Documentation
¶
Overview ¶
Package concepts defines the core concepts for the operator component framework.
Index ¶
- type Alive
- type AliveConvergingStatus
- type AliveStatusWithReason
- type Completable
- type CompletionStatus
- type CompletionStatusWithReason
- type ConvergingOperation
- type DataExtractable
- type GraceStatus
- type GraceStatusWithReason
- type Graceful
- type GuardStatus
- type GuardStatusWithReason
- type Guardable
- type Operational
- type OperationalStatus
- type OperationalStatusWithReason
- type Suspendable
- type SuspensionStatus
- type SuspensionStatusWithReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alive ¶
type Alive interface {
// ConvergingStatus returns the resource's current progress towards "Ready".
// The provided ConvergingOperation helps the resource decide if it's currently Creating or Updating.
ConvergingStatus(op ConvergingOperation) (AliveStatusWithReason, error)
}
Alive defines the contract for resources that have observable health and readiness. Resources implementing this interface contribute to the component's aggregate status. If a resource does NOT implement Alive, it is considered "Ready" as long as it exists.
type AliveConvergingStatus ¶
type AliveConvergingStatus string
AliveConvergingStatus represents the transitional state of an alive resource as it moves towards "healthy".
const ( // AliveConvergingStatusHealthy indicates the resource has reached its desired state and is fully operational. AliveConvergingStatusHealthy AliveConvergingStatus = "Healthy" // AliveConvergingStatusCreating indicates the resource is being created for the first time. AliveConvergingStatusCreating AliveConvergingStatus = "Creating" // AliveConvergingStatusUpdating indicates an existing resource is being updated with new configuration. AliveConvergingStatusUpdating AliveConvergingStatus = "Updating" // AliveConvergingStatusScaling indicates the resource is scaling its capacity (e.g., adding/removing replicas). AliveConvergingStatusScaling AliveConvergingStatus = "Scaling" // AliveConvergingStatusFailing indicates the resource is failing to converge to healthy. AliveConvergingStatusFailing AliveConvergingStatus = "Failing" )
type AliveStatusWithReason ¶
type AliveStatusWithReason struct {
// Status is the status of the resource while converging towards healthy (can also be healthy).
Status AliveConvergingStatus
// Reason explains why the resource is currently healthy, Creating, Updating or Scaling.
// Examples:
// - With Status=healthy: Deployment is healthy.
// - With Status=Created (ConvergingOperationCreated): Deployment has 2/3 healthy replicas.
// - With Status=Updated (ConvergingOperationUpdated): Deployment has 2/3 healthy replicas.
// - With Status=Scaling (ConvergingOperationNone): Deployment has 0/3 healthy replicas.
// - With Status=failing: failing to pull image
Reason string
}
AliveStatusWithReason is the explanation of why the resource is or is not healthy at health checking time.
func StaleGenerationStatus ¶
func StaleGenerationStatus( op ConvergingOperation, observedGeneration, generation int64, resourceKind string, ) *AliveStatusWithReason
StaleGenerationStatus checks whether a resource's controller has observed the latest spec by comparing ObservedGeneration against the object's Generation. If the controller is behind, it returns a non-nil AliveStatusWithReason with an appropriate Creating or Updating status. If the generation is current, it returns nil.
This should be called at the top of a DefaultConvergingStatusHandler before evaluating readiness fields, which may be stale when the controller has not yet reconciled the latest generation.
if status := concepts.StaleGenerationStatus(op, obj.Status.ObservedGeneration, obj.Generation, "deployment"); status != nil {
return *status, nil
}
type Completable ¶
type Completable interface {
// ConvergingStatus returns the resource's current completion state.
// The provided ConvergingOperation helps the resource decide its current status.
ConvergingStatus(op ConvergingOperation) (CompletionStatusWithReason, error)
}
Completable defines the contract for resources that run to completion rather than being long-running. Resources implementing this interface contribute to the component's aggregate completion status.
type CompletionStatus ¶
type CompletionStatus string
CompletionStatus represents the execution state of a resource that runs to completion (e.g., Jobs, Tasks).
const ( // CompletionStatusCompleted indicates the resource has finished its execution successfully. CompletionStatusCompleted CompletionStatus = "Completed" // CompletionStatusRunning indicates the resource is currently running. CompletionStatusRunning CompletionStatus = "TaskRunning" // CompletionStatusPending indicates the resource is waiting to start. CompletionStatusPending CompletionStatus = "TaskPending" // CompletionStatusFailing indicates the resource has finished its execution with an error. CompletionStatusFailing CompletionStatus = "TaskFailing" )
type CompletionStatusWithReason ¶
type CompletionStatusWithReason struct {
// Status is the current execution state of the resource.
Status CompletionStatus
// Reason explains why the resource is in the current status.
// Examples:
// - With Status=Completed: Job has finished successfully.
// - With Status=TaskRunning: Job has 1/1 active pods.
// - With Status=TaskPending: Job is waiting for pods to be scheduled.
// - With Status=TaskFailing: Job failed with exit code 1.
Reason string
}
CompletionStatusWithReason is the explanation of why the resource is in its current execution state.
type ConvergingOperation ¶
type ConvergingOperation string
ConvergingOperation represents the result of a CreateOrUpdate operation on a resource. It provides context to the Alive interface to help determine the ConvergingStatus.
const ( // ConvergingOperationCreated indicates that the resource was newly created. ConvergingOperationCreated ConvergingOperation = "Created" // ConvergingOperationUpdated indicates that an existing resource was updated. ConvergingOperationUpdated ConvergingOperation = "Updated" // ConvergingOperationNone indicates that no changes were made to the resource. ConvergingOperationNone ConvergingOperation = "None" )
func ConvergingOperationFromOperationResult ¶
func ConvergingOperationFromOperationResult(result controllerutil.OperationResult) ConvergingOperation
ConvergingOperationFromOperationResult maps a controllerutil.OperationResult to a ConvergingStatus.
type DataExtractable ¶
type DataExtractable interface {
// ExtractData performs the data extraction from the resource's underlying Kubernetes object.
// The implementation should store the extracted data in its own fields or shared state
// where it can be accessed by the caller.
ExtractData() error
}
DataExtractable defines the contract for resources that need to expose internal data after they have been created, updated, or fetched from the cluster.
Implement this interface when a resource contains information (like generated credentials, endpoint URLs, or status fields) that needs to be pulled back into the operator's memory for use by other components or for updating the parent CRD's status.
Data extraction is intended to be an observational/read-only operation on the resource.
Extraction is triggered immediately after each resource is applied or fetched during reconciliation, regardless of whether the resource is managed or read-only. This allows data extracted from one resource to be available to subsequent resources' guards and mutations within the same reconciliation cycle. Extraction always occurs before the final component condition is calculated.
type GraceStatus ¶
type GraceStatus string
GraceStatus represents the health of a resource after the allowed grace period has expired.
const ( // GraceStatusHealthy indicates the resource is fully healthy after the grace period. GraceStatusHealthy = GraceStatus(AliveConvergingStatusHealthy) // GraceStatusDegraded indicates the resource is partially functional or in an intermediate state // after the grace period has expired. GraceStatusDegraded GraceStatus = "Degraded" // GraceStatusDown indicates the resource is completely non-functional after the grace period. GraceStatusDown GraceStatus = "Down" )
func (GraceStatus) Priority ¶
func (s GraceStatus) Priority() int
Priority returns the priority of the grace status. Higher values indicate more severe health issues. This is used for status aggregation: "Down" takes precedence over "Degraded", which takes precedence over "Ready".
type GraceStatusWithReason ¶
type GraceStatusWithReason struct {
// Status is the status of the resource when the grace period expired.
Status GraceStatus
// Reason explains the reason why the resource is healthy, Down or Degraded at grace expiry.
// Examples:
// - With Status=healthy: Deployment is healthy.
// - With Status=Degraded: Deployment has 2/3 healthy replicas.
// - With Status=Down: Deployment has 0/3 healthy replicas.
Reason string
}
GraceStatusWithReason is the explanation of why the resource did or did not converge to healthy on grace expiry.
type Graceful ¶
type Graceful interface {
// GraceStatus returns the final health assessment after the component's grace period has expired.
// The implementation should assume the grace period HAS expired and return its current state
// (healthy, Degraded, or Down) without internal timing logic.
GraceStatus() (GraceStatusWithReason, error)
}
Graceful defines the contract for resources which have time constrained convergence.
type GuardStatus ¶ added in v0.4.0
type GuardStatus string
GuardStatus represents whether a resource's guard precondition has been met.
const ( // GuardStatusBlocked indicates that the resource's precondition is not yet satisfied. // The resource will not be applied and all resources registered after it are also skipped. GuardStatusBlocked GuardStatus = "Blocked" // GuardStatusUnblocked indicates that the resource's precondition is satisfied // and the resource can be applied normally. GuardStatusUnblocked GuardStatus = "Unblocked" )
type GuardStatusWithReason ¶ added in v0.4.0
type GuardStatusWithReason struct {
// Status is the guard evaluation result.
Status GuardStatus
// Reason provides a human-readable explanation of why the guard is in this state.
Reason string
}
GuardStatusWithReason pairs a guard evaluation result with a human-readable explanation.
type Guardable ¶ added in v0.4.0
type Guardable interface {
// GuardStatus evaluates the resource's precondition and returns whether
// the resource is ready to be applied.
GuardStatus() (GuardStatusWithReason, error)
}
Guardable defines the contract for resources that have preconditions which must be satisfied before the resource can be applied to the cluster.
When a guard evaluates to Blocked, the resource is not applied and all resources registered after it in the component are also skipped. The blocked reason is surfaced in the component's status condition.
Guards are not evaluated during suspension. Suspension proceeds regardless of guard state to ensure the component can always be fully deactivated.
type Operational ¶
type Operational interface {
ConvergingStatus(op ConvergingOperation) (OperationalStatusWithReason, error)
}
Operational describes resources who are not necessarily alive but depend on assignments or other external dependencies to be considered operational. This can be services, ingresses, cronjob schedules, or any other resource who may be perceived as static but also depend on cluster-external factors.
type OperationalStatus ¶
type OperationalStatus string
OperationalStatus represents the operational state of a resource.
const ( // OperationalStatusOperational indicates the resource is fully operational. OperationalStatusOperational OperationalStatus = "Operational" // OperationalStatusPending indicates the resource is waiting to become operational. OperationalStatusPending OperationalStatus = "OperationPending" // OperationalStatusFailing indicates the resource is not operational. OperationalStatusFailing OperationalStatus = "OperationFailing" )
type OperationalStatusWithReason ¶
type OperationalStatusWithReason struct {
// Status is the status of the resource while converging towards operational (can also be operational).
Status OperationalStatus
// Reason explains why the resource is currently 'Operational', 'Pending' or 'Failing'.
// Examples:
// - With Status=Operational: Service load balancer IP address assigned.
// - With Status=Pending: Awaiting load balancer IP assignment.
// - With Status=Failing: Missing cloud provider annotation for load balancer assignment.
Reason string
}
OperationalStatusWithReason is the explanation of why the resource is or is not operational at checking time.
type Suspendable ¶
type Suspendable interface {
// DeleteOnSuspend returns true if the resource should be deleted after suspension is complete.
// Note: Suspend() and SuspensionStatus() are still called even if this returns true.
// The resource must reach SuspensionStatusSuspended before it is actually deleted.
// This allows for necessary cleanup or state persistence (e.g., ensuring disks are retained)
// before the Kubernetes object is removed.
DeleteOnSuspend() bool
// Suspend applies suspension mutations to the resource's desired state.
// The suspension intent MUST be stored in the wrapper's internal state and applied
// during a subsequent Mutate() call.
// Suspend MUST NOT mutate the Kubernetes cluster state directly.
Suspend() error
// SuspensionStatus returns the current progress of the suspension.
// It is called after Suspend() to track when the resource has reached the desired state.
SuspensionStatus() (SuspensionStatusWithReason, error)
}
Suspendable defines the contract for resources that support controlled suspension. Suspension can be achieved through deletion, mutations (like scaling to zero), or both. Any resource not implementing this interface is considered non-suspendable and remains active.
type SuspensionStatus ¶
type SuspensionStatus string
SuspensionStatus is the status determined for the resource at suspension time. It represents the progress of a resource towards a fully suspended state.
const ( // SuspensionStatusPending indicates that the suspension is waiting for a precondition to be met. SuspensionStatusPending SuspensionStatus = "PendingSuspension" // SuspensionStatusSuspending indicates that suspension is in progress but not yet completed. // For example, a Deployment might be scaling down its replicas. SuspensionStatusSuspending SuspensionStatus = "Suspending" // SuspensionStatusSuspended indicates that the suspension has successfully completed. SuspensionStatusSuspended SuspensionStatus = "Suspended" )
func (SuspensionStatus) Priority ¶
func (s SuspensionStatus) Priority() int
Priority returns the priority of the suspension status. Higher values indicate a state that is further from the desired "Suspended" state. This is used for status aggregation when multiple resources are being suspended.
type SuspensionStatusWithReason ¶
type SuspensionStatusWithReason struct {
// Status is the status of the resource while converging towards Suspended (can also be Suspended)
Status SuspensionStatus
// Reason explains the reason why the Status is currently PendingSuspension, Suspending or Suspended.
// Examples:
// - With Status=PendingSuspension (SuspensionStatusPending): Waiting for statefulset observed generation to match generation.
// - With Status=Suspending (SuspensionStatusSuspending): Replicas scaling down. 1/3 replicas running.
// - With Status=Suspended (SuspensionStatusSuspended): Replicas scaled down to 0.
Reason string
}
SuspensionStatusWithReason is the explanation of why the resource is or is not Suspended at suspension checking time.