Documentation
¶
Index ¶
- Constants
- Variables
- func GetListenerPrefix(service *corev1.Service) string
- func GetLoadBalancerName(clusterName string, service *corev1.Service) string
- type Backend
- type BackendList
- type BackendSpec
- type EIPAllocateSource
- type EIPStrategy
- type LisenerSpec
- type Listener
- func (l *Listener) CheckPortConflict() (bool, error)
- func (l *Listener) CreateQingCloudListener() error
- func (l *Listener) CreateQingCloudListenerWithBackends() error
- func (l *Listener) DeleteQingCloudListener() error
- func (l *Listener) GetBackends() *BackendList
- func (l *Listener) LoadBackends()
- func (l *Listener) LoadQcListener() error
- func (l *Listener) NeedUpdate() bool
- func (l *Listener) UpdateBackends() error
- func (l *Listener) UpdateQingCloudListener() error
- type LoadBalancer
- func (l *LoadBalancer) ClearNoUseListener() error
- func (l *LoadBalancer) CreateQingCloudLB() error
- func (l *LoadBalancer) DeleteQingCloudLB() error
- func (l *LoadBalancer) EnsureEIP() error
- func (l *LoadBalancer) EnsureLoadBalancerSecurityGroup() error
- func (l *LoadBalancer) EnsureQingCloudLB() error
- func (l *LoadBalancer) GenerateK8sLoadBalancer() error
- func (l *LoadBalancer) GetListeners() []*Listener
- func (l *LoadBalancer) GetNodesInstanceIDs() []string
- func (l *LoadBalancer) GetService() *corev1.Service
- func (l *LoadBalancer) LoadListeners() error
- func (l *LoadBalancer) LoadQcLoadBalancer() error
- func (l *LoadBalancer) LoadSecurityGroup() error
- func (l *LoadBalancer) NeedChangeIP() (yes bool, toadd []string, todelete []string)
- func (l *LoadBalancer) NeedResize() bool
- func (l *LoadBalancer) NeedUpdate() bool
- func (l *LoadBalancer) UpdateQingCloudLB() error
- type LoadBalancerSpec
- type LoadBalancerStatus
- type NewLoadBalancerOption
Constants ¶
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 ¶
var ( ErrorLBNotFoundInCloud = fmt.Errorf("Cannot find lb in qingcloud") ErrorSGNotFoundInCloud = fmt.Errorf("Cannot find security group in qingcloud") )
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") )
var ErrorBackendNotFound = fmt.Errorf("Cannot find backend")
Functions ¶
func GetListenerPrefix ¶
Types ¶
type Backend ¶
type Backend struct { Name string Spec BackendSpec Status *qcservice.LoadBalancerBackend // contains filtered or unexported fields }
func (*Backend) DeleteBackend ¶
func (*Backend) LoadQcBackend ¶
func (*Backend) NeedUpdate ¶
func (*Backend) UpdateBackend ¶
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 EIPAllocateSource ¶
type EIPAllocateSource string
type LisenerSpec ¶
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 (*Listener) CreateQingCloudListener ¶
func (*Listener) CreateQingCloudListenerWithBackends ¶
func (*Listener) DeleteQingCloudListener ¶
func (*Listener) GetBackends ¶
func (l *Listener) GetBackends() *BackendList
func (*Listener) LoadBackends ¶
func (l *Listener) LoadBackends()
func (*Listener) LoadQcListener ¶
LoadQcListener get real lb in qingcloud
func (*Listener) NeedUpdate ¶
func (*Listener) UpdateBackends ¶ added in v1.3.2
func (*Listener) UpdateQingCloudListener ¶
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 }