k8sclient

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EpClient

type EpClient interface {
	// Get the mapping between pod key and the corresponding service names
	PodKeyToServiceNames() map[string][]string
	// Get the mapping between the service and the number of belonging pods
	ServiceToPodNum() map[Service]int
}

type JobClient

type JobClient interface {
	// get the mapping between job and cronjob
	JobToCronJob() map[string]string
}

type K8sClient

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

func Get

func Get(logger *zap.Logger, options ...Option) *K8sClient

Get returns a singleton instance of k8s client If the intialization fails, it returns nil

func (*K8sClient) GetClientSet added in v0.30.0

func (c *K8sClient) GetClientSet() kubernetes.Interface

func (*K8sClient) GetEpClient added in v0.30.0

func (c *K8sClient) GetEpClient() EpClient

func (*K8sClient) GetJobClient added in v0.30.0

func (c *K8sClient) GetJobClient() JobClient

func (*K8sClient) GetNodeClient added in v0.30.0

func (c *K8sClient) GetNodeClient() NodeClient

func (*K8sClient) GetPodClient added in v0.30.0

func (c *K8sClient) GetPodClient() PodClient

func (*K8sClient) GetReplicaSetClient added in v0.30.0

func (c *K8sClient) GetReplicaSetClient() ReplicaSetClient

func (*K8sClient) Shutdown

func (c *K8sClient) Shutdown()

Shutdown stops K8sClient

func (*K8sClient) ShutdownEpClient added in v0.30.0

func (c *K8sClient) ShutdownEpClient()

func (*K8sClient) ShutdownJobClient added in v0.30.0

func (c *K8sClient) ShutdownJobClient()

func (*K8sClient) ShutdownNodeClient added in v0.30.0

func (c *K8sClient) ShutdownNodeClient()

func (*K8sClient) ShutdownPodClient added in v0.30.0

func (c *K8sClient) ShutdownPodClient()

func (*K8sClient) ShutdownReplicaSetClient added in v0.30.0

func (c *K8sClient) ShutdownReplicaSetClient()

type NodeClient

type NodeClient interface {
	// Get the number of failed nodes for current cluster
	ClusterFailedNodeCount() int
	// Get the number of nodes for current cluster
	ClusterNodeCount() int
}

type ObjStore

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

ObjStore implements the cache.Store interface: https://github.com/kubernetes/client-go/blob/release-1.20/tools/cache/store.go#L26-L71 It is used by cache.Reflector to keep the updated information about resources https://github.com/kubernetes/client-go/blob/release-1.20/tools/cache/reflector.go#L48

func NewObjStore

func NewObjStore(transformFunc func(any) (any, error), logger *zap.Logger) *ObjStore

func (*ObjStore) Add

func (s *ObjStore) Add(obj any) error

Add implements the Add method of the store interface. Add adds an entry to the ObjStore.

func (*ObjStore) Delete

func (s *ObjStore) Delete(obj any) error

Delete implements the Delete method of the store interface. Delete deletes an existing entry in the ObjStore.

func (*ObjStore) Get

func (s *ObjStore) Get(_ any) (item any, exists bool, err error)

Get implements the Get method of the store interface.

func (*ObjStore) GetByKey

func (s *ObjStore) GetByKey(_ string) (item any, exists bool, err error)

GetByKey implements the GetByKey method of the store interface.

func (*ObjStore) GetResetRefreshStatus

func (s *ObjStore) GetResetRefreshStatus() bool

GetResetRefreshStatus tracks whether the underlying data store is refreshed or not. Calling this func itself will reset the state to false.

func (*ObjStore) List

func (s *ObjStore) List() []any

List implements the List method of the store interface. List lists all the objects in the ObjStore

func (*ObjStore) ListKeys

func (s *ObjStore) ListKeys() []string

ListKeys implements the ListKeys method of the store interface. ListKeys lists the keys for all objects in the ObjStore

func (*ObjStore) Replace

func (s *ObjStore) Replace(list []any, _ string) error

Replace implements the Replace method of the store interface. Replace will delete the contents of the store, using instead the given list.

func (*ObjStore) Resync

func (s *ObjStore) Resync() error

Resync implements the Resync method of the store interface.

func (*ObjStore) Update

func (s *ObjStore) Update(obj any) error

Update implements the Update method of the store interface. Update updates the existing entry in the ObjStore.

type Option

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

Option is a struct that can be used to change the configuration of passed K8sClient It can be used as an option to the Get(...) function to create a customized K8sClient

func InitSyncPollInterval

func InitSyncPollInterval(pollInterval time.Duration) Option

InitSyncPollInterval provides the option to set the init sync poll interval for testing connection to kubernetes api server

func InitSyncPollTimeout

func InitSyncPollTimeout(pollTimeout time.Duration) Option

InitSyncPollTimeout provides the option to set the init sync poll timeout for testing connection to kubernetes api server

func KubeConfigPath

func KubeConfigPath(kubeConfigPath string) Option

KubeConfigPath provides the option to set the kube config which will be used if the service account that kubernetes gives to pods can't be used

type PodClient

type PodClient interface {
	// Get the mapping between the namespace and the number of belonging pods
	NamespaceToRunningPodNum() map[string]int
}

type ReplicaSetClient

type ReplicaSetClient interface {
	// Get the mapping between replica set and deployment
	ReplicaSetToDeployment() map[string]string
}

type Service

type Service struct {
	ServiceName string
	Namespace   string
}

func NewService

func NewService(name, namespace string) Service

Jump to

Keyboard shortcuts

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