Documentation ¶
Overview ¶
Package mgr manages listeners for each LoadBalancer definition configured in the kubernetes services
Index ¶
- func Address(ip IP, port Port) string
- func ConfigureBackoff(step, maxStep, maxElapsedTime time.Duration, cancel chan struct{}) *backoff.ExponentialBackOff
- func DurationString(d time.Duration) string
- func Endpoints(Clientset *kubernetes.Clientset, Service *v1.Service) (ep *v1.Endpoints)
- func HMSN(d time.Duration) (h, m, s, n int64)
- func InCluster() bool
- func Listen(serviceKey, address string, cancel chan struct{}) (listener net.Listener)
- func NewPipeDefinition(Service *v1.Service, envCfg *share.ServerCfg) *pipe.Definition
- type IP
- type IPByPort
- type IPSet
- type IPs
- type ManagedListener
- func (ml *ManagedListener) Accept() (net.Conn, error)
- func (ml *ManagedListener) Close()
- func (lhs *ManagedListener) Copy(rhs *ManagedListener) *ManagedListener
- func (ml *ManagedListener) Delete(pipe *pipe.Pipe)
- func (lhs *ManagedListener) Equal(rhs *ManagedListener) bool
- func (ml *ManagedListener) Insert(pipe *pipe.Pipe)
- func (ml *ManagedListener) Listening()
- func (ml *ManagedListener) Monitor(args ...interface{}) func()
- func (ml *ManagedListener) Next() (sink string)
- func (ml *ManagedListener) Open()
- func (ml *ManagedListener) PipeMapHandler()
- func (ml *ManagedListener) RemoveExternalIP()
- func (ml *ManagedListener) SetEndpoint(ep *v1.Endpoints)
- func (ml *ManagedListener) SetExternalIP()
- func (ml *ManagedListener) SetService(Service *v1.Service)
- func (ml *ManagedListener) StopWatchNotify()
- func (ml *ManagedListener) UpdateEndpoints()
- func (ml *ManagedListener) UpdateEndpointsWithBackoff()
- type ManagedListenerMap
- type ManagedListeners
- type Mgr
- func (mgr *Mgr) Close(Key string)
- func (mgr *Mgr) EndpointWatch()
- func (mgr *Mgr) Get(Key string) (ml *ManagedListener, ok bool)
- func (mgr *Mgr) GetCreate(Key string, Service *v1.Service, created *bool) (ml *ManagedListener)
- func (mgr *Mgr) Listen(Service *v1.Service)
- func (mgr *Mgr) Monitor() func()
- func (mgr *Mgr) NodeWatch()
- func (mgr *Mgr) Run()
- func (mgr *Mgr) ServiceWatch()
- func (mgr *Mgr) Set(Key string, ml *ManagedListener)
- func (mgr *Mgr) SetEndpoint(Key string, ep *v1.Endpoints)
- func (mgr *Mgr) SetService(Key string, Service *v1.Service)
- func (mgr *Mgr) Shutdown()
- type Port
- type PortByIP
- type PortSet
- type Ports
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureBackoff ¶
func ConfigureBackoff(step, maxStep, maxElapsedTime time.Duration, cancel chan struct{}) *backoff.ExponentialBackOff
ConfigureBackoff using some normal steps
func DurationString ¶
DurationString string of hours, minutes, seconds, nanoseconds
func InCluster ¶
func InCluster() bool
InCluster checks whether app is running in a kubernetes clsuter
func NewPipeDefinition ¶
NewPipeDefinition from a kubernetes v1.Service
Types ¶
type IPs ¶
type IPs []IP
IPs sortable slice of IP addresses
func EndpointIPs ¶
EndpointIPs get the ips from EndpointSubsets
type ManagedListener ¶
type ManagedListener struct { pipe.Definition Listener net.Listener `json:"-"` Pipes map[*pipe.Pipe]bool `json:"-"` Mutex *mutex.Mutex `json:"-"` Debug bool `json:"-"` MapAdd chan *pipe.Pipe `json:"-"` MapRm chan *pipe.Pipe `json:"-"` Clientset *kubernetes.Clientset `json:"-"` StopWatch chan bool `json:"-"` Active uint64 Key string Service *v1.Service Endpoints *v1.Endpoints EndpointsChanged bool Canceled chan struct{} Create time.Time Port IPs Ports *ipmgr.CIDR // contains filtered or unexported fields }
ManagedListener and it's dependent objects
func NewManagedListener ¶
func NewManagedListener(Service *v1.Service, envCfg *share.ServerCfg, Clientset *kubernetes.Clientset) (ml *ManagedListener)
NewManagedListener from a kubernetes v1.Service
func (*ManagedListener) Accept ¶
func (ml *ManagedListener) Accept() (net.Conn, error)
Accept expose ManagedListener's listener
func (*ManagedListener) Close ¶
func (ml *ManagedListener) Close()
Close a listener and it's children
func (*ManagedListener) Copy ¶
func (lhs *ManagedListener) Copy(rhs *ManagedListener) *ManagedListener
Copy points w/o erasing EndPoints
func (*ManagedListener) Delete ¶
func (ml *ManagedListener) Delete(pipe *pipe.Pipe)
Delete pipe from map of pipes in managed listener
func (*ManagedListener) Equal ¶
func (lhs *ManagedListener) Equal(rhs *ManagedListener) bool
Equal compares two ManagedListener objects
func (*ManagedListener) Insert ¶
func (ml *ManagedListener) Insert(pipe *pipe.Pipe)
Insert pipe to map of pipes in managed listener
func (*ManagedListener) Listening ¶
func (ml *ManagedListener) Listening()
Listening on managed listener
func (*ManagedListener) Monitor ¶
func (ml *ManagedListener) Monitor(args ...interface{}) func()
Monitor for this ManagedListener
func (*ManagedListener) Next ¶
func (ml *ManagedListener) Next() (sink string)
Next returns the next host:port pair if more than one available round robin selection
func (*ManagedListener) Open ¶
func (ml *ManagedListener) Open()
Open / start Listening and run PipeMapHandler
func (*ManagedListener) PipeMapHandler ¶
func (ml *ManagedListener) PipeMapHandler()
PipeMapHandler adds, removes, closes and single threads access to map list
func (*ManagedListener) RemoveExternalIP ¶
func (ml *ManagedListener) RemoveExternalIP()
RemoveExternalIP from service spec
func (*ManagedListener) SetEndpoint ¶
func (ml *ManagedListener) SetEndpoint(ep *v1.Endpoints)
SetEndpoint from nodes or others
func (*ManagedListener) SetExternalIP ¶
func (ml *ManagedListener) SetExternalIP()
SetExternalIP for service spec
func (*ManagedListener) SetService ¶
func (ml *ManagedListener) SetService(Service *v1.Service)
SetService from nodes or others
func (*ManagedListener) StopWatchNotify ¶
func (ml *ManagedListener) StopWatchNotify()
StopWatchNotify checking for endpoints
func (*ManagedListener) UpdateEndpoints ¶
func (ml *ManagedListener) UpdateEndpoints()
UpdateEndpoints when in a cluster and processing asynchronous updates manage changes
func (*ManagedListener) UpdateEndpointsWithBackoff ¶
func (ml *ManagedListener) UpdateEndpointsWithBackoff()
UpdateEndpointsWithBackoff retry until endoints are found
type ManagedListenerMap ¶
type ManagedListenerMap map[Port]*ManagedListener
ManagedListenerMap of managed listeners by port
type ManagedListeners ¶
type ManagedListeners struct { Listeners ManagedListenerMap Mutex *mutex.Mutex `json:"-"` Debug bool `json:"-"` Clientset *kubernetes.Clientset Active uint64 Service *v1.Service *ipmgr.CIDR IPs Ports }
ManagedListeners manages multiple managed listeners for multiple ports and endpoints
type Mgr ¶
type Mgr struct { Listeners map[string]*ManagedListener Mutex *mutex.Mutex EnvCfg *share.ServerCfg NodeWatcher *watch.QueueMgr ServiceWatcher *watch.QueueMgr EndpointWatcher *watch.QueueMgr *kubernetes.Clientset }
Mgr management info for listeners
func NewMgr ¶
func NewMgr(EnvCfg *share.ServerCfg, Clientset *kubernetes.Clientset) *Mgr
NewMgr create a new Mgr
func (*Mgr) EndpointWatch ¶
func (mgr *Mgr) EndpointWatch()
EndpointWatch watch.QueueMgr for LoadBalancers
func (*Mgr) Get ¶
func (mgr *Mgr) Get(Key string) (ml *ManagedListener, ok bool)
Get a listener by key
func (*Mgr) Listen ¶
Listen creates a listener and retries until the listener works with exponential backoff
func (*Mgr) Monitor ¶
func (mgr *Mgr) Monitor() func()
Monitor lifts mutex deferable lock to Mgr object
func (*Mgr) ServiceWatch ¶
func (mgr *Mgr) ServiceWatch()
ServiceWatch watch.QueueMgr for LoadBalancers
func (*Mgr) SetEndpoint ¶
SetEndpoint sets the endpoint addresses for a managed listener with lock
func (*Mgr) SetService ¶
SetService sets the endpoint addresses for a managed listener with lock
type Ports ¶
type Ports []Port
Ports sortable Port slice
func EndpointSubsetPorts ¶
EndpointSubsetPorts get the ports from EndpointSubsets
func ServiceTargetPorts ¶
ServiceTargetPorts get the ports for a Service port array