manager

package
v0.0.0-...-7a5359b Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyKubeconfig = "kubeconfig.yaml"
	KeyStauts     = "status"
	ClustersAll   = "all"
)

key config

Variables

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

Functions

This section is empty.

Types

type BaseCluster

type BaseCluster interface {
	GetOriginKubeCli(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) ([]*appv1.Deployment, error)
	GetStatefulsets(opts *client.ListOptions, clusternames ...string) ([]*appv1.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
}

BaseCluster is used to shield the complexity of the underlying multi-cluster and single cluster.

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

	Status ClusterStatusType
	// Started is true if the Informers has been Started
	Started bool
	// contains filtered or unexported fields
}

Cluster ...

func NewCluster

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

NewCluster ...

func (*Cluster) GetName

func (c *Cluster) GetName() string

GetName ...

func (*Cluster) StartCache

func (c *Cluster) StartCache(stopCh <-chan struct{})

StartCache ...

func (*Cluster) Stop

func (c *Cluster) Stop()

Stop ...

type ClusterManager

type ClusterManager struct {
	MasterClient

	Opt *ClusterManagerOption

	PreInit        func()
	Started        bool
	ClusterAddInfo chan map[string]string
	// contains filtered or unexported fields
}

ClusterManager ...

func NewClusterManager

func NewClusterManager(cli MasterClient, opt *ClusterManagerOption) (*ClusterManager, error)

NewClusterManager ...

func (*ClusterManager) Add

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

Add ...

func (*ClusterManager) AddPreInit

func (m *ClusterManager) AddPreInit(preInit func())

AddPreInit ...

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) ([]*appv1.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) GetNodes

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

GetNodes ...

func (*ClusterManager) GetOriginKubeCli

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

GetOriginKubeCli returns the kubecli of the master cluster client if len(clusterNames) == 0, otherwise returns the specific kubecli.

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) 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) ([]*appv1.StatefulSet, error)

GetStatefulsets ...

func (*ClusterManager) Start

func (m *ClusterManager) Start(stopCh <-chan struct{}) error

Start timer check cluster health

type ClusterManagerOption

type ClusterManagerOption struct {
	Namespace     string
	LabelSelector map[string]string
}

ClusterManagerOption ...

func DefaultClusterManagerOption

func DefaultClusterManagerOption(namespace string, ls map[string]string) *ClusterManagerOption

DefaultClusterManagerOption ...

type ClusterStatusType

type ClusterStatusType string

ClusterStatusType ...

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 CustomeCluster

type CustomeCluster interface {
	BaseCluster
	GetHelmRelease(opts map[string]string, clusterNames ...string) ([]*rlsv2.Release, error)
}

CustomeCluster extend the methods of the basic cluster, including some special business methods.

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