controllers

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Namespace where reports will be generated
	ReportNamespace = "projectsveltos"
)

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 EvenTriggers.",
			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 EvenTriggers.",
			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 EvenTriggers.",
			e.Object.GetObjectKind()))
		return false
	}
)

Functions

func ClusterSetPredicates added in v0.27.0

func ClusterSetPredicates(logger logr.Logger) predicate.Funcs

ClusterSetPredicates predicates for ClusterSet. EventTriggerReconciler watches ClusterSet events and react to those by reconciling itself based on following predicates

func ConfigMapPredicates added in v0.7.2

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 EventReportPredicates

func EventReportPredicates(logger logr.Logger) predicate.Funcs

EventReportPredicates predicates for EventReport. EventTriggerReconciler watches sveltos EventReport events and react to those by reconciling itself based on following predicates

func EventSourcePredicates

func EventSourcePredicates(logger logr.Logger) predicate.Funcs

EventSourcePredicates predicates for EventSource. EventTriggerReconciler watches sveltos EventSource 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 added in v0.7.2

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 SetVersion added in v0.38.0

func SetVersion(v string)

func SveltosClusterPredicates

func SveltosClusterPredicates(logger logr.Logger) predicate.Funcs

SveltosClusterPredicates predicates for sveltos Cluster. EventTriggerReconciler 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 ClusterReconciler

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

ClusterReconciler reconciles a Cluster object

func (*ClusterReconciler) Reconcile

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

func (*ClusterReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type EventSourceReconciler

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

EventSourceReconciler reconciles a EventSource object

func (*EventSourceReconciler) Reconcile

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

+kubebuilder:rbac:groups=lib.projectsveltos.io,resources=eventsources,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=lib.projectsveltos.io,resources=eventsources/status,verbs=get;update;patch +kubebuilder:rbac:groups=lib.projectsveltos.io,resources=eventsources/finalizers,verbs=update

func (*EventSourceReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type EventTriggerReconciler added in v0.21.0

type EventTriggerReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Deployer             deployer.DeployerInterface
	EventReportMode      ReportMode
	ShardKey             string
	Logger               logr.Logger

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

	// key: Sveltos/CAPI Cluster: value: set of all EventTrigger instances matching the Cluster
	ClusterMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: EventTrigger: value: set of Sveltos/CAPI Clusters matched
	ToClusterMap map[types.NamespacedName]*libsveltosset.Set

	// key: EventTriggers; value EventTrigger Selector
	EventTriggers map[corev1.ObjectReference]libsveltosv1beta1.Selector

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

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

	// key: EventSource: value: set of all EventTrigger referencing it
	EventSourceMap map[corev1.ObjectReference]*libsveltosset.Set

	// Key: EventTrigger: value: set of EventSource referenced
	ToEventSourceMap map[types.NamespacedName]*libsveltosset.Set
}

EventTriggerReconciler reconciles a EventTrigger object

func (*EventTriggerReconciler) Reconcile added in v0.21.0

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

func (*EventTriggerReconciler) SetupWithManager added in v0.21.0

func (r *EventTriggerReconciler) SetupWithManager(mgr ctrl.Manager) (controller.Controller, error)

SetupWithManager sets up the controller with the Manager.

func (*EventTriggerReconciler) WatchForCAPI added in v0.21.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 ReportMode

type ReportMode int
const (
	// Default mode. In this mode, eventManager running
	// in the management cluster periodically collects
	// EventReports from Sveltos/CAPI clusters
	CollectFromManagementCluster ReportMode = iota

	// In this mode, sveltos agent sends EventReport
	// to management cluster.
	// SveltosAgent is provided with Kubeconfig to access
	// management cluster and can only update EventReport
	// (and ClassifierReport and HealthCheckReport).
	AgentSendReportsNoGateway
)

type SveltosClusterReconciler

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

SveltosClusterReconciler reconciles a SveltosCluster object

func (*SveltosClusterReconciler) Reconcile

func (*SveltosClusterReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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