multicluster

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MultiClusterSecretLabel = "istio/multiCluster"
)

Variables

View Source
var BuildClientsFromConfig = func(kubeConfig []byte) (kube.Client, error) {
	if len(kubeConfig) == 0 {
		return nil, errors.New("kubeconfig is empty")
	}

	rawConfig, err := clientcmd.Load(kubeConfig)
	if err != nil {
		return nil, fmt.Errorf("kubeconfig cannot be loaded: %v", err)
	}

	if err := clientcmd.Validate(*rawConfig); err != nil {
		return nil, fmt.Errorf("kubeconfig is not valid: %v", err)
	}
	if err := sanitizeKubeConfig(*rawConfig, features.InsecureKubeConfigOptions); err != nil {
		return nil, fmt.Errorf("kubeconfig is not allowed: %v", err)
	}

	clientConfig := clientcmd.NewDefaultClientConfig(*rawConfig, &clientcmd.ConfigOverrides{})

	clients, err := kube.NewClient(clientConfig)
	if err != nil {
		return nil, fmt.Errorf("failed to create kube clients: %v", err)
	}
	return clients, nil
}

BuildClientsFromConfig creates kube.Clients from the provided kubeconfig. This is overridden for testing only

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	// ID of the cluster.
	ID cluster.ID
	// SyncTimeout is marked after features.RemoteClusterTimeout.
	SyncTimeout *atomic.Bool
	// Client for accessing the cluster.
	Client kube.Client
	// contains filtered or unexported fields
}

Cluster defines cluster struct

func (*Cluster) HasSynced

func (r *Cluster) HasSynced() bool

func (*Cluster) Run

func (r *Cluster) Run()

Run starts the cluster's informers and waits for caches to sync. Once caches are synced, we mark the cluster synced. This should be called after each of the handlers have registered informers, and should be run in a goroutine.

func (*Cluster) Stop

func (r *Cluster) Stop() <-chan struct{}

Stop channel which is closed when the cluster is removed or the Controller that created the client is stopped. Client.RunAndWait is called using this channel.

func (*Cluster) SyncDidTimeout

func (r *Cluster) SyncDidTimeout() bool

type ClusterHandler

type ClusterHandler interface {
	ClusterAdded(cluster *Cluster, stop <-chan struct{}) error
	ClusterUpdated(cluster *Cluster, stop <-chan struct{}) error
	ClusterDeleted(clusterID cluster.ID) error
}

type ClusterStore

type ClusterStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ClusterStore is a collection of clusters

func (*ClusterStore) All

func (c *ClusterStore) All() map[string]map[cluster.ID]*Cluster

All returns a copy of the current remote clusters.

func (*ClusterStore) Contains

func (c *ClusterStore) Contains(clusterID cluster.ID) bool

func (*ClusterStore) Delete

func (c *ClusterStore) Delete(secretKey string, clusterID cluster.ID)

func (*ClusterStore) Get

func (c *ClusterStore) Get(secretKey string, clusterID cluster.ID) *Cluster

func (*ClusterStore) GetByID

func (c *ClusterStore) GetByID(clusterID cluster.ID) *Cluster

func (*ClusterStore) GetExistingClustersFor

func (c *ClusterStore) GetExistingClustersFor(secretKey string) []*Cluster

GetExistingClustersFor return existing clusters registered for the given secret

func (*ClusterStore) Len

func (c *ClusterStore) Len() int

func (*ClusterStore) Store

func (c *ClusterStore) Store(secretKey string, clusterID cluster.ID, value *Cluster)

type Controller

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

Controller is the controller implementation for Secret resources

func NewController

func NewController(kubeclientset kube.Client, namespace string, localClusterID cluster.ID) *Controller

NewController returns a new secret controller

func (*Controller) AddHandler

func (c *Controller) AddHandler(h ClusterHandler)

func (*Controller) GetRemoteKubeClient

func (c *Controller) GetRemoteKubeClient(clusterID cluster.ID) kubernetes.Interface

func (*Controller) HasSynced

func (c *Controller) HasSynced() bool

func (*Controller) ListRemoteClusters

func (c *Controller) ListRemoteClusters() []cluster.DebugInfo

ListRemoteClusters provides debug info about connected remote clusters.

func (*Controller) Run

func (c *Controller) Run(stopCh <-chan struct{}) error

Run starts the controller until it receives a message over stopCh

Jump to

Keyboard shortcuts

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