metallb

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 19 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 CMConfigurer added in v1.29.0

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

func (*CMConfigurer) AddAddressPool added in v1.29.0

func (m *CMConfigurer) AddAddressPool(_ context.Context, add *AddressPool, svcNamespace, svcName string) (bool, error)

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

func (*CMConfigurer) Get added in v1.29.0

func (m *CMConfigurer) Get(ctx context.Context) error

func (*CMConfigurer) RemoveAddressPool added in v1.29.0

func (m *CMConfigurer) RemoveAddressPool(ctx context.Context, pool string) error

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

func (*CMConfigurer) RemoveAddressPoolByAddress added in v1.29.0

func (m *CMConfigurer) RemoveAddressPoolByAddress(_ context.Context, addr string) error

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

func (*CMConfigurer) RemovePeersByService added in v1.29.0

func (m *CMConfigurer) RemovePeersByService(_ context.Context, svcNamespace, svcName string) (bool, error)

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.

func (*CMConfigurer) Update added in v1.29.0

func (m *CMConfigurer) Update(ctx context.Context) error

func (*CMConfigurer) UpdatePeersByService added in v1.29.0

func (m *CMConfigurer) UpdatePeersByService(_ context.Context, adds *[]Peer, svcNamespace, svcName string) (bool, error)

type CRDConfigurer added in v1.29.0

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

func (*CRDConfigurer) AddAddressPool added in v1.29.0

func (m *CRDConfigurer) AddAddressPool(ctx context.Context, add *AddressPool, svcNamespace, svcName string) (bool, error)

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

func (*CRDConfigurer) Get added in v1.29.0

func (m *CRDConfigurer) Get(_ context.Context) error

func (*CRDConfigurer) RemoveAddressPool added in v1.29.0

func (m *CRDConfigurer) RemoveAddressPool(ctx context.Context, pool string) error

RemoveAddressPool removes a pool by name. If the matching pool does not exist, do not change anything

func (*CRDConfigurer) RemoveAddressPoolByAddress added in v1.29.0

func (m *CRDConfigurer) RemoveAddressPoolByAddress(ctx context.Context, addrName string) error

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

func (*CRDConfigurer) RemovePeersByService added in v1.29.0

func (m *CRDConfigurer) RemovePeersByService(ctx context.Context, svcNamespace, svcName string) (bool, error)

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

func (*CRDConfigurer) Update added in v1.29.0

func (m *CRDConfigurer) Update(_ context.Context) error

func (*CRDConfigurer) UpdatePeersByService added in v1.29.0

func (m *CRDConfigurer) UpdatePeersByService(ctx context.Context, adds *[]Peer, svcNamespace, svcName string) (bool, error)

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 Configurer added in v1.29.0

type Configurer interface {
	// 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.
	UpdatePeersByService(ctx context.Context, adds *[]Peer, svcNamespace, svcName string) (bool, error)

	// 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. Not applicable with CRD
	RemovePeersByService(ctx context.Context, svcNamespace, svcName string) (bool, error)

	// AddAddressPool adds an address pool. If a matching pool already exists, do not change anything.
	// Returns if anything changed
	AddAddressPool(ctx context.Context, add *AddressPool, svcNamespace, svcName string) (bool, error)

	// RemoveAddressPool remove a pool by name. If the matching pool does not exist, do not change anything
	RemoveAddressPool(ctx context.Context, pool string) error

	// RemoveAddressPoolByAddress remove a pool by an address alone. If the matching pool does not exist, do not change anything
	RemoveAddressPoolByAddress(ctx context.Context, addr string) error

	// Read the config from the system, if it needs to be updated
	Get(context.Context) error

	// Update write the config back to the system, if necessary
	Update(context.Context) error
}

type LB

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

func NewLB

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

NewLB returns a new LB The first argument used to be k8sclient. We no longer need it, as we do client.New() in NewLB. We keep it around in case it is needed in the future, e.g. if we need to go back to the configmap. In theory, we should be able to get the client we need of type "sigs.k8s.io/controller-runtime/pkg/client" from the k8sclient; for the future.

func (*LB) AddService

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

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"`
	Name          string         `json:"name,omitempty"`
}

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