Thanks to visit codestin.com
Credit goes to pkg.go.dev

multicluster

package
v0.22.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: Apache-2.0 Imports: 4 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClusterNotFound can be returned by provider implementations if the cluster requested
	// doesn't exist and cannot be constructed.
	ErrClusterNotFound = errClusterNotFound()
)

Functions

This section is empty.

Types

type Aware

type Aware interface {
	// Engage gets called when the component should start operations for the given Cluster.
	// The given context is tied to the Cluster's lifecycle and will be cancelled when the
	// Cluster is removed or an error occurs.
	//
	// Engage is a no-op if the passed cluster is equal to the existing, already
	// engaged cluster (equal means interface equality, i.e. the same instance).
	//
	// Implementers should return an error if they cannot start operations for the given Cluster,
	// and should ensure this operation is re-entrant and non-blocking.
	//
	//	\_________________|)____.---'--`---.____
	//              ||    \----.________.----/
	//              ||     / /    `--'
	//            __||____/ /_
	//           |___         \
	//               `--------'
	Engage(context.Context, string, cluster.Cluster) error
}

Aware is an interface that can be implemented by components that can engage and disengage when clusters are added or removed at runtime.

type Provider

type Provider interface {
	// Get returns a cluster for the given identifying cluster name. Get
	// returns an existing cluster if it has been created before.
	// If no cluster is known to the provider under the given cluster name,
	// ErrClusterNotFound should be returned.
	Get(ctx context.Context, clusterName string) (cluster.Cluster, error)

	// IndexField indexes the given object by the given field on all engaged
	// clusters, current and future.
	IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error
}

Provider allows to retrieve clusters by name. The provider is responsible for discovering and managing the lifecycle of each cluster, calling `Engage` on the manager it is run against whenever a new cluster is discovered and cancelling the context used on engage when a cluster is unregistered.

Example: A Cluster API provider would be responsible for discovering and managing clusters that are backed by Cluster API resources, which can live in multiple namespaces in a single management cluster.

type ProviderRunnable

type ProviderRunnable interface {
	// Start runs the provider. Implementation of this method should block.
	// If you need to pass in manager, it is recommended to implement SetupWithManager(mgr mcmanager.Manager) error method on individual providers.
	// Even if a provider gets a manager through e.g. `SetupWithManager` the `Aware` passed to this method must be used to engage clusters.
	Start(context.Context, Aware) error
}

ProviderRunnable implements a `Start` method similar to manager.Runnable. The main difference to a normal Runnable is that a provider needs an Aware passed to engage clusters it discovers. Start is expected to block until completion.

Providers implementing this interface are automatically started by the multicluster manager when the manager starts. You should NOT manually call Start() on providers that implement this interface - the manager will handle this automatically.

Jump to

Keyboard shortcuts

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