cluster

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LastHeartBeatStatus = make(map[string]bool)

LastHeartBeatStatus record last heart beat status to avoid verbose log

Functions

func SetupHeartBeat

func SetupHeartBeat(name, namespace string, updater func(string, string))

SetupHeartBeat setup heartbeat watcher

func SetupPortForwardHeartBeat

func SetupPortForwardHeartBeat(port int) *time.Ticker

SetupPortForwardHeartBeat setup heartbeat watcher for port forward

func SetupTimeDifference added in v0.3.3

func SetupTimeDifference() error

SetupTimeDifference get time difference between cluster and local

Types

type Kubernetes

type Kubernetes struct {
	Clientset kubernetes.Interface
}

Kubernetes implements KubernetesInterface

func (*Kubernetes) AddEphemeralContainer

func (k *Kubernetes) AddEphemeralContainer(containerName string, name string,
	envs map[string]string) (string, error)

AddEphemeralContainer add ephemeral container to specified pod

func (*Kubernetes) ClusterCidr added in v0.3.6

func (k *Kubernetes) ClusterCidr(namespace string) ([]string, []string)

ClusterCidr get cluster CIDR

func (*Kubernetes) CreateRectifierPod added in v0.3.3

func (k *Kubernetes) CreateRectifierPod(name string) (*coreV1.Pod, error)

CreateRectifierPod create pod for rectify time difference

func (*Kubernetes) CreateRouterPod added in v0.3.2

func (k *Kubernetes) CreateRouterPod(name string, labels, annotations map[string]string, ports map[int]int) (*coreV1.Pod, error)

CreateRouterPod create router pod

func (*Kubernetes) CreateService

func (k *Kubernetes) CreateService(metaAndSpec *SvcMetaAndSpec) (*coreV1.Service, error)

CreateService create kubernetes service

func (*Kubernetes) DecreaseDeploymentRef added in v0.3.2

func (k *Kubernetes) DecreaseDeploymentRef(name string, namespace string) (cleanup bool, err error)

DecreaseDeploymentRef decrease deployment ref count by 1

func (*Kubernetes) DecreasePodRef added in v0.3.2

func (k *Kubernetes) DecreasePodRef(name string, namespace string) (bool, error)

DecreasePodRef decrease pod ref count by 1

func (*Kubernetes) ExecInPod

func (k *Kubernetes) ExecInPod(containerName, podName, namespace string, cmd ...string) (string, string, error)

func (*Kubernetes) GetAllDeploymentInNamespace

func (k *Kubernetes) GetAllDeploymentInNamespace(namespace string) (*appV1.DeploymentList, error)

GetAllDeploymentInNamespace get all deployment in specified namespace

func (*Kubernetes) GetAllIngressInNamespace added in v0.3.6

func (k *Kubernetes) GetAllIngressInNamespace(namespace string) (*extV1.IngressList, error)

GetAllIngressInNamespace get all ingresses in specified namespace

func (*Kubernetes) GetAllNamespaces

func (k *Kubernetes) GetAllNamespaces() (*coreV1.NamespaceList, error)

GetAllNamespaces get all namespaces

func (*Kubernetes) GetAllServiceInNamespace

func (k *Kubernetes) GetAllServiceInNamespace(namespace string) (*coreV1.ServiceList, error)

GetAllServiceInNamespace get all services in specified namespace

func (*Kubernetes) GetConfigMap

func (k *Kubernetes) GetConfigMap(name, namespace string) (*coreV1.ConfigMap, error)

GetConfigMap get configmap

func (*Kubernetes) GetConfigMapsByLabel

func (k *Kubernetes) GetConfigMapsByLabel(labels map[string]string, namespace string) (pods *coreV1.ConfigMapList, err error)

GetConfigMapsByLabel get deployments by label

func (*Kubernetes) GetDeployment

func (k *Kubernetes) GetDeployment(name string, namespace string) (*appV1.Deployment, error)

GetDeployment ...

func (*Kubernetes) GetDeploymentsByLabel

func (k *Kubernetes) GetDeploymentsByLabel(labels map[string]string, namespace string) (pods *appV1.DeploymentList, err error)

GetDeploymentsByLabel get deployments by label

func (*Kubernetes) GetKtResources

func (k *Kubernetes) GetKtResources(namespace string) ([]coreV1.Pod, []coreV1.ConfigMap, []appV1.Deployment, []coreV1.Service, error)

GetKtResources fetch all kt pods and deployments

func (*Kubernetes) GetOrCreateShadow

func (k *Kubernetes) GetOrCreateShadow(name string, labels, annotations, envs map[string]string, exposePorts string, portNameDict map[int]string) (
	string, string, string, error)

GetOrCreateShadow create shadow pod or deployment

func (*Kubernetes) GetPod

func (k *Kubernetes) GetPod(name string, namespace string) (*coreV1.Pod, error)

GetPod ...

func (*Kubernetes) GetPodsByLabel

func (k *Kubernetes) GetPodsByLabel(labels map[string]string, namespace string) (*coreV1.PodList, error)

GetPodsByLabel get pods by label

func (*Kubernetes) GetService

func (k *Kubernetes) GetService(name, namespace string) (*coreV1.Service, error)

GetService get service

func (*Kubernetes) GetServicesByLabel

func (k *Kubernetes) GetServicesByLabel(labels map[string]string, namespace string) (svcs *coreV1.ServiceList, err error)

GetServicesByLabel get services by label

func (*Kubernetes) GetServicesBySelector

func (k *Kubernetes) GetServicesBySelector(matchLabels map[string]string, namespace string) ([]coreV1.Service, error)

GetServicesBySelector get services by selector

func (*Kubernetes) IncreaseDeploymentRef added in v0.3.2

func (k *Kubernetes) IncreaseDeploymentRef(name string, namespace string) error

IncreaseDeploymentRef increase deployment ref count by 1

func (*Kubernetes) IncreasePodRef added in v0.3.2

func (k *Kubernetes) IncreasePodRef(name string, namespace string) error

IncreasePodRef increase pod ref count by 1

func (*Kubernetes) RemoveConfigMap

func (k *Kubernetes) RemoveConfigMap(name, namespace string) (err error)

RemoveConfigMap remove ConfigMap instance

func (*Kubernetes) RemoveDeployment added in v0.3.2

func (k *Kubernetes) RemoveDeployment(name, namespace string) (err error)

RemoveDeployment remove deployment instances

func (*Kubernetes) RemoveEphemeralContainer

func (k *Kubernetes) RemoveEphemeralContainer(_, podName string, namespace string) (err error)

RemoveEphemeralContainer remove ephemeral container from specified pod

func (*Kubernetes) RemovePod

func (k *Kubernetes) RemovePod(name, namespace string) (err error)

RemovePod remove pod instances

func (*Kubernetes) RemoveService

func (k *Kubernetes) RemoveService(name, namespace string) (err error)

RemoveService remove service

func (*Kubernetes) ScaleTo

func (k *Kubernetes) ScaleTo(name, namespace string, replicas *int32) (err error)

ScaleTo scale deployment to

func (*Kubernetes) UpdateConfigMapHeartBeat

func (k *Kubernetes) UpdateConfigMapHeartBeat(name, namespace string)

func (*Kubernetes) UpdateDeployment

func (k *Kubernetes) UpdateDeployment(deployment *appV1.Deployment) (*appV1.Deployment, error)

UpdateDeployment ...

func (*Kubernetes) UpdateDeploymentHeartBeat added in v0.3.2

func (k *Kubernetes) UpdateDeploymentHeartBeat(name, namespace string)

func (*Kubernetes) UpdatePod

func (k *Kubernetes) UpdatePod(pod *coreV1.Pod) (*coreV1.Pod, error)

UpdatePod ...

func (*Kubernetes) UpdatePodHeartBeat

func (k *Kubernetes) UpdatePodHeartBeat(name, namespace string)

func (*Kubernetes) UpdateService

func (k *Kubernetes) UpdateService(svc *coreV1.Service) (*coreV1.Service, error)

UpdateService ...

func (*Kubernetes) UpdateServiceHeartBeat

func (k *Kubernetes) UpdateServiceHeartBeat(name, namespace string)

func (*Kubernetes) WaitPodReady

func (k *Kubernetes) WaitPodReady(name, namespace string, timeoutSec int) (*coreV1.Pod, error)

WaitPodReady ...

func (*Kubernetes) WaitPodTerminate

func (k *Kubernetes) WaitPodTerminate(name, namespace string) (*coreV1.Pod, error)

WaitPodTerminate ...

func (*Kubernetes) WaitPodsReady added in v0.3.2

func (k *Kubernetes) WaitPodsReady(labels map[string]string, namespace string, timeoutSec int) ([]coreV1.Pod, error)

func (*Kubernetes) WatchPod

func (k *Kubernetes) WatchPod(name, namespace string, fAdd, fDel, fMod func(*coreV1.Pod))

WatchPod ...

func (*Kubernetes) WatchService

func (k *Kubernetes) WatchService(name, namespace string, fAdd, fDel, fMod func(*coreV1.Service))

WatchService ...

type KubernetesInterface

type KubernetesInterface interface {
	GetPod(name string, namespace string) (*coreV1.Pod, error)
	GetPodsByLabel(labels map[string]string, namespace string) (*coreV1.PodList, error)
	UpdatePod(pod *coreV1.Pod) (*coreV1.Pod, error)
	RemovePod(name, namespace string) error
	GetOrCreateShadow(name string, labels, annotations, envs map[string]string, portsToExpose string, portNameDict map[int]string) (string, string, string, error)
	CreateRouterPod(name string, labels, annotations map[string]string, ports map[int]int) (*coreV1.Pod, error)
	CreateRectifierPod(name string) (*coreV1.Pod, error)
	UpdatePodHeartBeat(name, namespace string)
	WaitPodReady(name, namespace string, timeoutSec int) (*coreV1.Pod, error)
	WaitPodTerminate(name, namespace string) (*coreV1.Pod, error)
	WatchPod(name, namespace string, fAdd, fDel, fMod func(*coreV1.Pod))
	ExecInPod(containerName, podName, namespace string, cmd ...string) (string, string, error)
	AddEphemeralContainer(containerName, podName string, envs map[string]string) (string, error)
	RemoveEphemeralContainer(containerName, podName string, namespace string) error
	IncreasePodRef(name, namespace string) error
	DecreasePodRef(name, namespace string) (bool, error)

	GetDeployment(name string, namespace string) (*appV1.Deployment, error)
	GetDeploymentsByLabel(labels map[string]string, namespace string) (*appV1.DeploymentList, error)
	GetAllDeploymentInNamespace(namespace string) (*appV1.DeploymentList, error)
	UpdateDeployment(deployment *appV1.Deployment) (*appV1.Deployment, error)
	RemoveDeployment(name, namespace string) error
	IncreaseDeploymentRef(name, namespace string) error
	DecreaseDeploymentRef(name, namespace string) (bool, error)
	ScaleTo(deployment, namespace string, replicas *int32) (err error)

	GetService(name, namespace string) (*coreV1.Service, error)
	GetServicesBySelector(matchLabels map[string]string, namespace string) ([]coreV1.Service, error)
	GetAllServiceInNamespace(namespace string) (*coreV1.ServiceList, error)
	GetServicesByLabel(labels map[string]string, namespace string) (*coreV1.ServiceList, error)
	CreateService(metaAndSpec *SvcMetaAndSpec) (*coreV1.Service, error)
	UpdateService(svc *coreV1.Service) (*coreV1.Service, error)
	RemoveService(name, namespace string) (err error)
	UpdateServiceHeartBeat(name, namespace string)
	WatchService(name, namespace string, fAdd, fDel, fMod func(*coreV1.Service))

	GetConfigMap(name, namespace string) (*coreV1.ConfigMap, error)
	GetConfigMapsByLabel(labels map[string]string, namespace string) (*coreV1.ConfigMapList, error)
	RemoveConfigMap(name, namespace string) (err error)
	UpdateConfigMapHeartBeat(name, namespace string)

	GetAllIngressInNamespace(namespace string) (*extV1.IngressList, error)

	GetKtResources(namespace string) ([]coreV1.Pod, []coreV1.ConfigMap, []appV1.Deployment, []coreV1.Service, error)
	GetAllNamespaces() (*coreV1.NamespaceList, error)
	ClusterCidr(namespace string) (cidr []string, excludeCidr []string)
}

KubernetesInterface kubernetes interface

func Ins

func Ins() KubernetesInterface

Ins get singleton instance

type PodMetaAndSpec

type PodMetaAndSpec struct {
	Meta   *ResourceMeta
	Image  string
	Envs   map[string]string
	Ports  map[string]int
	IsLeaf bool
}

PodMetaAndSpec ...

type ResourceMeta

type ResourceMeta struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
}

ResourceMeta ...

type SSHkeyMeta

type SSHkeyMeta struct {
	SshConfigMapName string
	PrivateKeyPath   string
}

SSHkeyMeta ...

type SvcMetaAndSpec

type SvcMetaAndSpec struct {
	Meta      *ResourceMeta
	External  bool
	Ports     map[int]int
	Selectors map[string]string
}

SvcMetaAndSpec ...

Jump to

Keyboard shortcuts

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