Documentation
¶
Index ¶
Constants ¶
const ( OperationResultDeletionFailed controllerutil.OperationResult = "deletionFailed" OperationResultDeletionRequested controllerutil.OperationResult = "deletionRequested" OperationResultDeleted controllerutil.OperationResult = "deleted" OperationResultOrphaned controllerutil.OperationResult = "orphaned" )
const ( StatusPhaseReady = "Ready" StatusPhaseProgressing = "Progressing" StatusPhaseTerminating = "Terminating" StatusPhaseUnknown = "Unknown" )
Variables ¶
var ErrCleanup = errors.New("cleanup failed")
ErrCleanup indicates that a cleaner could not list its target objects.
var ErrReconcileManagedObjects = errors.New("managed objects contain reconcile errors")
ErrReconcileManagedObjects indicates that one or more managed objects returned an error.
Functions ¶
This section is empty.
Types ¶
type Cleaner ¶
Cleaner removes objects that are no longer part of the desired state.
func NewCleaner ¶
func NewCleaner[T client.ObjectList](cluster Cluster, serviceProvider, namespace string, config CleanerConfig[T]) Cleaner
NewCleaner removes redundant objects in a target namespace.
type CleanerConfig ¶
type CleanerConfig[T client.ObjectList] struct { ObjectsToKeep []corev1.LocalObjectReference EmptyList func() T PreDeletionSteps func(context.Context, client.Object) (proceed bool, err error) }
CleanerConfig describes the objects a Cleaner should retain.
type Cluster ¶
type Cluster interface {
AddObject(Object)
GetObjects() []Object
GetDefaultNamespace() string
GetClient() client.Client
GetClusterType() ClusterType
}
Cluster holds objects that are reconciled against one Kubernetes client.
func NewCluster ¶
func NewCluster(client client.Client, namespace string, clusterType ClusterType) Cluster
NewCluster creates an object-manager cluster from a Kubernetes client.
type ClusterType ¶
type ClusterType string
ClusterType identifies the role of a target cluster.
const ( ManagedControlPlane ClusterType = "ManagedControlPlane" PlatformCluster ClusterType = "PlatformCluster" WorkloadCluster ClusterType = "WorkloadCluster" )
type DeletionPolicy ¶
type DeletionPolicy string
DeletionPolicy distinguishes between deleting and orphaning an object.
const ( Orphan DeletionPolicy = "orphan" Delete DeletionPolicy = "delete" )
type ManagedObject ¶
type ManagedObject struct {
APIGroup string `json:"apiGroup,omitempty"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Location string `json:"location,omitempty"`
Status ManagedObjectStatus `json:"status,omitempty"`
}
ManagedObject is the serializable result returned by Apply and Delete. Its JSON tags allow consumers to use it directly in their status API.
type ManagedObjectStatus ¶
type ManagedObjectStatus struct {
Phase string `json:"phase,omitempty"`
Message string `json:"message,omitempty"`
}
ManagedObjectStatus describes an object's observed lifecycle state.
func SimpleStatus ¶
func SimpleStatus(object client.Object) ManagedObjectStatus
SimpleStatus reports whether an object is terminating, pending, or present.
type Manager ¶
type Manager interface {
AddCluster(Cluster)
AddCleaner(Cleaner)
Apply(context.Context) (ReconcileResult, error)
Delete(context.Context) (ReconcileResult, error)
}
Manager reconciles objects across one or more clusters.
func NewManager ¶
NewManager creates a Manager for a service provider.
type Object ¶
type Object interface {
GetObject() client.Object
Reconcile(context.Context) error
GetDependencies() []Object
GetDeletionPolicy() DeletionPolicy
GetStatus() ManagedObjectStatus
}
Object represents an object managed by a Manager.
type ObjectConfig ¶
type ObjectConfig struct {
ReconcileFunc ReconcileFunc
DependsOn []Object
DeletionPolicy DeletionPolicy
StatusFunc StatusFunc
}
ObjectConfig configures an object registered with a Cluster.
type ReconcileFunc ¶
ReconcileFunc configures an object before it is created or updated.
type ReconcileResult ¶
type ReconcileResult struct {
Results []Result
// Requeue indicates
// - on Apply: at least one object reports status phase != ready
// - on Delete: at least one object remains that is not deleted/orphaned
Requeue bool
}
ReconcileResult is the consolidated return value for Apply and Delete.
func (ReconcileResult) ManagedObjects ¶
func (rr ReconcileResult) ManagedObjects() []ManagedObject
type Result ¶
type Result struct {
Object Object
Cluster Cluster
OperationResult controllerutil.OperationResult
Error error
}
Result summarizes one object reconciliation result.
type StatusFunc ¶
type StatusFunc func(client.Object) ManagedObjectStatus
StatusFunc returns the lifecycle status of an object.