Documentation ¶
Index ¶
- Constants
- Variables
- func ClusterPredicates(logger logr.Logger) predicate.Funcs
- func ConfigMapPredicates(logger logr.Logger) predicate.Funcs
- func FluxSourcePredicates(logger logr.Logger) predicate.Funcs
- func GetClusterSummaryName(clusterProfileName, clusterName string, isSveltosCluster bool) string
- func InitScheme() (*runtime.Scheme, error)
- func MachinePredicates(logger logr.Logger) predicate.Funcs
- func RegisterFeatures(d deployer.DeployerInterface, setupLog logr.Logger)
- func SecretPredicates(logger logr.Logger) predicate.Funcs
- func SetManagementClusterAccess(c client.Client, config *rest.Config)
- func SveltosClusterPredicates(logger logr.Logger) predicate.Funcs
- type ClusterProfileReconciler
- func (r *ClusterProfileReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)
- func (r *ClusterProfileReconciler) SetupWithManager(mgr ctrl.Manager) (controller.Controller, error)
- func (r *ClusterProfileReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error
- type ClusterSummaryReconciler
- func (r *ClusterSummaryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error)
- func (r *ClusterSummaryReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) (controller.Controller, error)
- func (r *ClusterSummaryReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error
- func (r *ClusterSummaryReconciler) WatchForFlux(mgr ctrl.Manager, c controller.Controller) error
- type ReportMode
Constants ¶
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 ¶
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 ¶
ClusterPredicates predicates for v1Cluster. ClusterProfileReconciler watches v1Cluster events and react to those by reconciling itself based on following predicates
func ConfigMapPredicates ¶
ConfigMapPredicates predicates for ConfigMaps. ClusterSummaryReconciler watches ConfigMap events and react to those by reconciling itself based on following predicates
func FluxSourcePredicates ¶
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 ¶
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 MachinePredicates ¶
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 ¶
SecretPredicates predicates for Secrets. ClusterSummaryReconciler watches Secret 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) SetupWithManager ¶
func (r *ClusterProfileReconciler) SetupWithManager(mgr ctrl.Manager) (controller.Controller, error)
SetupWithManager sets up the controller with the Manager.
func (*ClusterProfileReconciler) WatchForCAPI ¶
func (r *ClusterProfileReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error
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) 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 (r *ClusterSummaryReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error
func (*ClusterSummaryReconciler) WatchForFlux ¶
func (r *ClusterSummaryReconciler) WatchForFlux(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 )
Source Files ¶
- clusterprofile_controller.go
- clusterprofile_predicates.go
- clusterprofile_transformations.go
- clustersummary_controller.go
- clustersummary_deployer.go
- clustersummary_features.go
- clustersummary_predicates.go
- clustersummary_transformations.go
- clustersummary_watchers.go
- handlers_helm.go
- handlers_kustomize.go
- handlers_resources.go
- handlers_utils.go
- labels.go
- lua_utils.go
- lua_validations.go
- management_cluster.go
- metrics.go
- openapi_validation.go
- resourcesummary.go
- resourcesummary_collection.go
- template_instantiation.go
- utils.go