client

package
v0.0.0-...-686ee7d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveLease

func RemoveLease(kubeCl *KubernetesClient, config *LeaseLockConfig, confirm func(lease *coordinationv1.Lease) error) error

Types

type CRDInformer

type CRDInformer struct {
	KubeClient *KubernetesClient

	SharedInformer cache.SharedInformer

	ListOptions metav1.ListOptions

	EventCb func(obj *apiextensionsv1beta1.CustomResourceDefinition, event string)
	// contains filtered or unexported fields
}

func NewCRDInformer

func NewCRDInformer(parentCtx context.Context, client *KubernetesClient) *CRDInformer

func (*CRDInformer) CreateSharedInformer

func (p *CRDInformer) CreateSharedInformer() (err error)

func (*CRDInformer) HandleWatchEvent

func (p *CRDInformer) HandleWatchEvent(object interface{}, eventType string)

func (*CRDInformer) OnAdd

func (p *CRDInformer) OnAdd(obj interface{}, _ bool)

func (*CRDInformer) OnDelete

func (p *CRDInformer) OnDelete(obj interface{})

func (*CRDInformer) OnUpdate

func (p *CRDInformer) OnUpdate(oldObj, newObj interface{})

func (*CRDInformer) Run

func (p *CRDInformer) Run()

func (*CRDInformer) Stop

func (p *CRDInformer) Stop()

func (*CRDInformer) WithKubeEventCb

func (p *CRDInformer) WithKubeEventCb(eventCb func(obj *apiextensionsv1beta1.CustomResourceDefinition, event string))

type DeploymentInformer

type DeploymentInformer struct {
	KubeClient *KubernetesClient

	// Filter by namespace
	Namespace string
	// Filter by object name
	Name string
	// filter labels
	LabelSelector *metav1.LabelSelector
	// filter by fields
	FieldSelector string

	SharedInformer cache.SharedInformer

	ListOptions metav1.ListOptions

	EventCb func(obj *appsv1.Deployment, event string)
	// contains filtered or unexported fields
}

func NewDeploymentInformer

func NewDeploymentInformer(parentCtx context.Context, client *KubernetesClient) *DeploymentInformer

func (*DeploymentInformer) CreateSharedInformer

func (p *DeploymentInformer) CreateSharedInformer() (err error)

func (*DeploymentInformer) HandleWatchEvent

func (p *DeploymentInformer) HandleWatchEvent(object interface{}, eventType string)

func (*DeploymentInformer) OnAdd

func (p *DeploymentInformer) OnAdd(obj interface{}, _ bool)

func (*DeploymentInformer) OnDelete

func (p *DeploymentInformer) OnDelete(obj interface{})

func (*DeploymentInformer) OnUpdate

func (p *DeploymentInformer) OnUpdate(oldObj, newObj interface{})

func (*DeploymentInformer) Run

func (p *DeploymentInformer) Run()

func (*DeploymentInformer) Stop

func (p *DeploymentInformer) Stop()

func (*DeploymentInformer) WithKubeEventCb

func (p *DeploymentInformer) WithKubeEventCb(eventCb func(obj *appsv1.Deployment, event string))

type KubeClient

type KubeClient interface {
	kubernetes.Interface
	Dynamic() dynamic.Interface
	APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
	APIResource(apiVersion, kind string) (*metav1.APIResource, error)
	GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
}

type KubernetesClient

type KubernetesClient struct {
	KubeClient
	SSHClient *ssh.Client
	KubeProxy *frontend.KubeProxy
}

KubernetesClient connects to kubernetes API server through ssh tunnel and kubectl proxy.

func NewFakeKubernetesClient

func NewFakeKubernetesClient() *KubernetesClient

func NewFakeKubernetesClientWithListGVR

func NewFakeKubernetesClientWithListGVR(gvr map[schema.GroupVersionResource]string) *KubernetesClient

func NewKubernetesClient

func NewKubernetesClient() *KubernetesClient

func (*KubernetesClient) Init

func (k *KubernetesClient) Init(params *KubernetesInitParams) error

Init initializes kubernetes client

func (*KubernetesClient) StartKubernetesProxy

func (k *KubernetesClient) StartKubernetesProxy() (port string, err error)

StartKubernetesProxy initializes kubectl-proxy on remote host and establishes ssh tunnel to it

func (*KubernetesClient) WithSSHClient

func (k *KubernetesClient) WithSSHClient(client *ssh.Client) *KubernetesClient

type KubernetesInitParams

type KubernetesInitParams struct {
	KubeConfig        string
	KubeConfigContext string

	KubeConfigInCluster bool
}

func AppKubernetesInitParams

func AppKubernetesInitParams() *KubernetesInitParams

type LeaseLock

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

func NewLeaseLock

func NewLeaseLock(kubeCl *KubernetesClient, config LeaseLockConfig) *LeaseLock

func (*LeaseLock) Lock

func (l *LeaseLock) Lock(force bool) error

func (*LeaseLock) StopAutoRenew

func (l *LeaseLock) StopAutoRenew()

func (*LeaseLock) Unlock

func (l *LeaseLock) Unlock()

type LeaseLockConfig

type LeaseLockConfig struct {
	Name      string
	Namespace string
	Identity  string

	LeaseDurationSeconds int32
	RenewEverySeconds    int64
	RetryWaitDuration    time.Duration

	OnRenewError func(err error)

	AdditionalUserInfo string
}

func (*LeaseLockConfig) RenewRetries

func (c *LeaseLockConfig) RenewRetries() int

RenewRetries returns a number of possible retries between renew seconds and lease lifetime seconds.

type LockUserInfo

type LockUserInfo struct {
	Name       string `json:"name,omitempty"`
	Host       string `json:"host,omitempty"`
	Additional string `json:"additional,omitempty"`
}

func LockInfo

func LockInfo(lease *coordinationv1.Lease) (string, *LockUserInfo)

func NewLockUserInfo

func NewLockUserInfo(additional string) *LockUserInfo

type StateCache

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

func NewK8sStateCache

func NewK8sStateCache(client *KubernetesClient, namespace, secretName, tmpDir string) *StateCache

func (*StateCache) Clean

func (c *StateCache) Clean()

func (*StateCache) CleanWithExceptions

func (c *StateCache) CleanWithExceptions(excludeKeys ...string)

func (*StateCache) Delete

func (c *StateCache) Delete(name string)

func (*StateCache) GetPath

func (c *StateCache) GetPath(name string) string

func (*StateCache) InCache

func (c *StateCache) InCache(name string) (bool, error)

func (*StateCache) Init

func (c *StateCache) Init() error

func (*StateCache) Iterate

func (c *StateCache) Iterate(action func(string, []byte) error) error

func (*StateCache) Load

func (c *StateCache) Load(name string) ([]byte, error)

func (*StateCache) LoadStruct

func (c *StateCache) LoadStruct(name string, v interface{}) error

func (*StateCache) NeedIntermediateSave

func (c *StateCache) NeedIntermediateSave() bool

func (*StateCache) Save

func (c *StateCache) Save(name string, content []byte) error

func (*StateCache) SaveStruct

func (c *StateCache) SaveStruct(name string, v interface{}) error

func (*StateCache) WithLabels

func (c *StateCache) WithLabels(labels map[string]string) *StateCache

Jump to

Keyboard shortcuts

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