controllers

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 54 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 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. EventBasedAddOnReconciler watches v1Cluster 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. EventBasedAddOnReconciler 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. EventBasedAddOnReconciler 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. EventBasedAddOnReconciler watches sveltos EventSource events and react to those by reconciling itself based on following predicates

func InitScheme

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

func MachinePredicates

func MachinePredicates(logger logr.Logger) predicate.Funcs

MachinePredicates predicates for v1Machine. EventBasedAddOnReconciler 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 added in v0.7.2

func SecretPredicates(logger logr.Logger) predicate.Funcs

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

func SveltosClusterPredicates

func SveltosClusterPredicates(logger logr.Logger) predicate.Funcs

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

Types

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 EventBasedAddOnReconciler

type EventBasedAddOnReconciler struct {
	client.Client
	Scheme               *runtime.Scheme
	ConcurrentReconciles int
	Deployer             deployer.DeployerInterface
	EventReportMode      ReportMode

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

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

	// key: EventBasedAddOns; value EventBasedAddOn Selector
	EventBasedAddOns map[corev1.ObjectReference]libsveltosv1alpha1.Selector

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

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

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

	// key: Referenced object; value: set of all EventBasedAddOns referencing the resource
	ReferenceMap map[corev1.ObjectReference]*libsveltosset.Set
	// key: EventBasedAddOns name; value: set of referenced resources
	EventBasedAddOnMap map[types.NamespacedName]*libsveltosset.Set
}

EventBasedAddOnReconciler reconciles a EventBasedAddOn object

func (*EventBasedAddOnReconciler) Reconcile

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

func (*EventBasedAddOnReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

func (*EventBasedAddOnReconciler) WatchForCAPI

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 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