Documentation ¶
Index ¶
- Constants
- Variables
- func GetListenerPrefix(service *corev1.Service) string
- func GetLoadBalancerName(clusterName string, service *corev1.Service, ...) string
- type AnnotaionConfig
- type Backend
- type BackendList
- type BackendSpec
- type EIPAllocateSource
- 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) 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() (err 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
- type Policy
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 is the annotation which indicates the very vxnet where load // balancer resides. This annotation should NOT be used when ServiceAnnotationLoadBalancerEipIds is // set. ServiceAnnotationLoadBalancerVxnetID = "service.beta.kubernetes.io/qingcloud-load-balancer-vxnet-id" ServiceAnnotationLoadBalancerInternalIP = "service.beta.kubernetes.io/qingcloud-load-balancer-internal-ip" ServiceAnnotationLoadBalancerInternalReuseID = "service.beta.kubernetes.io/qingcloud-load-balancer-reuse-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" // ServiceAnnotationLoadBalancerNetworkType represents the network mode of lb, one of "public" or "internal", public is the default mode which needs at least an eip ServiceAnnotationLoadBalancerNetworkType = "service.beta.kubernetes.io/qingcloud-load-balancer-network-type" // ServiceAnnotationLoadBalancerID is needed when user want to use exsiting lb ServiceAnnotationLoadBalancerID = "service.beta.kubernetes.io/qingcloud-load-balancer-id" // ServiceAnnotationLoadBalancerPolicy 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 ServiceAnnotationLoadBalancerPolicy = "service.beta.kubernetes.io/qingcloud-load-balancer-eip-strategy" ServiceAnnotationLoadBalancerEipSource = "service.beta.kubernetes.io/qingcloud-load-balancer-eip-source" //ReuseExistingLB use existing loadbalancer on the cloud ReuseExistingLB Policy = "reuse-lb" Shared Policy = "reuse" // Exclusive is the default value, means every service has its own EIP Exclusive Policy = "exclusive" ManualSet EIPAllocateSource = "manual" UseAvailableOrAllocateOne EIPAllocateSource = "auto" UseAvailableOnly EIPAllocateSource = "use-available" AllocateOnly EIPAllocateSource = "allocate" NetworkModePublic string = "public" NetworkModeInternal = "internal" )
Variables ¶
var ( ErrorListenerPortConflict = fmt.Errorf("Port has been occupied") )
Functions ¶
func GetListenerPrefix ¶
func GetLoadBalancerName ¶
func GetLoadBalancerName(clusterName string, service *corev1.Service, lb executor.QingCloudLoadBalancerExecutor) string
GetLoadBalancerName generate lb name for each service. The name of a service is fixed and predictable
Types ¶
type AnnotaionConfig ¶ added in v1.4.2
type AnnotaionConfig struct { ScaleType int NetworkType string EipIDs []string EIPAllocateSource Policy InternalIP string InternalReuseID string VxnetID string ReuseLBID string }
func ParseAnnotation ¶ added in v1.4.2
func ParseAnnotation(annotation map[string]string, skipCheck bool) (AnnotaionConfig, error)
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) 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() (err 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 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 DefaultVxnet string }