mgr

package
v0.0.0-...-aab1398 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package mgr manages listeners for each LoadBalancer definition configured in the kubernetes services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(ip IP, port Port) string

Address ip + ':' + port

func ConfigureBackoff

func ConfigureBackoff(step, maxStep, maxElapsedTime time.Duration, cancel chan struct{}) *backoff.ExponentialBackOff

ConfigureBackoff using some normal steps

func DurationString

func DurationString(d time.Duration) string

DurationString string of hours, minutes, seconds, nanoseconds

func Endpoints

func Endpoints(
	Clientset *kubernetes.Clientset,
	Service *v1.Service) (ep *v1.Endpoints)

Endpoints returns *v1.Endpoints

func HMSN

func HMSN(d time.Duration) (h, m, s, n int64)

HMSN hours, minutes, seconds, nanoseconds

func InCluster

func InCluster() bool

InCluster checks whether app is running in a kubernetes clsuter

func Listen

func Listen(
	serviceKey, address string, cancel chan struct{}) (
	listener net.Listener)

Listen open listener on address

func NewPipeDefinition

func NewPipeDefinition(Service *v1.Service, envCfg *share.ServerCfg) *pipe.Definition

NewPipeDefinition from a kubernetes v1.Service

Types

type IP

type IP string

IP IP address

type IPByPort

type IPByPort map[Port]IPSet

IPByPort ports for an address

type IPSet

type IPSet map[IP]bool

IPSet set of address

func (IPSet) ToIPs

func (ipSet IPSet) ToIPs() (ips IPs)

ToIPs from a set

type IPs

type IPs []IP

IPs sortable slice of IP addresses

func EndpointIPs

func EndpointIPs(ep *v1.Endpoints) (ips IPs)

EndpointIPs get the ips from EndpointSubsets

func (IPs) Equal

func (ips IPs) Equal(rhs IPs) bool

Equal compare 2 IP arrays

func (IPs) Len

func (ips IPs) Len() int

func (IPs) Less

func (ips IPs) Less(i, j int) bool

func (IPs) Swap

func (ips IPs) Swap(i, j int)

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

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) Close

func (mgr *Mgr) Close(Key string)

Close removes a pipe definition

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) GetCreate

func (mgr *Mgr) GetCreate(Key string, Service *v1.Service, created *bool) (ml *ManagedListener)

GetCreate returns a listener by key

func (*Mgr) Listen

func (mgr *Mgr) Listen(Service *v1.Service)

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) NodeWatch

func (mgr *Mgr) NodeWatch()

NodeWatch manage node workers list dynamically

func (*Mgr) Run

func (mgr *Mgr) Run()

Run primary processing loop

func (*Mgr) ServiceWatch

func (mgr *Mgr) ServiceWatch()

ServiceWatch watch.QueueMgr for LoadBalancers

func (*Mgr) Set

func (mgr *Mgr) Set(Key string, ml *ManagedListener)

Set a listener by key

func (*Mgr) SetEndpoint

func (mgr *Mgr) SetEndpoint(Key string, ep *v1.Endpoints)

SetEndpoint sets the endpoint addresses for a managed listener with lock

func (*Mgr) SetService

func (mgr *Mgr) SetService(Key string, Service *v1.Service)

SetService sets the endpoint addresses for a managed listener with lock

func (*Mgr) Shutdown

func (mgr *Mgr) Shutdown()

Shutdown this manager

type Port

type Port int32

Port number

func ServicePort

func ServicePort(Service *v1.Service) (port Port)

ServicePort Port from v1.Service

func SinkPort

func SinkPort(Service *v1.Service, ep *v1.Endpoints) (port Port)

SinkPort Port from v1.Service or v1.Endpoints

type PortByIP

type PortByIP map[IP]PortSet

PortByIP ports for an address

type PortSet

type PortSet map[Port]bool

PortSet set of ports

func (PortSet) ToPorts

func (portSet PortSet) ToPorts() (ports Ports)

ToPorts from a set

type Ports

type Ports []Port

Ports sortable Port slice

func EndpointSubsetPorts

func EndpointSubsetPorts(ep *v1.Endpoints) (ports Ports)

EndpointSubsetPorts get the ports from EndpointSubsets

func ServiceTargetPorts

func ServiceTargetPorts(svc *v1.Service) (ports Ports)

ServiceTargetPorts get the ports for a Service port array

func (Ports) Equal

func (ports Ports) Equal(rhs Ports) bool

Equal compare 2 port arrays

func (Ports) Len

func (ports Ports) Len() int

func (Ports) Less

func (ports Ports) Less(i, j int) bool

func (Ports) PortSet

func (ports Ports) PortSet() (ps PortSet)

PortSet from port slice

func (Ports) Swap

func (ports Ports) Swap(i, j int)

Jump to

Keyboard shortcuts

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