controllers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: Apache-2.0 Imports: 121 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 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 SetAgentInMgmtCluster added in v0.52.0

func SetAgentInMgmtCluster(isInMgmtCluster bool)

func SetCAPIOnboardAnnotation added in v0.49.0

func SetCAPIOnboardAnnotation(key string)

func SetDriftDetectionRegistry added in v0.50.0

func SetDriftDetectionRegistry(reg string)

func SetDriftdetectionConfigMap added in v0.34.0

func SetDriftdetectionConfigMap(name string)

func SetLuaConfigMap added in v0.46.0

func SetLuaConfigMap(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

Types

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 ClusterSummaryDeletedError added in v1.1.0

type ClusterSummaryDeletedError struct {
	Message string
}

func (*ClusterSummaryDeletedError) Error added in v1.1.0

type ClusterSummaryPredicate added in v1.0.0

type ClusterSummaryPredicate struct {
	Logger logr.Logger
}

ClusterSummaryStatusPredicate is a custom predicate that filters ClusterSummary s events

func (ClusterSummaryPredicate) Create added in v1.0.0

func (ClusterSummaryPredicate) Delete added in v1.0.0

func (ClusterSummaryPredicate) Generic added in v1.0.0

func (ClusterSummaryPredicate) Update added in v1.0.0

type ClusterSummaryReconciler

type ClusterSummaryReconciler struct {
	*rest.Config
	client.Client
	Scheme               *runtime.Scheme
	Logger               logr.Logger
	ReportMode           ReportMode
	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

	DeletedInstances map[types.NamespacedName]time.Time
	// 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 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

type SortedCorev1ObjectReference added in v0.48.1

type SortedCorev1ObjectReference []corev1.ObjectReference

func (SortedCorev1ObjectReference) Len added in v0.48.1

func (SortedCorev1ObjectReference) Less added in v0.48.1

func (a SortedCorev1ObjectReference) Less(i, j int) bool

func (SortedCorev1ObjectReference) Swap added in v0.48.1

func (a SortedCorev1ObjectReference) Swap(i, j int)

type SortedHelmCharts added in v0.48.1

type SortedHelmCharts []configv1beta1.HelmChart

func (SortedHelmCharts) Len added in v0.48.1

func (a SortedHelmCharts) Len() int

func (SortedHelmCharts) Less added in v0.48.1

func (a SortedHelmCharts) Less(i, j int) bool

func (SortedHelmCharts) Swap added in v0.48.1

func (a SortedHelmCharts) Swap(i, j int)

type SortedKustomizationRefs added in v0.48.1

type SortedKustomizationRefs []configv1beta1.KustomizationRef

func (SortedKustomizationRefs) Len added in v0.48.1

func (a SortedKustomizationRefs) Len() int

func (SortedKustomizationRefs) Less added in v0.48.1

func (a SortedKustomizationRefs) Less(i, j int) bool

func (SortedKustomizationRefs) Swap added in v0.48.1

func (a SortedKustomizationRefs) Swap(i, j int)

type SveltosClusterManager added in v1.0.0

type SveltosClusterManager struct {
	// contains filtered or unexported fields
}

SveltosClusterManager keeps track of managed SveltosCluster in pull-mode. The order might change if addon controller is restarted. But if more than X clusters are in pull mode without a license, it is an invalid configuration anyway.

func GetSveltosClusterManager added in v1.0.0

func GetSveltosClusterManager() *SveltosClusterManager

func NewSveltosClusterManager added in v1.0.0

func NewSveltosClusterManager() *SveltosClusterManager

NewSveltosClusterManager creates and returns a new initialized SveltosClusterManager.

func (*SveltosClusterManager) AddCluster added in v1.0.0

func (m *SveltosClusterManager) AddCluster(cluster *libsveltosv1beta1.SveltosCluster)

AddCluster adds a SveltosCluster to the manager's collection. It ensures that the cluster is not added if it already exists (based on Name and Namespace). This method is thread-safe.

func (*SveltosClusterManager) IsInTopX added in v1.0.0

func (m *SveltosClusterManager) IsInTopX(namespace, name string, x int) bool

IsInTopX checks if a SveltosCluster, identified by its name and namespace, is among the first 'x' registered clusters in the manager's collection. This method is thread-safe.

func (*SveltosClusterManager) RemoveCluster added in v1.0.0

func (m *SveltosClusterManager) RemoveCluster(namespace, name string)

RemoveCluster removes a SveltosCluster from the manager's collection identified by its name and namespace. This method is thread-safe.

type SveltosClusterReconciler added in v1.0.0

type SveltosClusterReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

SveltosClusterReconciler reconciles a SveltosCluster object

func (*SveltosClusterReconciler) Reconcile added in v1.0.0

func (*SveltosClusterReconciler) SetupWithManager added in v1.0.0

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

SetupWithManager sets up the controller with the Manager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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