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) OnDeleteService(svc *slim_corev1.Service) error
- func (s *MetalLBSpeaker) OnUpdateEndpoints(eps *k8s.Endpoints) error
- func (s *MetalLBSpeaker) OnUpdateService(svc *slim_corev1.Service) error
- func (s *MetalLBSpeaker) RegisterSvcCache(cache endpointsGetter)
- func (s *MetalLBSpeaker) SubscribeToLocalCiliumNodeResource(ctx context.Context, lcnr agentK8s.LocalCiliumNodeResource)
- func (s *MetalLBSpeaker) SubscribeToLocalNodeResource(ctx context.Context, lnr agentK8s.LocalNodeResource)
- 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 ¶
New creates a new MetalLB BGP speaker controller. Options are provided to specify what the Speaker should announce via BGP.
func (*MetalLBSpeaker) OnDeleteService ¶
func (s *MetalLBSpeaker) OnDeleteService(svc *slim_corev1.Service) error
OnDeleteService notifies the Speaker of a delete of a service.
func (*MetalLBSpeaker) OnUpdateEndpoints ¶
func (s *MetalLBSpeaker) OnUpdateEndpoints(eps *k8s.Endpoints) error
OnUpdateEndpoints notifies the Speaker of an update to the backends of a service.
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.
func (*MetalLBSpeaker) SubscribeToLocalCiliumNodeResource ¶ added in v1.15.0
func (s *MetalLBSpeaker) SubscribeToLocalCiliumNodeResource(ctx context.Context, lcnr agentK8s.LocalCiliumNodeResource)
func (*MetalLBSpeaker) SubscribeToLocalNodeResource ¶ added in v1.15.0
func (s *MetalLBSpeaker) SubscribeToLocalNodeResource(ctx context.Context, lnr agentK8s.LocalNodeResource)
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 // GetBGPController returns the BGPController of the speaker GetBGPController() *metallbspr.BGPController }
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.