remote

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 42 Imported by: 116

Documentation

Overview

Package remote implements remote controllers.

Index

Constants

This section is empty.

Variables

View Source
var ErrClusterLocked = errors.New("cluster is locked already")

ErrClusterLocked is returned in methods that require cluster-level locking if the cluster is already locked by another concurrent call.

View Source
var NodeProviderIDIndex = Index{
	Object:       &corev1.Node{},
	Field:        index.NodeProviderIDField,
	ExtractValue: index.NodeByProviderID,
}

NodeProviderIDIndex is used to index Nodes by ProviderID.

Functions

func DefaultClusterAPIUserAgent added in v0.4.0

func DefaultClusterAPIUserAgent(sourceName string) string

DefaultClusterAPIUserAgent returns a User-Agent string built from static global vars.

func NewClusterClient

func NewClusterClient(ctx context.Context, sourceName string, c client.Client, cluster client.ObjectKey) (client.Client, error)

NewClusterClient returns a Client for interacting with a remote Cluster using the given scheme for encoding and decoding objects.

func RESTConfig added in v0.3.0

func RESTConfig(ctx context.Context, sourceName string, c client.Reader, cluster client.ObjectKey) (*restclient.Config, error)

RESTConfig returns a configuration instance to be used with a Kubernetes client.

Types

type ClusterCacheReconciler added in v0.3.6

type ClusterCacheReconciler struct {
	Client  client.Client
	Tracker *ClusterCacheTracker

	// WatchFilterValue is the label value used to filter events prior to reconciliation.
	WatchFilterValue string
}

ClusterCacheReconciler is responsible for stopping remote cluster caches when the cluster for the remote cache is being deleted.

func (*ClusterCacheReconciler) Reconcile added in v0.3.6

Reconcile reconciles Clusters and removes ClusterCaches for any Cluster that cannot be retrieved from the management cluster.

func (*ClusterCacheReconciler) SetupWithManager added in v0.3.7

func (r *ClusterCacheReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error

type ClusterCacheTracker added in v0.3.6

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

ClusterCacheTracker manages client caches for workload clusters.

func NewClusterCacheTracker added in v0.3.6

func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOptions) (*ClusterCacheTracker, error)

NewClusterCacheTracker creates a new ClusterCacheTracker.

func NewTestClusterCacheTracker added in v0.3.11

func NewTestClusterCacheTracker(log logr.Logger, cl client.Client, remoteClient client.Client, scheme *runtime.Scheme, objKey client.ObjectKey, watchObjects ...string) *ClusterCacheTracker

NewTestClusterCacheTracker creates a new fake ClusterCacheTracker that can be used by unit tests with fake client.

func (*ClusterCacheTracker) GetClient added in v0.3.7

func (t *ClusterCacheTracker) GetClient(ctx context.Context, cluster client.ObjectKey) (client.Client, error)

GetClient returns a cached client for the given cluster.

func (*ClusterCacheTracker) GetEtcdClientCertificateKey added in v1.3.8

func (t *ClusterCacheTracker) GetEtcdClientCertificateKey(ctx context.Context, cluster client.ObjectKey) (*rsa.PrivateKey, error)

GetEtcdClientCertificateKey returns a cached certificate key to be used for generating certificates for accessing etcd in the given cluster.

func (*ClusterCacheTracker) GetRESTConfig added in v1.1.6

func (t *ClusterCacheTracker) GetRESTConfig(ctc context.Context, cluster client.ObjectKey) (*rest.Config, error)

GetRESTConfig returns a cached REST config for the given cluster.

func (*ClusterCacheTracker) GetReader added in v1.6.4

func (t *ClusterCacheTracker) GetReader(ctx context.Context, cluster client.ObjectKey) (client.Reader, error)

GetReader returns a cached read-only client for the given cluster.

func (*ClusterCacheTracker) Watch added in v0.3.6

func (t *ClusterCacheTracker) Watch(ctx context.Context, input WatchInput) error

Watch watches a remote cluster for resource events. If the watch already exists based on input.Name, this is a no-op.

type ClusterCacheTrackerOptions added in v0.4.0

type ClusterCacheTrackerOptions struct {
	// SecretCachingClient is a client which caches secrets.
	// If set it will be used to read the kubeconfig secret.
	// Otherwise the default client from the manager will be used.
	SecretCachingClient client.Client

	// Log is the logger used throughout the lifecycle of caches.
	// Defaults to a no-op logger if it's not set.
	Log *logr.Logger

	// ClientUncachedObjects instructs the Client to never cache the following objects,
	// it'll instead query the API server directly.
	// Defaults to never caching ConfigMap and Secret if not set.
	ClientUncachedObjects []client.Object
	Indexes               []Index

	// ControllerName is the name of the controller.
	// This is used to calculate the user agent string.
	// If not set, it defaults to "cluster-cache-tracker".
	ControllerName string
}

ClusterCacheTrackerOptions defines options to configure a ClusterCacheTracker.

type ClusterClientGetter added in v0.3.0

type ClusterClientGetter func(ctx context.Context, sourceName string, c client.Client, cluster client.ObjectKey) (client.Client, error)

ClusterClientGetter returns a new remote client.

type Index added in v0.4.1

type Index struct {
	Object       client.Object
	Field        string
	ExtractValue client.IndexerFunc
}

Index is a helper to model the info passed to cache.IndexField.

type WatchInput added in v0.3.6

type WatchInput struct {
	// Name represents a unique watch request for the specified Cluster.
	Name string

	// Cluster is the key for the remote cluster.
	Cluster client.ObjectKey

	// Watcher is the watcher (controller) whose Reconcile() function will be called for events.
	Watcher Watcher

	// Kind is the type of resource to watch.
	Kind client.Object

	// EventHandler contains the event handlers to invoke for resource events.
	EventHandler handler.EventHandler

	// Predicates is used to filter resource events.
	Predicates []predicate.Predicate
}

WatchInput specifies the parameters used to establish a new watch for a remote cluster.

type Watcher added in v0.3.6

type Watcher interface {
	// Watch watches src for changes, sending events to eventHandler if they pass predicates.
	Watch(src source.Source, eventHandler handler.EventHandler, predicates ...predicate.Predicate) error
}

Watcher is a scoped-down interface from Controller that only knows how to watch.

Directories

Path Synopsis
Package fake implements testing fakes.
Package fake implements testing fakes.

Jump to

Keyboard shortcuts

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