Documentation ¶
Index ¶
- Constants
- type Client
- func (cli *Client) AddEventHandler(obj client.Object, handler cache.ResourceEventHandler) error
- func (cli *Client) CreateObj(obj client.Object, opts ...client.CreateOption) error
- func (cli *Client) CreateObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.CreateOption) error
- func (cli *Client) DeleteObj(obj client.Object, opts ...client.DeleteOption) error
- func (cli *Client) DeleteObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.DeleteOption) error
- func (cli *Client) GetInformerWithObj(obj client.Object) (runtimecache.Informer, error)
- func (cli *Client) GetName() string
- func (cli *Client) GetObj(key types.NamespacedName, obj client.Object) error
- func (cli *Client) GetObjWithTimeout(timeout time.Duration, key types.NamespacedName, obj client.Object) error
- func (cli *Client) HasSynced() bool
- func (cli *Client) Start(ctx context.Context) error
- func (cli *Client) Stop()
- func (cli *Client) UpdateObj(obj client.Object, opts ...client.UpdateOption) error
- func (cli *Client) UpdateObjStatus(obj client.Object, opts ...client.UpdateOption) error
- func (cli *Client) UpdateObjStatusWithTimeout(timeout time.Duration, obj client.Object, ...) error
- func (cli *Client) UpdateObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.UpdateOption) error
- type ClusterConfigInfo
- type ClusterConfigurationManager
- type InitHandler
- type KubeConfigType
- type MultiClient
- func (mc *MultiClient) AddEventHandler(obj client.Object, handler cache.ResourceEventHandler) error
- func (mc *MultiClient) GetAll() []*Client
- func (mc *MultiClient) GetAllConnected() []*Client
- func (mc *MultiClient) GetAllReady() []*Client
- func (mc *MultiClient) GetConnectedWithName(name string) (*Client, error)
- func (mc *MultiClient) GetReadyWithName(name string) (*Client, error)
- func (mc *MultiClient) GetWithName(name string) (*Client, error)
- func (mc *MultiClient) HasSynced() bool
- func (mc *MultiClient) Rebuild() error
- func (mc *MultiClient) SetIndexField(obj client.Object, field string, extractValue client.IndexerFunc) error
- func (mc *MultiClient) Start(ctx context.Context) error
- func (mc *MultiClient) Stop()
- func (mc *MultiClient) TriggerSync(obj client.Object) error
- type Option
- func WithAutoHealthCheckInterval(interval time.Duration) Option
- func WithKubeConfig(kubeConfig string) Option
- func WithKubeConfigType(typ KubeConfigType) Option
- func WithKubeContext(kubeContext string) Option
- func WithKubeSetRsetConfigFn(setKubeRestConfigFnList ...SetKubeRestConfigFn) Option
- func WithRequestTimeout(timeout time.Duration) Option
- func WithRuntimeManagerOptions(ctrlRtManagerOpts manager.Options) Option
- type SetKubeRestConfigFn
Constants ¶
const ( Initing = iota Connected DisConnected )
Cluster status
const ( // GracefulStopWaitTimeout graceful stop cluster wait time GracefulStopWaitTimeout = time.Second * 30 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { KubeRestConfig *rest.Config KubeInterface kubernetes.Interface CtrlRtManager manager.Manager CtrlRtCache runtimecache.Cache // contains filtered or unexported fields }
Client wrap controller-runtime client
func (*Client) AddEventHandler ¶
AddEventHandler add event handler
func (*Client) CreateObjWithTimeout ¶
func (cli *Client) CreateObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.CreateOption) error
CreateObjWithTimeout create obj with timeout
func (*Client) DeleteObjWithTimeout ¶
func (cli *Client) DeleteObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.DeleteOption) error
DeleteObjWithTimeout delete obj with timeout
func (*Client) GetInformerWithObj ¶
GetInformerWithObj get object informer with cache
func (*Client) GetObjWithTimeout ¶
func (cli *Client) GetObjWithTimeout(timeout time.Duration, key types.NamespacedName, obj client.Object) error
GetObjWithTimeout get obj with timeout
func (*Client) UpdateObjStatus ¶
UpdateObjStatus update obj status with timeout requestTimeout
func (*Client) UpdateObjStatusWithTimeout ¶
func (cli *Client) UpdateObjStatusWithTimeout(timeout time.Duration, obj client.Object, opts ...client.SubResourceUpdateOption) error
UpdateObjStatusWithTimeout update status obj with timeout
func (*Client) UpdateObjWithTimeout ¶
func (cli *Client) UpdateObjWithTimeout(timeout time.Duration, obj client.Object, opts ...client.UpdateOption) error
UpdateObjWithTimeout update obj with timeout
type ClusterConfigInfo ¶
type ClusterConfigInfo interface { GetName() string GetKubeConfig() string GetKubeContext() string GetKubeConfigType() KubeConfigType }
ClusterConfigInfo cluster config info
func BuildClusterCfgInfo ¶
func BuildClusterCfgInfo(name, kubeConfig, kubeContext string, kubeConfigType KubeConfigType) ClusterConfigInfo
BuildClusterCfgInfo build cluster info
type ClusterConfigurationManager ¶
type ClusterConfigurationManager interface { GetAll() ([]ClusterConfigInfo, error) GetOptions() []Option }
ClusterConfigurationManager cluster configuration manager
func NewClusterCfgManagerWithCM ¶
func NewClusterCfgManagerWithCM(kubeInterface kubernetes.Interface, namespace string, label map[string]string, dataname string, options ...Option) ClusterConfigurationManager
NewClusterCfgManagerWithCM build clusterconfigmap
func NewClusterCfgManagerWithDir ¶
func NewClusterCfgManagerWithDir(dir, suffix string, kubeConfigType KubeConfigType, options ...Option) (ClusterConfigurationManager, error)
NewClusterCfgManagerWithDir build clusterconfigdir
type KubeConfigType ¶
type KubeConfigType string
const ( KubeConfigTypeRawString KubeConfigType = "RawString" KubeConfigTypeFile KubeConfigType = "File" )
Kubeconfig type
type MultiClient ¶
type MultiClient struct { InitHandlerList []InitHandler // contains filtered or unexported fields }
MultiClient multi cluster client obj
func NewMultiClient ¶
func NewMultiClient(rebuildInterval time.Duration, clusterCfgMgr ClusterConfigurationManager) (*MultiClient, error)
NewMultiClient build MultiClient
func (*MultiClient) AddEventHandler ¶
func (mc *MultiClient) AddEventHandler(obj client.Object, handler cache.ResourceEventHandler) error
AddEventHandler add event with multiclient
func (*MultiClient) GetAllConnected ¶
func (mc *MultiClient) GetAllConnected() []*Client
GetAllConnected get all cluster when cluster is connected.
func (*MultiClient) GetAllReady ¶
func (mc *MultiClient) GetAllReady() []*Client
GetAllReady get all cluster when cluster is connected and informer has synced
func (*MultiClient) GetConnectedWithName ¶
func (mc *MultiClient) GetConnectedWithName(name string) (*Client, error)
GetConnectedWithName get cluster with name and cluster is healthy.
func (*MultiClient) GetReadyWithName ¶
func (mc *MultiClient) GetReadyWithName(name string) (*Client, error)
GetReadyWithName get cluster with name and cluster is healthy and status ready.
func (*MultiClient) GetWithName ¶
func (mc *MultiClient) GetWithName(name string) (*Client, error)
GetWithName get cluster with name.
func (*MultiClient) HasSynced ¶
func (mc *MultiClient) HasSynced() bool
HasSynced return all cluster has synced
func (*MultiClient) Rebuild ¶
func (mc *MultiClient) Rebuild() error
Rebuild rebuild with cluster info
func (*MultiClient) SetIndexField ¶
func (mc *MultiClient) SetIndexField(obj client.Object, field string, extractValue client.IndexerFunc) error
SetIndexField set informer indexfield
func (*MultiClient) Start ¶
func (mc *MultiClient) Start(ctx context.Context) error
Start start multiclient
func (*MultiClient) TriggerSync ¶
func (mc *MultiClient) TriggerSync(obj client.Object) error
TriggerSync only trigger informer sync obj
type Option ¶
type Option func(*option)
func WithKubeConfig ¶
func WithKubeConfigType ¶
func WithKubeConfigType(typ KubeConfigType) Option
func WithKubeContext ¶
func WithKubeSetRsetConfigFn ¶
func WithKubeSetRsetConfigFn(setKubeRestConfigFnList ...SetKubeRestConfigFn) Option
func WithRequestTimeout ¶
type SetKubeRestConfigFn ¶
SetKubeRestConfigFn set kubernetes restconfig info