Documentation ¶
Overview ¶
Package speaker abstracts the BGP speaker controller from MetalLB. This package provides BGP announcements based on K8s object event handling.
Index ¶
- Variables
- type CidrSlice
- type MetalLBSpeaker
- func (s *MetalLBSpeaker) OnAddNode(node *v1.Node, swg *lock.StoppableWaitGroup) error
- func (s *MetalLBSpeaker) OnDeleteNode(node *v1.Node, swg *lock.StoppableWaitGroup) error
- func (s *MetalLBSpeaker) OnDeleteService(svc *slim_corev1.Service) error
- func (s *MetalLBSpeaker) OnUpdateEndpointSliceV1(eps *slim_discover_v1.EndpointSlice) error
- func (s *MetalLBSpeaker) OnUpdateEndpointSliceV1Beta1(eps *slim_discover_v1beta1.EndpointSlice) error
- func (s *MetalLBSpeaker) OnUpdateEndpoints(eps *slim_corev1.Endpoints) error
- func (s *MetalLBSpeaker) OnUpdateNode(oldNode, newNode *v1.Node, swg *lock.StoppableWaitGroup) error
- func (s *MetalLBSpeaker) OnUpdateService(svc *slim_corev1.Service) error
- func (s *MetalLBSpeaker) RegisterSvcCache(cache endpointsGetter)
- type Op
- type Opts
- type Speaker
Constants ¶
This section is empty.
Variables ¶
var (
ErrShutDown = errors.New("cannot enqueue event, speaker is shutdown")
)
Functions ¶
This section is empty.
Types ¶
type CidrSlice ¶
type CidrSlice []string
CidrSlice is a slice of Cidr strings with a method set for converting them to MetalLB advertisements.
func (CidrSlice) ToAdvertisements ¶
func (cs CidrSlice) ToAdvertisements() []*metallbbgp.Advertisement
ToAdvertisements converts the CidrSlice into metallb Advertisements.
If a cidr cannot be parsed it is omitted from the array of Advertisements returned an an error is logged.
type MetalLBSpeaker ¶
type MetalLBSpeaker struct { // Our speaker requeues our own event structures on failure. // Use a fence to avoid replaying stale events. fence.Fencer lock.Mutex // contains filtered or unexported fields }
MetalLBSpeaker represents the BGP speaker. It integrates Cilium's K8s events with MetalLB's logic for making BGP announcements. It is responsible for announcing BGP messages containing a loadbalancer IP address to peers.
func New ¶
func New(ctx context.Context, opts Opts) (*MetalLBSpeaker, error)
New creates a new MetalLB BGP speaker controller. Options are provided to specify what the Speaker should announce via BGP.
func (*MetalLBSpeaker) OnAddNode ¶
func (s *MetalLBSpeaker) OnAddNode(node *v1.Node, swg *lock.StoppableWaitGroup) error
OnAddNode notifies the Speaker of a new node.
func (*MetalLBSpeaker) OnDeleteNode ¶
func (s *MetalLBSpeaker) OnDeleteNode(node *v1.Node, swg *lock.StoppableWaitGroup) error
OnDeleteNode notifies the Speaker of a node deletion.
When the speaker discovers the node that it is running on is shuttig down it will send a BGP message to its peer instructing it to withdrawal all previously advertised routes.
func (*MetalLBSpeaker) OnDeleteService ¶
func (s *MetalLBSpeaker) OnDeleteService(svc *slim_corev1.Service) error
OnDeleteService notifies the Speaker of a delete of a service.
func (*MetalLBSpeaker) OnUpdateEndpointSliceV1 ¶ added in v1.11.0
func (s *MetalLBSpeaker) OnUpdateEndpointSliceV1(eps *slim_discover_v1.EndpointSlice) error
OnUpdateEndpointSliceV1 notifies the Speaker of an update to the backends of a service as endpoint slices.
func (*MetalLBSpeaker) OnUpdateEndpointSliceV1Beta1 ¶ added in v1.11.0
func (s *MetalLBSpeaker) OnUpdateEndpointSliceV1Beta1(eps *slim_discover_v1beta1.EndpointSlice) error
OnUpdateEndpointSliceV1Beta1 is the same as OnUpdateEndpointSliceV1() but for the v1beta1 variant.
func (*MetalLBSpeaker) OnUpdateEndpoints ¶
func (s *MetalLBSpeaker) OnUpdateEndpoints(eps *slim_corev1.Endpoints) error
OnUpdateEndpoints notifies the Speaker of an update to the backends of a service.
func (*MetalLBSpeaker) OnUpdateNode ¶
func (s *MetalLBSpeaker) OnUpdateNode(oldNode, newNode *v1.Node, swg *lock.StoppableWaitGroup) error
OnUpdateNode notifies the Speaker of an update to a node.
func (*MetalLBSpeaker) OnUpdateService ¶
func (s *MetalLBSpeaker) OnUpdateService(svc *slim_corev1.Service) error
OnUpdateService notifies the Speaker of an update to a service.
func (*MetalLBSpeaker) RegisterSvcCache ¶
func (s *MetalLBSpeaker) RegisterSvcCache(cache endpointsGetter)
RegisterSvcCache registers the K8s watcher cache with this Speaker.
type Speaker ¶
type Speaker interface { // SetService will announce the provided Service of type LoadBalancer to BGP peers. SetService(name string, svc *metallbspr.Service, eps *metallbspr.Endpoints) types.SyncState // SetNodeLabels will create or delete any BGP sessions given the provided labels // allow for this. // // The provided labels will be used to determine if the Speaker allows for BGP // peering. SetNodeLabels(labels map[string]string) types.SyncState // PeerSessions returns any active BGP sessions. PeerSessions() []metallbspr.Session }
Speaker provides a method set for interfacing with a BGP speaker.
This interface is heavily modeled after MetalLB's speaker as it's the first BGP integration for Cilium's use cases.
If other BGP integrations are desired, consider building out custom types and a more abstracted method set.