loadbalance

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceAnnotationLoadBalancerEipIds is the annotation which specifies a list of eip ids.
	// The ids in list are separated by ',', e.g. "eip-j38f2h3h,eip-ornz2xq7". And this annotation should
	// NOT be used with ServiceAnnotationLoadBalancerVxnetId. Please make sure there is one and only one
	// of them being set
	ServiceAnnotationLoadBalancerEipIds = "service.beta.kubernetes.io/qingcloud-load-balancer-eip-ids"

	ServiceAnnotationLoadBalancerVxnetID = "service.beta.kubernetes.io/qingcloud-load-balancer-vxnet-id"

	// ServiceAnnotationLoadBalancerType is the annotation used on the
	// service to indicate that we want a qingcloud loadBalancer type.
	// value "0" means the LB can max support 5000 concurrency connections, it's default type.
	// value "1" means the LB can max support 20000 concurrency connections.
	// value "2" means the LB can max support 40000 concurrency connections.
	// value "3" means the LB can max support 100000 concurrency connections.
	// value "4" means the LB can max support 200000 concurrency connections.
	// value "5" means the LB can max support 500000 concurrency connections.
	ServiceAnnotationLoadBalancerType = "service.beta.kubernetes.io/qingcloud-load-balancer-type"

	// ServiceAnnotationLoadBalancerEipStrategy is usd to specify EIP use strategy
	// reuse represent the EIP can be shared with other service which has no port conflict
	// exclusive is the default value, means every service has its own EIP
	ServiceAnnotationLoadBalancerEipStrategy = "service.beta.kubernetes.io/qingcloud-load-balancer-eip-strategy"

	ServiceAnnotationLoadBalancerEipSource = "service.beta.kubernetes.io/qingcloud-load-balancer-eip-source"

	// ReuseEIP represent the EIP can be shared with other service which has no port conflict
	ReuseEIP EIPStrategy = "reuse"
	// Exclusive is the default value, means every service has its own EIP
	Exclusive EIPStrategy = "exclusive"

	ManualSet                 EIPAllocateSource = "manual"
	UseAvailableOrAllocateOne EIPAllocateSource = "auto"
	UseAvailableOnly          EIPAllocateSource = "use-available"
	AllocateOnly              EIPAllocateSource = "allocate"
)

Variables

View Source
var (
	ErrorLBNotFoundInCloud = fmt.Errorf("Cannot find lb in qingcloud")
	ErrorSGNotFoundInCloud = fmt.Errorf("Cannot find security group in qingcloud")
)
View Source
var (
	ErrorListenerPortConflict = fmt.Errorf("Port has been occupied")
	ErrorReuseEIPButNoName    = fmt.Errorf("If you want to reuse an eip , you must specify the name of each port in service")
	ErrorListenerNotFound     = fmt.Errorf("Failed to get listener in cloud")
)
View Source
var ErrorBackendNotFound = fmt.Errorf("Cannot find backend")

Functions

func GetListenerPrefix

func GetListenerPrefix(service *corev1.Service) string

func GetLoadBalancerName

func GetLoadBalancerName(clusterName string, service *corev1.Service) string

GetLoadBalancerName generate lb name for each service. The name of a service is fixed and predictable

Types

type Backend

type Backend struct {
	Name   string
	Spec   BackendSpec
	Status *qcservice.LoadBalancerBackend
	// contains filtered or unexported fields
}

func (*Backend) Create added in v1.3.2

func (b *Backend) Create() error

func (*Backend) DeleteBackend

func (b *Backend) DeleteBackend() error

func (*Backend) LoadQcBackend

func (b *Backend) LoadQcBackend() error

func (*Backend) NeedUpdate

func (b *Backend) NeedUpdate() bool

func (*Backend) UpdateBackend

func (b *Backend) UpdateBackend() error

type BackendList

type BackendList struct {
	Listener *Listener
	Items    []*Backend
	// contains filtered or unexported fields
}

func NewBackendList

func NewBackendList(lb *LoadBalancer, listener *Listener) *BackendList

func (*BackendList) CreateBackends

func (b *BackendList) CreateBackends() error

func (*BackendList) LoadAndGetUselessBackends added in v1.3.2

func (b *BackendList) LoadAndGetUselessBackends() ([]string, error)

type BackendSpec

type BackendSpec struct {
	Listener   *Listener
	Weight     int
	Port       int
	InstanceID string
}

type EIPAllocateSource

type EIPAllocateSource string

type EIPStrategy

type EIPStrategy string

EIPStrategy is the type representing eip strategy

type LisenerSpec

type LisenerSpec struct {
	PrefixName   string
	Name         string
	ListenerPort int
	BalanceMode  string
	Protocol     string
	NodePort     int
	// contains filtered or unexported fields
}

type Listener

type Listener struct {
	LisenerSpec
	Status *qcservice.LoadBalancerListener
	// contains filtered or unexported fields
}

Listener is

func NewListener

func NewListener(lb *LoadBalancer, port int) (*Listener, error)

func (*Listener) CheckPortConflict

func (l *Listener) CheckPortConflict() (bool, error)

func (*Listener) CreateQingCloudListener

func (l *Listener) CreateQingCloudListener() error

func (*Listener) CreateQingCloudListenerWithBackends

func (l *Listener) CreateQingCloudListenerWithBackends() error

func (*Listener) DeleteQingCloudListener

func (l *Listener) DeleteQingCloudListener() error

func (*Listener) GetBackends

func (l *Listener) GetBackends() *BackendList

func (*Listener) LoadBackends

func (l *Listener) LoadBackends()

func (*Listener) LoadQcListener

func (l *Listener) LoadQcListener() error

LoadQcListener get real lb in qingcloud

func (*Listener) NeedUpdate

func (l *Listener) NeedUpdate() bool

func (*Listener) UpdateBackends added in v1.3.2

func (l *Listener) UpdateBackends() error

func (*Listener) UpdateQingCloudListener

func (l *Listener) UpdateQingCloudListener() error

type LoadBalancer

type LoadBalancer struct {
	LoadBalancerSpec
	Status LoadBalancerStatus
	// contains filtered or unexported fields
}

func NewLoadBalancer

func NewLoadBalancer(opt *NewLoadBalancerOption) (*LoadBalancer, error)

NewLoadBalancer create loadbalancer in memory, not in cloud, call 'CreateQingCloudLB' to create a real loadbalancer in qingcloud

func (*LoadBalancer) ClearNoUseListener

func (l *LoadBalancer) ClearNoUseListener() error

ClearNoUseListener delete uneccassary listeners in qingcloud, used when service ports changed

func (*LoadBalancer) CreateQingCloudLB

func (l *LoadBalancer) CreateQingCloudLB() error

CreateQingCloudLB do create a lb in qingcloud

func (*LoadBalancer) DeleteQingCloudLB

func (l *LoadBalancer) DeleteQingCloudLB() error

func (*LoadBalancer) EnsureEIP

func (l *LoadBalancer) EnsureEIP() error

func (*LoadBalancer) EnsureLoadBalancerSecurityGroup

func (l *LoadBalancer) EnsureLoadBalancerSecurityGroup() error

EnsureLoadBalancerSecurityGroup will create a SecurityGroup if not exists

func (*LoadBalancer) EnsureQingCloudLB added in v1.3.2

func (l *LoadBalancer) EnsureQingCloudLB() error

func (*LoadBalancer) GenerateK8sLoadBalancer

func (l *LoadBalancer) GenerateK8sLoadBalancer() error

GenerateK8sLoadBalancer get a corev1.LoadBalancerStatus for k8s

func (*LoadBalancer) GetListeners

func (l *LoadBalancer) GetListeners() []*Listener

GetListeners return listeners of this service

func (*LoadBalancer) GetNodesInstanceIDs

func (l *LoadBalancer) GetNodesInstanceIDs() []string

GetNodesInstanceIDs return resource ids for listener to create backends

func (*LoadBalancer) GetService

func (l *LoadBalancer) GetService() *corev1.Service

GetService return service of this loadbalancer

func (*LoadBalancer) LoadListeners

func (l *LoadBalancer) LoadListeners() error

LoadListeners use should mannually load listener because sometimes we do not need load entire topology. For example, deletion

func (*LoadBalancer) LoadQcLoadBalancer

func (l *LoadBalancer) LoadQcLoadBalancer() error

LoadQcLoadBalancer use qingcloud api to get lb in cloud, return err if not found

func (*LoadBalancer) LoadSecurityGroup

func (l *LoadBalancer) LoadSecurityGroup() error

LoadSecurityGroup read SecurityGroup in qingcloud related with this service

func (*LoadBalancer) NeedChangeIP

func (l *LoadBalancer) NeedChangeIP() (yes bool, toadd []string, todelete []string)

func (*LoadBalancer) NeedResize

func (l *LoadBalancer) NeedResize() bool

NeedResize tell us if we should resize the lb in qingcloud

func (*LoadBalancer) NeedUpdate

func (l *LoadBalancer) NeedUpdate() bool

NeedUpdate tell us whether an update to loadbalancer is needed

func (*LoadBalancer) UpdateQingCloudLB

func (l *LoadBalancer) UpdateQingCloudLB() error

UpdateQingCloudLB update some attrs of qingcloud lb

type LoadBalancerSpec

type LoadBalancerSpec struct {
	EIPAllocateSource EIPAllocateSource
	EIPStrategy       EIPStrategy
	EIPs              []string
	Type              int
	TCPPorts          []int
	NodePorts         []int
	Nodes             []*corev1.Node
	Name              string
	// contains filtered or unexported fields
}

type LoadBalancerStatus

type LoadBalancerStatus struct {
	K8sLoadBalancerStatus *corev1.LoadBalancerStatus
	QcLoadBalancer        *qcservice.LoadBalancer
	QcSecurityGroup       *qcservice.SecurityGroup
}

type NewLoadBalancerOption

type NewLoadBalancerOption struct {
	EipHelper  eip.EIPHelper
	LbExecutor executor.QingCloudLoadBalancerExecutor
	SgExecutor executor.QingCloudSecurityGroupExecutor
	NodeLister corev1lister.NodeLister

	K8sNodes    []*corev1.Node
	K8sService  *corev1.Service
	Context     context.Context
	ClusterName string
	SkipCheck   bool
}

Jump to

Keyboard shortcuts

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