multicluster

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LocalCluster clusterType = iota
	PivotCluster
	MemberCluster
	AllCluster
)

Variables

View Source
var ManagerImpl = newMultiClusterMgr()

ManagerImpl instance implement interface, init local cluster at first.

Functions

func AddInternalCluster added in v1.2.0

func AddInternalCluster(cluster clusterv1.Cluster) error

AddInternalCluster build internal cluster of cluster and add it to multi cluster manager without scout.

func AddInternalClusterWithScout added in v1.2.0

func AddInternalClusterWithScout(cluster clusterv1.Cluster) error

AddInternalClusterWithScout build internal cluster of cluster and add it to multi cluster manager with scout by default opts.

func AddInternalClusterWithScoutOpts added in v1.7.9

func AddInternalClusterWithScoutOpts(cluster clusterv1.Cluster, scoutInitialDelaySeconds, scoutWaitTimeoutSeconds int) error

AddInternalClusterWithScoutOpts build internal cluster of cluster and add it to multi cluster manager with scout opts.

func ClusterWideKeyFunc added in v1.2.0

func ClusterWideKeyFunc(obj interface{}) (worker.QueueKey, error)

ClusterWideKeyFunc generates a ClusterWideKey for object.

func InitFakeMultiClusterMgrWithOpts added in v1.2.0

func InitFakeMultiClusterMgrWithOpts(opts *fake.Options)

InitFakeMultiClusterMgrWithOpts must be called at first in testing

func NewDefaultMultiVersionConverter added in v1.2.0

func NewDefaultMultiVersionConverter(m Manager) conversion.MultiVersionConverter

Types

type DefaultMultiVersionConverter added in v1.2.0

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

func (*DefaultMultiVersionConverter) GetVersionConvert added in v1.2.0

func (m *DefaultMultiVersionConverter) GetVersionConvert(cluster string) (*conversion.VersionConverter, error)

type FakerManagerImpl added in v1.2.0

type FakerManagerImpl struct {
	sync.RWMutex
	Clusters map[string]*InternalCluster
}

FakerManagerImpl implements Manager

func (*FakerManagerImpl) Add added in v1.2.0

func (m *FakerManagerImpl) Add(cluster string, c *InternalCluster) error

func (*FakerManagerImpl) Del added in v1.2.0

func (m *FakerManagerImpl) Del(cluster string) error

func (*FakerManagerImpl) FuzzyCopy added in v1.2.0

func (m *FakerManagerImpl) FuzzyCopy() map[string]*FuzzyCluster

func (*FakerManagerImpl) Get added in v1.2.0

func (m *FakerManagerImpl) Get(cluster string) (*InternalCluster, error)

func (*FakerManagerImpl) GetClient added in v1.2.0

func (m *FakerManagerImpl) GetClient(cluster string) (client.Client, error)

func (*FakerManagerImpl) GetTransport added in v1.6.0

func (m *FakerManagerImpl) GetTransport(cluster string) (http.RoundTripper, error)

func (*FakerManagerImpl) ListClustersByType added in v1.2.0

func (m *FakerManagerImpl) ListClustersByType(t clusterType) []*InternalCluster

func (*FakerManagerImpl) ListClustersNameByType added in v1.2.1

func (m *FakerManagerImpl) ListClustersNameByType(t clusterType) []string

func (*FakerManagerImpl) ScoutFor added in v1.2.0

func (m *FakerManagerImpl) ScoutFor(ctx context.Context, cluster string) error

ScoutFor do nothing in testing

func (*FakerManagerImpl) Version added in v1.2.0

func (m *FakerManagerImpl) Version(cluster string) (*version.Info, error)

type FuzzyCluster added in v1.2.0

type FuzzyCluster struct {
	Name       string
	Config     *rest.Config
	Client     client.Client
	RawCluster *clusterv1.Cluster
}

FuzzyCluster be exported for test

type InternalCluster added in v1.2.0

type InternalCluster struct {
	// Name the cluster name
	Name string

	// Type of cluster
	Type clusterType

	// Client holds all the clients needed
	Client client.Client

	// Scout knows the health status of cluster and keep watch
	Scout *scout.Scout

	// Config bind to a real cluster
	Config *rest.Config

	// Version the k8s Version about internal cluster
	Version *version.Info

	// RawCluster holds raw cluster
	RawCluster *clusterv1.Cluster

	// StopCh for closing channel when delete cluster, goroutine
	// of cache and scout will exit gracefully.
	StopCh chan struct{}
	// contains filtered or unexported fields
}

InternalCluster represent a cluster runtime contains client and internal warden.

func NewInternalCluster added in v1.2.0

func NewInternalCluster(cluster clusterv1.Cluster) (*InternalCluster, error)

type Manager added in v1.2.0

type Manager interface {
	// Add runtime cache in memory
	Add(cluster string, internalCluster *InternalCluster) error
	Get(cluster string) (*InternalCluster, error)
	Del(cluster string) error

	// Version the k8s version about cluster
	Version(cluster string) (*version.Info, error)

	// FuzzyCopy return fuzzy cluster of raw
	FuzzyCopy() map[string]*FuzzyCluster

	// ScoutFor scout heartbeat for warden
	ScoutFor(ctx context.Context, cluster string) error

	// GetClient get client for cluster by name
	GetClient(cluster string) (client.Client, error)

	GetTransport(cluster string) (http.RoundTripper, error)

	// ListClustersByType list clusters by given type
	ListClustersByType(t clusterType) []*InternalCluster

	// ListClustersNameByType list cluster names by given type
	ListClustersNameByType(t clusterType) []string
}

Manager access to internal cluster

func Interface

func Interface() Manager

Interface the way to be used outside for multi cluster manager

type MultiClustersMgr added in v1.2.0

type MultiClustersMgr struct {
	sync.RWMutex
	Clusters map[string]*InternalCluster
}

MultiClustersMgr a memory cache for runtime cluster.

func (*MultiClustersMgr) Add added in v1.2.0

func (m *MultiClustersMgr) Add(cluster string, c *InternalCluster) error

func (*MultiClustersMgr) Del added in v1.2.0

func (m *MultiClustersMgr) Del(cluster string) error

func (*MultiClustersMgr) FuzzyCopy added in v1.2.0

func (m *MultiClustersMgr) FuzzyCopy() map[string]*FuzzyCluster

FuzzyCopy copy all internal clusters when runtime except local cluster

func (*MultiClustersMgr) Get added in v1.2.0

func (m *MultiClustersMgr) Get(cluster string) (*InternalCluster, error)

func (*MultiClustersMgr) GetClient added in v1.2.0

func (m *MultiClustersMgr) GetClient(cluster string) (client.Client, error)

func (*MultiClustersMgr) GetTransport added in v1.6.0

func (m *MultiClustersMgr) GetTransport(cluster string) (http.RoundTripper, error)

func (*MultiClustersMgr) ListClustersByType added in v1.2.0

func (m *MultiClustersMgr) ListClustersByType(t clusterType) []*InternalCluster

ListClustersByType get clusters by given type return nil if found no clusters with type.

func (*MultiClustersMgr) ListClustersNameByType added in v1.2.1

func (m *MultiClustersMgr) ListClustersNameByType(t clusterType) []string

ListClustersNameByType get cluster names by given type return nil if found no clusters with type.

func (*MultiClustersMgr) ScoutFor added in v1.2.0

func (m *MultiClustersMgr) ScoutFor(ctx context.Context, cluster string) error

ScoutFor starts watch for warden intelligence

func (*MultiClustersMgr) Version added in v1.2.0

func (m *MultiClustersMgr) Version(cluster string) (*version.Info, error)

type SyncMgr added in v1.2.0

type SyncMgr struct {
	Informer cache.Informer
	Worker   worker.Interface

	// ScoutWaitTimeoutSeconds that heartbeat not receive timeout
	ScoutWaitTimeoutSeconds int
	// ScoutInitialDelaySeconds the time that wait for warden start
	ScoutInitialDelaySeconds int
	// contains filtered or unexported fields
}

SyncMgr only running when process as subsidiary

func NewSyncMgr added in v1.2.0

func NewSyncMgr(config *rest.Config, isWithScout bool, scoutInitialDelaySeconds, scoutWaitTimeoutSeconds int) (*SyncMgr, error)

func NewSyncMgrWithDefaultSetting added in v1.3.0

func NewSyncMgrWithDefaultSetting(config *rest.Config, isWithScout bool) (*SyncMgr, error)

func NewSyncMgrWithScoutSetting added in v1.7.9

func NewSyncMgrWithScoutSetting(config *rest.Config, scoutInitialDelaySeconds, scoutWaitTimeoutSeconds int) (*SyncMgr, error)

func (*SyncMgr) OnClusterAdd added in v1.2.0

func (m *SyncMgr) OnClusterAdd(obj interface{})

func (*SyncMgr) OnClusterDelete added in v1.2.0

func (m *SyncMgr) OnClusterDelete(obj interface{})

func (*SyncMgr) OnClusterUpdate added in v1.2.0

func (m *SyncMgr) OnClusterUpdate(oldObj, newObj interface{})

func (*SyncMgr) ReconcileCluster added in v1.2.0

func (m *SyncMgr) ReconcileCluster(key worker.QueueKey) error

ReconcileCluster sync cluster during multi KubeCube instance

func (*SyncMgr) Start added in v1.2.0

func (m *SyncMgr) Start(ctx context.Context) error

Start keep sync cluster change by informer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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