clustermanager

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClustersAll = "all"
)

key config

Variables

View Source
var (
	SyncPeriodTime = 1 * time.Hour
)

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Name          string
	AliasName     string
	RawKubeconfig []byte
	Meta          map[string]string
	RestConfig    *rest.Config
	Client        client.Client
	KubeCli       kubernetes.Interface

	Log        logr.Logger
	Mgr        manager.Manager
	Cache      cache.Cache
	SyncPeriod time.Duration

	StopperCancel context.CancelFunc

	Status ClusterStatusType
	// Started is true if the Informers has been Started
	Started bool
}

func NewCluster

func NewCluster(name string, kubeconfig []byte, log logr.Logger) (*Cluster, error)

func (*Cluster) GetName

func (c *Cluster) GetName() string

func (*Cluster) StartCache

func (c *Cluster) StartCache(stopCtx context.Context)

func (*Cluster) Stop

func (c *Cluster) Stop()

type ClusterManager

type ClusterManager struct {
	MasterClient

	Started bool
	sync.RWMutex
	// contains filtered or unexported fields
}

ClusterManager ...

func NewManager

func NewManager(cli MasterClient) (*ClusterManager, error)

NewManager ...

func (*ClusterManager) Add

func (m *ClusterManager) Add(cluster *Cluster) error

Add ...

func (*ClusterManager) AddNewClusters

func (m *ClusterManager) AddNewClusters(name string, kubeconfig string) (*Cluster, error)

func (*ClusterManager) Delete

func (m *ClusterManager) Delete(name string) error

Delete ...

func (*ClusterManager) DeletePod

func (m *ClusterManager) DeletePod(opts types.NamespacedName, clusterNames ...string) error

DeletePod ...

func (*ClusterManager) DeletePods

func (m *ClusterManager) DeletePods(opts *client.ListOptions, clusterNames ...string) error

DeletePods ...

func (*ClusterManager) Get

func (m *ClusterManager) Get(name string) (*Cluster, error)

Get ...

func (*ClusterManager) GetAll

func (m *ClusterManager) GetAll(name ...string) []*Cluster

GetAll get all cluster

func (*ClusterManager) GetClusterIndex

func (m *ClusterManager) GetClusterIndex(name string) (int, bool)

GetClusterIndex ...

func (*ClusterManager) GetDeployment

func (m *ClusterManager) GetDeployment(opts *client.ListOptions, clusterNames ...string) ([]*appsv1.Deployment, error)

GetDeployment ...

func (*ClusterManager) GetEndpoints

func (m *ClusterManager) GetEndpoints(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Endpoints, error)

GetEndpoints ...

func (*ClusterManager) GetEvent

func (m *ClusterManager) GetEvent(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Event, error)

GetEvent ...

func (*ClusterManager) GetHelmRelease

func (m *ClusterManager) GetHelmRelease(opts map[string]string, clusterNames ...string) ([]*helmv3.Release, error)

GetHelmRelease ...

func (*ClusterManager) GetNodes

func (m *ClusterManager) GetNodes(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Node, error)

GetNodes ...

func (*ClusterManager) GetPod

func (m *ClusterManager) GetPod(opts types.NamespacedName, clusterNames ...string) (*corev1.Pod, error)

GetPod ...

func (*ClusterManager) GetPods

func (m *ClusterManager) GetPods(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Pod, error)

GetPods ...

func (*ClusterManager) GetRawCli

func (m *ClusterManager) GetRawCli(clusterNames ...string) (kubernetes.Interface, error)

GetRawCli return the client of the master cluster as default if len(clusterNames) == 0, otherwise it will return a client with the special name.

func (*ClusterManager) GetService

func (m *ClusterManager) GetService(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Service, error)

GetService ...

func (*ClusterManager) GetStatefulsets

func (m *ClusterManager) GetStatefulsets(opts *client.ListOptions, clusterNames ...string) ([]*appsv1.StatefulSet, error)

GetStatefulsets ...

func (*ClusterManager) Start

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

Start timer check cluster health

func (*ClusterManager) Stop

func (m *ClusterManager) Stop()

type ClusterStatusType

type ClusterStatusType string
const (
	// ClusterReady means the cluster is ready to accept workloads.
	ClusterReady ClusterStatusType = "Ready"
	// ClusterOffline means the cluster is temporarily down or not reachable
	ClusterOffline  ClusterStatusType = "Offline"
	ClusterMaintain ClusterStatusType = "Maintaining"
)

These are valid status of a cluster.

type CustomInterface

type CustomInterface interface {
	Interface
	GetHelmRelease(opts map[string]string, clusterNames ...string) ([]*helmv3.Release, error)
}

CustomInterface as the extension of the basic cluster, it includes the extra methods for handling your own business.

type Interface

type Interface interface {
	GetRawCli(clusterNames ...string) (kubernetes.Interface, error)
	GetPod(opts types.NamespacedName, clusterNames ...string) (*corev1.Pod, error)
	GetPods(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Pod, error)
	GetNodes(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Node, error)
	GetDeployment(opts *client.ListOptions, clusterNames ...string) ([]*appsv1.Deployment, error)
	GetStatefulsets(opts *client.ListOptions, clusternames ...string) ([]*appsv1.StatefulSet, error)
	GetService(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Service, error)
	GetEndpoints(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Endpoints, error)
	GetEvent(opts *client.ListOptions, clusterNames ...string) ([]*corev1.Event, error)
	DeletePods(opts *client.ListOptions, clusterNames ...string) error
	DeletePod(opts types.NamespacedName, clusterNames ...string) error
}

Interface is used to shield the complexity of the underlying multi-cluster or single cluster.

type MasterClient

type MasterClient struct {
	KubeCli kubernetes.Interface
	manager.Manager
}

MasterClient ...

Jump to

Keyboard shortcuts

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