controllers

package
v0.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 111 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterSummaryLabelName is added to each policy deployed by a ClusterSummary
	// instance to a CAPI Cluster
	ClusterSummaryLabelName = "projectsveltos.io/cluster-summary-name"

	// ClusterProfileLabelName is added to all ClusterSummary instances created
	// by a ClusterProfile instance
	ClusterProfileLabelName = "projectsveltos.io/cluster-profile-name"

	// ProfileLabelName is added to all ClusterSummary instances created
	// by a Profile instance
	ProfileLabelName = "projectsveltos.io/profile-name"
)

Variables

View Source
var (
	CreateFuncTrue = func(e event.CreateEvent, logger logr.Logger) bool {
		log := logger.WithValues("predicate", "createEvent",
			e.Object.GetObjectKind(), e.Object.GetName(),
		)

		log.V(logs.LogVerbose).Info(fmt.Sprintf(
			"%s did match expected conditions.  Will attempt to reconcile associated ClusterSummaries.",
			e.Object.GetObjectKind()))
		return true
	}

	DeleteFuncTrue = func(e event.DeleteEvent, logger logr.Logger) bool {
		log := logger.WithValues("predicate", "deleteEvent",
			e.Object.GetObjectKind(), e.Object.GetName(),
		)
		log.V(logs.LogVerbose).Info(fmt.Sprintf(
			"%s did match expected conditions.  Will attempt to reconcile associated ClusterSummaries.",
			e.Object.GetObjectKind()))
		return true
	}

	GenericFuncFalse = func(e event.GenericEvent, logger logr.Logger) bool {
		log := logger.WithValues("predicate", "genericEvent",
			e.Object.GetObjectKind(), e.Object.GetName(),
		)
		log.V(logs.LogVerbose).Info(fmt.Sprintf(
			"%s did not match expected conditions.  Will not attempt to reconcile associated ClusterSummaries.",
			e.Object.GetObjectKind()))
		return false
	}
)

Functions

func ConfigMapPredicates

func ConfigMapPredicates(logger logr.Logger) predicate.Funcs

ConfigMapPredicates predicates for ConfigMaps. ClusterSummaryReconciler watches ConfigMap events and react to those by reconciling itself based on following predicates

func GetClusterSummaryName

func GetClusterSummaryName(profileKind, profileName, clusterName string, isSveltosCluster bool) string

GetClusterSummaryName returns the ClusterSummary name given a ClusterProfile/Profile kind/name and cluster type/Name.

func InitScheme

func InitScheme() (*runtime.Scheme, error)

func RegisterFeatures

func RegisterFeatures(d deployer.DeployerInterface, setupLog logr.Logger)

func SecretPredicates

func SecretPredicates(logger logr.Logger) predicate.Funcs

SecretPredicates predicates for Secrets. ClusterSummaryReconciler watches Secret events and react to those by reconciling itself based on following predicates

func SetDriftdetectionConfigMap added in v0.34.0

func SetDriftdetectionConfigMap(name string)

func SetManagementClusterAccess

func SetManagementClusterAccess(c client.Client, config *rest.Config)

func SetPredicates added in v0.26.0

func SetPredicates(logger logr.Logger) predicate.Funcs

SetPredicates predicates for ClusterSet/Set. ClusterProfileReconciler watches ClusterSet/Set events and react to those by reconciling itself based on following predicates

func SetVersion added in v0.22.0

func SetVersion(v string)

func SveltosClusterPredicates

func SveltosClusterPredicates(logger logr.Logger) predicate.Funcs

SveltosClusterPredicates predicates for sveltos Cluster. ClusterProfileReconciler watches sveltos Cluster events and react to those by reconciling itself based on following predicates

Types

type ClusterPredicate added in v0.29.0

type ClusterPredicate struct {
	Logger logr.Logger
}

func (ClusterPredicate) Create added in v0.29.0

func (ClusterPredicate) Delete added in v0.29.0

func (ClusterPredicate) Generic added in v0.29.0

func (ClusterPredicate) Update added in v0.29.0

type ClusterProfileReconciler

type ClusterProfileReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Logger               logr.Logger

	// use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	Mux sync.Mutex

	// key: ClusterSet: value ClusterProfiles currently referencing the ClusterSet
	ClusterSetMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: Sveltos/Cluster; value: set of all ClusterProfiles matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: ClusterProfile; value ClusterProfile Selector
	ClusterProfiles map[corev1.ObjectReference]libsveltosv1beta1.Selector

	// For each cluster contains current labels
	// This is needed in following scenario:
	// - ClusterProfile is created
	// - Cluster is created with labels matching ClusterProfile
	// - When first control plane machine in such cluster becomes available
	// we need Cluster labels to know which ClusterProfile to reconcile
	ClusterLabels map[corev1.ObjectReference]map[string]string
	// contains filtered or unexported fields
}

ClusterProfileReconciler reconciles a ClusterProfile object

func (*ClusterProfileReconciler) GetController added in v0.26.0

func (r *ClusterProfileReconciler) GetController() controller.Controller

func (*ClusterProfileReconciler) Reconcile

func (r *ClusterProfileReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)

func (*ClusterProfileReconciler) SetupWithManager

func (r *ClusterProfileReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*ClusterProfileReconciler) WatchForCAPI

type ClusterSetReconciler added in v0.26.0

type ClusterSetReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Logger               logr.Logger

	// use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	Mux sync.Mutex
	// key: Sveltos/Cluster; value: set of all ClusterSets matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: ClusterSet; value: set of Sveltos/CAPI Clusters matched
	ClusterSetMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: ClusterSets; value ClusterSet Selector
	ClusterSets map[corev1.ObjectReference]libsveltosv1beta1.Selector

	// For each cluster contains current labels
	// This is needed in following scenario:
	// - ClusterSet is created
	// - Cluster is created with labels matching ClusterSet
	// - When first control plane machine in such cluster becomes available
	// we need Cluster labels to know which ClusterSet to reconcile
	ClusterLabels map[corev1.ObjectReference]map[string]string
	// contains filtered or unexported fields
}

ClusterSetReconciler reconciles a ClusterSet object

func (*ClusterSetReconciler) GetController added in v0.26.0

func (r *ClusterSetReconciler) GetController() controller.Controller

func (*ClusterSetReconciler) Reconcile added in v0.26.0

func (r *ClusterSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)

func (*ClusterSetReconciler) SetupWithManager added in v0.26.0

func (r *ClusterSetReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*ClusterSetReconciler) WatchForCAPI added in v0.26.0

func (r *ClusterSetReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error

type ClusterSummaryReconciler

type ClusterSummaryReconciler struct {
	*rest.Config
	client.Client
	Scheme               *runtime.Scheme
	Logger               logr.Logger
	ReportMode           ReportMode
	AgentInMgmtCluster   bool   // if true, indicates drift-detection-manager needs to be started in the management cluster
	ShardKey             string // when set, only clusters matching the ShardKey will be reconciled
	Version              string
	Deployer             deployer.DeployerInterface
	ConcurrentReconciles int
	PolicyMux            sync.Mutex                                    // use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	ReferenceMap         map[corev1.ObjectReference]*libsveltosset.Set // key: Referenced object; value: set of all ClusterSummaries referencing the resource
	ClusterMap           map[corev1.ObjectReference]*libsveltosset.Set // key: Sveltos/Cluster; value: set of all ClusterSummaries for that Cluster

	ConflictRetryTime time.Duration
	// contains filtered or unexported fields
}

ClusterSummaryReconciler reconciles a ClusterSummary object

func (*ClusterSummaryReconciler) GetController added in v0.26.0

func (r *ClusterSummaryReconciler) GetController() controller.Controller

func (*ClusterSummaryReconciler) Reconcile

func (r *ClusterSummaryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)

func (*ClusterSummaryReconciler) SetupWithManager

func (r *ClusterSummaryReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*ClusterSummaryReconciler) WatchForCAPI

func (*ClusterSummaryReconciler) WatchForFlux

type FluxBucketPredicate added in v0.29.0

type FluxBucketPredicate struct {
	Logger logr.Logger
}

func (FluxBucketPredicate) Create added in v0.29.0

func (FluxBucketPredicate) Delete added in v0.29.0

func (FluxBucketPredicate) Generic added in v0.29.0

func (FluxBucketPredicate) Update added in v0.29.0

type FluxGitRepositoryPredicate added in v0.29.0

type FluxGitRepositoryPredicate struct {
	Logger logr.Logger
}

func (FluxGitRepositoryPredicate) Create added in v0.29.0

func (FluxGitRepositoryPredicate) Delete added in v0.29.0

func (FluxGitRepositoryPredicate) Generic added in v0.29.0

func (FluxGitRepositoryPredicate) Update added in v0.29.0

type FluxOCIRepositoryPredicate added in v0.29.0

type FluxOCIRepositoryPredicate struct {
	Logger logr.Logger
}

func (FluxOCIRepositoryPredicate) Create added in v0.29.0

func (FluxOCIRepositoryPredicate) Delete added in v0.29.0

func (FluxOCIRepositoryPredicate) Generic added in v0.29.0

func (FluxOCIRepositoryPredicate) Update added in v0.29.0

type MachinePredicate added in v0.29.0

type MachinePredicate struct {
	Logger logr.Logger
}

func (MachinePredicate) Create added in v0.29.0

func (MachinePredicate) Delete added in v0.29.0

func (MachinePredicate) Generic added in v0.29.0

func (MachinePredicate) Update added in v0.29.0

type NonRetriableError added in v0.22.0

type NonRetriableError struct {
	Message string
}

func (*NonRetriableError) Error added in v0.22.0

func (r *NonRetriableError) Error() string

type ProfileReconciler added in v0.21.0

type ProfileReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Logger               logr.Logger

	// use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	Mux sync.Mutex

	// key: Set; value: set of Profiles currently referencing the Set
	SetMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: Sveltos/Cluster; value: set of all Profiles matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: Profile; value Profile Selector
	Profiles map[corev1.ObjectReference]libsveltosv1beta1.Selector

	// For each cluster contains current labels
	// This is needed in following scenario:
	// - Profile is created
	// - Cluster is created with labels matching Profile
	// - When first control plane machine in such cluster becomes available
	// we need Cluster labels to know which Profile to reconcile
	ClusterLabels map[corev1.ObjectReference]map[string]string
	// contains filtered or unexported fields
}

ProfileReconciler reconciles a Profile object

func (*ProfileReconciler) GetController added in v0.26.0

func (r *ProfileReconciler) GetController() controller.Controller

func (*ProfileReconciler) Reconcile added in v0.21.0

func (r *ProfileReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)

func (*ProfileReconciler) SetupWithManager added in v0.21.0

func (r *ProfileReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*ProfileReconciler) WatchForCAPI added in v0.21.0

func (r *ProfileReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error

type ReportMode

type ReportMode int
const (
	// Default mode. In this mode, addon-controller running
	// in the management cluster periodically collects/processes
	// ResourceSummaries from Sveltos/CAPI Clusters
	CollectFromManagementCluster ReportMode = iota

	// In this mode, drift detection manager sends ResourceSummaries
	// updates to management cluster.
	AgentSendUpdatesNoGateway
)

type SetReconciler added in v0.26.0

type SetReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Logger               logr.Logger

	// use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	Mux sync.Mutex
	// key: Sveltos/Cluster; value: set of all Sets matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: Set; value: set of Sveltos/CAPI Clusters matched
	SetMap map[corev1.ObjectReference]*libsveltosset.Set

	// key: Sets; value Set Selector
	Sets map[corev1.ObjectReference]libsveltosv1beta1.Selector

	// For each cluster contains current labels
	// This is needed in following scenario:
	// - Set is created
	// - Cluster is created with labels matching Set
	// - When first control plane machine in such cluster becomes available
	// we need Cluster labels to know which Set to reconcile
	ClusterLabels map[corev1.ObjectReference]map[string]string
	// contains filtered or unexported fields
}

SetReconciler reconciles a Set object

func (*SetReconciler) GetController added in v0.26.0

func (r *SetReconciler) GetController() controller.Controller

func (*SetReconciler) Reconcile added in v0.26.0

func (r *SetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)

func (*SetReconciler) SetupWithManager added in v0.26.0

func (r *SetReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*SetReconciler) WatchForCAPI added in v0.26.0

func (r *SetReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL