loadbalancer

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = L4Type("NONE")
	// TCP type.
	TCP = L4Type("TCP")
	// UDP type.
	UDP = L4Type("UDP")
)

Variables

View Source
var (
	// AllProtocols is the list of all supported L4 protocols
	AllProtocols = []L4Type{TCP, UDP}
)

Functions

This section is empty.

Types

type BackendID

type BackendID uint16

BackendID is the backend's ID.

type FEPort

type FEPort struct {
	*L4Addr
	ID ServiceID
}

FEPort represents a frontend port with its ID and the L4Addr's inheritance.

func NewFEPort

func NewFEPort(protocol L4Type, portNumber uint16) *FEPort

NewFEPort creates a new FEPort with the ID set to 0.

func (*FEPort) Equals

func (f *FEPort) Equals(o *FEPort) bool

Equals returns true if both L4Addr are considered equal.

func (*FEPort) EqualsIgnoreID

func (f *FEPort) EqualsIgnoreID(o *FEPort) bool

EqualsIgnoreID returns true if both L4Addr are considered equal without comparing its ID.

type FEPortName

type FEPortName string

FEPortName is the name of the frontend's port.

type ID

type ID uint32

ID is the ID of L3n4Addr endpoint (either service or backend).

type L3n4Addr

type L3n4Addr struct {
	IP net.IP
	L4Addr
}

L3n4Addr is used to store, as an unique L3+L4 address in the KVStore.

func NewL3n4Addr

func NewL3n4Addr(protocol L4Type, ip net.IP, portNumber uint16) *L3n4Addr

NewL3n4Addr creates a new L3n4Addr.

func NewL3n4AddrFromBackendModel

func NewL3n4AddrFromBackendModel(base *models.BackendAddress) (*L3n4Addr, error)

func NewL3n4AddrFromModel

func NewL3n4AddrFromModel(base *models.FrontendAddress) (*L3n4Addr, error)

func (*L3n4Addr) DeepCopy

func (a *L3n4Addr) DeepCopy() *L3n4Addr

DeepCopy returns a DeepCopy of the given L3n4Addr.

func (*L3n4Addr) GetModel

func (a *L3n4Addr) GetModel() *models.FrontendAddress

func (*L3n4Addr) IsIPv6

func (a *L3n4Addr) IsIPv6() bool

IsIPv6 returns true if the IP address in the given L3n4Addr is IPv6 or not.

func (L3n4Addr) SHA256Sum

func (a L3n4Addr) SHA256Sum() string

SHA256Sum calculates L3n4Addr's internal SHA256Sum.

func (*L3n4Addr) String

func (a *L3n4Addr) String() string

String returns the L3n4Addr in the "IPv4:Port" format for IPv4 and "[IPv6]:Port" format for IPv6.

func (*L3n4Addr) StringID

func (a *L3n4Addr) StringID() string

StringID returns the L3n4Addr as string to be used for unique identification

func (*L3n4Addr) StringWithProtocol

func (a *L3n4Addr) StringWithProtocol() string

StringWithProtocol returns the L3n4Addr in the "IPv4:Port/Protocol" format for IPv4 and "[IPv6]:Port/Protocol" format for IPv6.

type L3n4AddrID

type L3n4AddrID struct {
	L3n4Addr
	ID ID
}

L3n4AddrID is used to store, as an unique L3+L4 plus the assigned ID, in the KVStore.

func NewL3n4AddrID

func NewL3n4AddrID(protocol L4Type, ip net.IP, portNumber uint16, id ID) *L3n4AddrID

NewL3n4AddrID creates a new L3n4AddrID.

func (*L3n4AddrID) DeepCopy

func (l *L3n4AddrID) DeepCopy() *L3n4AddrID

DeepCopy returns a DeepCopy of the given L3n4AddrID.

func (*L3n4AddrID) Equals added in v1.6.0

func (l *L3n4AddrID) Equals(o *L3n4AddrID) bool

Equals checks equality of both given addresses.

func (*L3n4AddrID) IsIPv6

func (l *L3n4AddrID) IsIPv6() bool

IsIPv6 returns true if the IP address in L3n4Addr's L3n4AddrID is IPv6 or not.

type L4Addr

type L4Addr struct {
	Protocol L4Type
	Port     uint16
}

L4Addr is an abstraction for the backend port with a L4Type, usually tcp or udp, and the Port number.

func NewL4Addr

func NewL4Addr(protocol L4Type, number uint16) *L4Addr

NewL4Addr creates a new L4Addr.

func (*L4Addr) DeepCopy

func (l *L4Addr) DeepCopy() *L4Addr

DeepCopy returns a DeepCopy of the given L4Addr.

func (*L4Addr) Equals

func (l *L4Addr) Equals(o *L4Addr) bool

Equals returns true if both L4Addr are considered equal.

type L4Type

type L4Type string

L4Type name.

func NewL4Type

func NewL4Type(name string) (L4Type, error)

type LBBackEnd

type LBBackEnd struct {
	ID BackendID
	L3n4Addr
	Weight uint16
}

LBBackEnd represents load balancer backend.

func NewLBBackEnd

func NewLBBackEnd(id BackendID, protocol L4Type, ip net.IP, portNumber uint16, weight uint16) *LBBackEnd

NewLBBackEnd creates the LBBackEnd struct instance from given params.

func NewLBBackEndFromBackendModel

func NewLBBackEndFromBackendModel(base *models.BackendAddress) (*LBBackEnd, error)

func (*LBBackEnd) GetBackendModel

func (b *LBBackEnd) GetBackendModel() *models.BackendAddress

func (*LBBackEnd) String

func (lbbe *LBBackEnd) String() string

type LBSVC

type LBSVC struct {
	Sha256   string
	FE       L3n4AddrID
	BES      []LBBackEnd
	NodePort bool
}

LBSVC is essentially used for the REST API.

func (*LBSVC) GetModel

func (s *LBSVC) GetModel() *models.Service

type LoadBalancer

type LoadBalancer struct {
	BPFMapMU  lock.RWMutex
	SVCMap    SVCMap
	SVCMapID  SVCMapID
	RevNATMap RevNATMap
}

LoadBalancer is the internal representation of the loadbalancer in the local cilium daemon.

func NewLoadBalancer

func NewLoadBalancer() *LoadBalancer

NewLoadBalancer returns a LoadBalancer with all maps initialized.

func (*LoadBalancer) AddService

func (lb *LoadBalancer) AddService(svc LBSVC) bool

AddService adds a service to list of loadbalancers and returns true if created.

func (*LoadBalancer) DeleteService

func (lb *LoadBalancer) DeleteService(svc *LBSVC)

DeleteService deletes svc from lb's SVCMap and SVCMapID.

type RevNATMap

type RevNATMap map[ServiceID]L3n4Addr

RevNATMap is a map of the daemon's RevNATs.

type SVCMap

type SVCMap map[string]LBSVC

SVCMap is a map of the daemon's services. The key is the sha256sum of the LBSVC's FE and the value the LBSVC.

func (SVCMap) AddFEnBE

func (svcs SVCMap) AddFEnBE(fe *L3n4AddrID, be *LBBackEnd, beIndex int) *LBSVC

AddFEnBE adds the given 'fe' and 'be' to the SVCMap. If 'fe' exists and beIndex is 0, the new 'be' will be appended to the list of existing backends. If beIndex is bigger than the size of existing backends slice, it will be created a new array with size of beIndex and the new 'be' will be inserted on index beIndex-1 of that new array. All remaining be elements will be kept on the same index and, in case the new array is larger than the number of backends, some elements will be empty.

type SVCMapID

type SVCMapID map[ServiceID]*LBSVC

SVCMapID maps service IDs to service structures.

type ServiceID

type ServiceID uint16

ServiceID is the service's ID.

Jump to

Keyboard shortcuts

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