controllers

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 98 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"

	// PolicyTemplate is the annotation that must be set on a policy when the
	// policy is a template and needs variable sustitution.
	PolicyTemplate = "projectsveltos.io/template"
)

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 ClusterPredicates

func ClusterPredicates(logger logr.Logger) predicate.Funcs

ClusterPredicates predicates for v1Cluster. ClusterProfileReconciler watches v1Cluster events and react to those by reconciling itself based on following predicates

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 FluxSourcePredicates

func FluxSourcePredicates(logger logr.Logger) predicate.Funcs

FluxSourcePredicates predicates for GitRepository/OCIRepository/Bucket. ClusterProfileReconciler watches GitRepository/OCIRepository/Bucket events and react to those by reconciling itself based on following predicates

func GetClusterSummaryName

func GetClusterSummaryName(clusterProfileName, clusterName string, isSveltosCluster bool) string

GetClusterSummaryName returns the ClusterSummary name given a ClusterProfile name and CAPI cluster Namespace/Name. This method does not guarantee that name is not already in use. Caller of this method needs to handle that scenario

func InitScheme

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

func MachinePredicates

func MachinePredicates(logger logr.Logger) predicate.Funcs

MachinePredicates predicates for v1Machine. ClusterProfileReconciler watches v1Machine events and react to those by reconciling itself based on following predicates

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 SetManagementClusterAccess

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

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 ClusterProfileReconciler

type ClusterProfileReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	// use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	Mux sync.Mutex
	// key: Sveltos/CAPI Cluster; value: set of all ClusterProfiles matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: ClusterProfile; value: set of Sveltos/CAPI Clusters matched
	ClusterProfileMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: ClusterProfile; value ClusterProfile Selector
	ClusterProfiles map[corev1.ObjectReference]libsveltosv1alpha1.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
}

ClusterProfileReconciler reconciles a ClusterProfile object

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) (controller.Controller, error)

SetupWithManager sets up the controller with the Manager.

func (*ClusterProfileReconciler) WatchForCAPI

type ClusterSummaryReconciler

type ClusterSummaryReconciler struct {
	*rest.Config
	client.Client
	Scheme               *runtime.Scheme
	ReportMode           ReportMode
	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
	ClusterSummaryMap    map[types.NamespacedName]*libsveltosset.Set   // key: ClusterSummary namespace/name; value: set of referenced resources

	// key: Sveltos/CAPI Cluster; value: set of all ClusterSummaries for that Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set
}

ClusterSummaryReconciler reconciles a ClusterSummary object

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,
) (controller.Controller, error)

SetupWithManager sets up the controller with the Manager.

func (*ClusterSummaryReconciler) WatchForCAPI

func (*ClusterSummaryReconciler) WatchForFlux

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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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