metallb

package
v0.0.2-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressPool

type AddressPool struct {
	Protocol          Proto
	Name              string
	Addresses         []string
	AvoidBuggyIPs     bool               `yaml:"avoid-buggy-ips"`
	AutoAssign        *bool              `yaml:"auto-assign"`
	BGPAdvertisements []BgpAdvertisement `yaml:"bgp-advertisements"`
}

func (*AddressPool) Duplicate

func (a *AddressPool) Duplicate() AddressPool

func (*AddressPool) Equal

func (a *AddressPool) Equal(o *AddressPool) bool

Equal determine if two AddressPools are equal. Definition of a match is MatchIgnoreName == true && a.Name == o.Name

func (*AddressPool) EqualIgnoreName

func (a *AddressPool) EqualIgnoreName(o *AddressPool) bool

EqualIgnoreName determine if two AddressPools are equal. Definition of a match is: - Protocol matches - AvoidBuggyIPs matches - AutoAssign matches - Addresses match (order is ignored) - BGPAdvertisements all match (order is ignored)

Note that two match even if the name is different. If you use this function, you must check name match separately!

type BgpAdvertisement

type BgpAdvertisement struct {
	AggregationLength *int `yaml:"aggregation-length"`
	LocalPref         *uint32
	Communities       []string
}

func (*BgpAdvertisement) Duplicate

func (b *BgpAdvertisement) Duplicate() BgpAdvertisement

func (*BgpAdvertisement) Equal

func (b *BgpAdvertisement) Equal(o *BgpAdvertisement) bool

type BgpAdvertisements

type BgpAdvertisements []BgpAdvertisement

func (BgpAdvertisements) Len

func (b BgpAdvertisements) Len() int

func (BgpAdvertisements) Less

func (b BgpAdvertisements) Less(i, j int) bool

func (BgpAdvertisements) Swap

func (b BgpAdvertisements) Swap(i, j int)

type ConfigFile

type ConfigFile struct {
	Peers          []Peer
	BGPCommunities map[string]string `yaml:"bgp-communities"`
	Pools          []AddressPool     `yaml:"address-pools"`
}

configFile is the configuration as parsed out of the ConfigMap, without validation or useful high level types.

func ParseConfig

func ParseConfig(bs []byte) (*ConfigFile, error)

func (*ConfigFile) AddAddressPool

func (cfg *ConfigFile) AddAddressPool(add *AddressPool) bool

AddAddressPool adds an address pool. If a matching pool already exists, do not change anything. Returns if anything changed

func (*ConfigFile) AddPeer

func (cfg *ConfigFile) AddPeer(add *Peer) bool

AddPeer adds a peer. If a matching peer already exists, do not change anything Returns if anything changed.

func (*ConfigFile) AddPeerByService

func (cfg *ConfigFile) AddPeerByService(add *Peer, svcNamespace, svcName string) bool

AddPeerByService adds a peer for a specific service. If a matching peer already exists with the service, do not change anything. If a matching peer already exists but does not have the service, add it. Returns if anything changed.

func (*ConfigFile) Bytes

func (cfg *ConfigFile) Bytes() ([]byte, error)

func (*ConfigFile) RemoveAddressPool

func (cfg *ConfigFile) RemoveAddressPool(remove *AddressPool)

RemoveAddressPool remove a pool. If the matching pool does not exist, do not change anything

func (*ConfigFile) RemoveAddressPoolByAddress

func (cfg *ConfigFile) RemoveAddressPoolByAddress(addr string)

RemoveAddressPooByAddress remove a pool by an address alone. If the matching pool does not exist, do not change anything

func (*ConfigFile) RemovePeer

func (cfg *ConfigFile) RemovePeer(remove *Peer)

RemovePeer remove a peer. If the matching peer does not exist, do not change anything

func (*ConfigFile) RemovePeersBySelector

func (cfg *ConfigFile) RemovePeersBySelector(remove *NodeSelector) bool

RemovePeersBySelector remove a peer by selector. If the matching peer does not exist, do not change anything. Returns if anything changed.

func (*ConfigFile) RemovePeersByService

func (cfg *ConfigFile) RemovePeersByService(svcNamespace, svcName string) bool

RemovePeersByService remove peers from a particular service. For any peers that have this services in the special MatchLabel, remove the service from the label. If there are no services left on a peer, remove the peer entirely.

type LB

type LB struct {
	// contains filtered or unexported fields
}

func NewLB

func NewLB(k8sclient kubernetes.Interface, config string) *LB

func (*LB) AddService

func (l *LB) AddService(ctx context.Context, svcNamespace, svcName, ip string, nodes []loadbalancers.Node) error

func (*LB) RemoveNode

func (l *LB) RemoveNode(ctx context.Context, nodeName string) error

RemoveNode remove a node with the provided name

func (*LB) RemoveService

func (l *LB) RemoveService(ctx context.Context, svcNamespace, svcName, ip string) error

func (*LB) UpdateService

func (l *LB) UpdateService(ctx context.Context, svcNamespace, svcName string, nodes []loadbalancers.Node) error

type NodeSelector

type NodeSelector struct {
	MatchLabels      map[string]string      `yaml:"match-labels"`
	MatchExpressions []SelectorRequirements `yaml:"match-expressions"`
}

func (*NodeSelector) Duplicate

func (ns *NodeSelector) Duplicate() NodeSelector

func (*NodeSelector) Equal

func (ns *NodeSelector) Equal(o *NodeSelector) bool

type NodeSelectors

type NodeSelectors []NodeSelector

func (NodeSelectors) Equal

func (n NodeSelectors) Equal(o NodeSelectors) bool

Equal return true if two sets of NodeSelectors are identical

func (NodeSelectors) EqualIgnoreService

func (n NodeSelectors) EqualIgnoreService(o NodeSelectors) bool

EqualIgnoreService return true if two sets of NodeSelectors are identical, except that the NodeSelector containing the special service label is ignored in the first one.

func (NodeSelectors) Len

func (n NodeSelectors) Len() int

func (NodeSelectors) Less

func (n NodeSelectors) Less(i, j int) bool

func (NodeSelectors) Swap

func (n NodeSelectors) Swap(i, j int)

type Peer

type Peer struct {
	MyASN         uint32         `yaml:"my-asn"`
	ASN           uint32         `yaml:"peer-asn"`
	Addr          string         `yaml:"peer-address"`
	Port          uint16         `yaml:"peer-port"`
	SrcAddr       string         `yaml:"source-address"`
	HoldTime      string         `yaml:"hold-time"`
	RouterID      string         `yaml:"router-id"`
	NodeSelectors []NodeSelector `yaml:"node-selectors"`
	Password      string         `yaml:"password"`
}

func (*Peer) AddService

func (p *Peer) AddService(svcNamespace, svcName string) bool

AddService ensures that the provided service is in the list of linked services.

func (*Peer) Duplicate

func (p *Peer) Duplicate() Peer

func (*Peer) Equal

func (p *Peer) Equal(o *Peer) bool

Equal return true if a peer is identical

func (*Peer) EqualIgnoreService

func (p *Peer) EqualIgnoreService(o *Peer) bool

EqualIgnoreService return true if a peer is identical except for the special service label. Will only check for it in the current Peer p, and not the "other" peer in the parameter.

func (*Peer) MatchSelector

func (p *Peer) MatchSelector(s *NodeSelector) bool

MatchSelector report if this peer matches a given selector

func (*Peer) RemoveService

func (p *Peer) RemoveService(svcNamespace, svcName string) (bool, int)

RemoveService removes a given service from the peer. Returns whether or not it was changed, and how many services are left for this peer.

func (*Peer) Services

func (p *Peer) Services() []Resource

Services list of services that this peer supports

type Proto

type Proto string

Proto holds the protocol we are speaking.

type Resource

type Resource struct {
	Namespace string
	Name      string
}

type Resources

type Resources []Resource

func (Resources) Len

func (r Resources) Len() int

Len is part of sort.Interface.

func (Resources) Less

func (r Resources) Less(i, j int) bool

Less is part of sort.Interface

func (Resources) Swap

func (r Resources) Swap(i, j int)

Swap is part of sort.Interface.

type SelectorRequirements

type SelectorRequirements struct {
	Key      string   `yaml:"key"`
	Operator string   `yaml:"operator"`
	Values   []string `yaml:"values"`
}

func (*SelectorRequirements) Compare

func (*SelectorRequirements) Equal

type SelectorRequirementsSlice

type SelectorRequirementsSlice []SelectorRequirements

func (SelectorRequirementsSlice) Equal

func (SelectorRequirementsSlice) Len

func (SelectorRequirementsSlice) Less

func (s SelectorRequirementsSlice) Less(i, j int) bool

func (SelectorRequirementsSlice) Swap

func (s SelectorRequirementsSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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