controllers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: Apache-2.0 Imports: 71 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-feature-name"

	// ReferenceLabelKind is added to each policy deployed by a ClusterSummary
	// instance to a CAPI Cluster. Indicates the Kind (ConfigMap or Secret)
	// containing the policy.
	ReferenceLabelKind = "projectsveltos.io/reference-kind"

	// ReferenceLabelName is added to each policy deployed by a ClusterSummary
	// instance to a CAPI Cluster. Indicates the name of the ConfigMap/Secret
	// containing the policy.
	ReferenceLabelName = "projectsveltos.io/reference-name"

	// ReferenceLabelNamespace is added to each policy deployed by a ClusterSummary
	// instance to a CAPI Cluster. Indicates the namespace of the ConfigMap/Secret
	// containing the policy.
	ReferenceLabelNamespace = "projectsveltos.io/reference-namespace"

	// clusterLabelNamespace is the label set on ClusterSummary instances created
	// by a ClusterProfile instance for a given cluster
	ClusterLabelNamespace = "projectsveltos.io/cluster-namespace"

	// clusterLabelName is the label set on ClusterSummary instances created
	// by a ClusterProfile instance for a given cluster
	ClusterLabelName = "projectsveltos.io/cluster-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"

	// PolicyHash is the annotation set on a policy when deployed in a CAPI
	// cluster.
	PolicyHash = "projectsveltos.io/hash"
)

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 GetClusterSummaryName

func GetClusterSummaryName(clusterProfileName, clusterName string) 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)

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: CAPI Cluster namespace/name; value: set of all ClusterProfiles matching the Cluster
	ClusterMap map[configv1alpha1.PolicyRef]*Set
	// key: ClusterProfile; value: set of CAPI Clusters matched
	ClusterProfileMap map[configv1alpha1.PolicyRef]*Set
	// key: ClusterProfile; value ClusterProfile Selector
	ClusterProfiles map[configv1alpha1.PolicyRef]configv1alpha1.Selector
}

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

SetupWithManager sets up the controller with the Manager.

type ClusterSummaryReconciler

type ClusterSummaryReconciler struct {
	*rest.Config
	client.Client
	Scheme               *runtime.Scheme
	Deployer             deployer.DeployerInterface
	ConcurrentReconciles int
	PolicyMux            sync.Mutex                        // use a Mutex to update Map as MaxConcurrentReconciles is higher than one
	ReferenceMap         map[configv1alpha1.PolicyRef]*Set // key: Referenced object; value: set of all ClusterSummaries referencing the resource
	ClusterSummaryMap    map[types.NamespacedName]*Set     // key: ClusterSummary namespace/name; value: set of referenced resources

}

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(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Set

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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