Documentation ¶
Index ¶
- Variables
- func NewBGPRouterManager(params bgpRouterManagerParams) agent.BGPRouterManager
- func NewExportPodCIDRReconciler() exportPodCIDRReconcilerOut
- func NewLBServiceReconciler(diffStore DiffStore[*slim_corev1.Service]) lbServiceReconcilerOut
- func NewNeighborReconciler() neighborReconcilerOut
- func NewPreflightReconciler() preflightReconcilerOut
- type Advertisement
- type BGPRouterManager
- type ConfigReconciler
- type DiffStore
- type ExportPodCIDRReconciler
- type LBServiceReconciler
- type LocalASNMap
- type NeighborReconciler
- type PreflightReconciler
- type ServerLogger
- func (l *ServerLogger) Debug(msg string, fields gobgpLog.Fields)
- func (l *ServerLogger) Error(msg string, fields gobgpLog.Fields)
- func (l *ServerLogger) Fatal(msg string, fields gobgpLog.Fields)
- func (l *ServerLogger) GetLevel() gobgpLog.LogLevel
- func (l *ServerLogger) Info(msg string, fields gobgpLog.Fields)
- func (l *ServerLogger) Panic(msg string, fields gobgpLog.Fields)
- func (l *ServerLogger) SetLevel(level gobgpLog.LogLevel)
- func (l *ServerLogger) Warn(msg string, fields gobgpLog.Fields)
- type ServerWithConfig
- func (sc *ServerWithConfig) AddNeighbor(ctx context.Context, n *v2alpha1api.CiliumBGPNeighbor) error
- func (sc *ServerWithConfig) AdvertisePath(ctx context.Context, ip *net.IPNet) (Advertisement, error)
- func (sc *ServerWithConfig) RemoveNeighbor(ctx context.Context, n *v2alpha1api.CiliumBGPNeighbor) error
- func (sc *ServerWithConfig) WithdrawPath(ctx context.Context, advert Advertisement) error
Constants ¶
This section is empty.
Variables ¶
var ( // GoBGPIPv6Family is a read-only pointer to a gobgp.Family structure // representing IPv6 address family. GoBGPIPv6Family = &gobgp.Family{ Afi: gobgp.Family_AFI_IP6, Safi: gobgp.Family_SAFI_UNICAST, } // GoBGPIPv4Family is a read-only pointer to a gobgp.Family structure // representing IPv4 address family. GoBGPIPv4Family = &gobgp.Family{ Afi: gobgp.Family_AFI_IP, Safi: gobgp.Family_SAFI_UNICAST, } )
var ConfigReconcilers = cell.ProvidePrivate( NewPreflightReconciler, NewNeighborReconciler, NewExportPodCIDRReconciler, NewLBServiceReconciler, )
Functions ¶
func NewBGPRouterManager ¶
func NewBGPRouterManager(params bgpRouterManagerParams) agent.BGPRouterManager
NewBGPRouterManager constructs a GoBGP-backed BGPRouterManager.
See NewBGPRouterManager for details.
func NewExportPodCIDRReconciler ¶
func NewExportPodCIDRReconciler() exportPodCIDRReconcilerOut
func NewLBServiceReconciler ¶
func NewLBServiceReconciler(diffStore DiffStore[*slim_corev1.Service]) lbServiceReconcilerOut
func NewNeighborReconciler ¶
func NewNeighborReconciler() neighborReconcilerOut
func NewPreflightReconciler ¶
func NewPreflightReconciler() preflightReconcilerOut
Types ¶
type Advertisement ¶
Advertisement is a container object which associates a net.IPNet with a gobgp.Path.
The `Net` field makes comparing this Advertisement with another IPNet encoded prefixes simple.
The `Path` field is a gobgp.Path object which can be forwarded to our server's WithdrawPath method, making withdrawing an advertised route simple.
type BGPRouterManager ¶
type BGPRouterManager struct { Servers LocalASNMap Reconcilers []ConfigReconciler }
BGPRouterManager implements the pkg.bgpv1.agent.BGPRouterManager interface.
This BGPRouterMananger utilizes the gobgp project to implement a BGP routing plane.
Logically, this manager views each CiliumBGPVirtualRouter within a CiliumBGPPeeringPolicy as a BGP router instantiated on its host.
BGP routers are grouped and accessed by their local ASNs, thus this backend mandates that each CiliumBGPPeeringConfig have a unique local ASN and precludes a single host instantiating two routers with the same local ASN.
This manager employs two main data structures to implement its high level business logic.
A reconcilerDiff is used to establish which BgpServers must be created, and removed from the Mananger along with which servers must have their configurations reconciled.
A set of ReconcilerConfigFunc(s), which usages are wrapped by the ReconcileBGPConfig function, reconcile individual features of a CiliumBGPPeeringConfig.
Together, the high-level flow the manager takes is:
- Instantiate a reconcilerDiff to compute which BgpServers to create, remove, and reconcile
- Create any BgpServers necessary, run ReconcilerConfigFuncs(s) on each
- Run each ReconcilerConfigFunc, by way of ReconcileBGPConfig, on any BgpServers marked for reconcile
BgpServers are abstracted by the ServerWithConfig structure which provides a method set for low-level BGP operations.
func (*BGPRouterManager) ConfigurePeers ¶
func (m *BGPRouterManager) ConfigurePeers(ctx context.Context, policy *v2alpha1api.CiliumBGPPeeringPolicy, cstate *agent.ControlPlaneState) error
ConfigurePeers is a declarative API for configuring the BGP peering topology given a desired CiliumBGPPeeringPolicy.
ConfigurePeers will evaluate BGPRouterManager's current state and the desired CiliumBGPPeeringPolicy policy then take the necessary actions to apply the provided policy. For more details see BGPRouterManager's comments.
ConfigurePeers should return only once a subsequent invocation is safe. This method is not thread safe and does not intend to be called concurrently.
type ConfigReconciler ¶
type ConfigReconciler interface { // Priority is used to determine the order in which reconcilers are called. Reconcilers are called from lowest to // highest. Priority() int // If the `Config` field in `sc` is nil the reconciler should unconditionally // perform the reconciliation actions, as no previous configuration is present. Reconcile(ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState) error }
ConfigReconciler is a interface for reconciling a particular aspect of an old and new *v2alpha1api.CiliumBGPVirtualRouter
type DiffStore ¶
type DiffStore[T k8sRuntime.Object] interface { resource.Store[T] // Diff returns a list of items that have been upserted(updated or inserted) and deleted since the last call to Diff. Diff() (upserted []T, deleted []resource.Key, err error) }
DiffStore is a super set of the resource.Store. The diffStore tracks all changes made to it since the last time the user synced up. This allows a user to get a list of just the changed objects while still being able to query the full store for a full sync.
func NewDiffStore ¶
func NewDiffStore[T k8sRuntime.Object](params diffStoreParams[T]) DiffStore[T]
type ExportPodCIDRReconciler ¶
type ExportPodCIDRReconciler struct{}
func (*ExportPodCIDRReconciler) Priority ¶
func (r *ExportPodCIDRReconciler) Priority() int
func (*ExportPodCIDRReconciler) Reconcile ¶
func (r *ExportPodCIDRReconciler) Reconcile(ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState) error
type LBServiceReconciler ¶
type LBServiceReconciler struct {
// contains filtered or unexported fields
}
func (*LBServiceReconciler) Priority ¶
func (r *LBServiceReconciler) Priority() int
func (*LBServiceReconciler) Reconcile ¶
func (r *LBServiceReconciler) Reconcile( ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState, ) error
type LocalASNMap ¶
type LocalASNMap map[int]*ServerWithConfig
LocalASNMap maps local ASNs to their associated BgpServers and server configuration info.
type NeighborReconciler ¶
type NeighborReconciler struct{}
func (*NeighborReconciler) Priority ¶
func (r *NeighborReconciler) Priority() int
func (*NeighborReconciler) Reconcile ¶
func (r *NeighborReconciler) Reconcile(ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState) error
type PreflightReconciler ¶
type PreflightReconciler struct{}
func (*PreflightReconciler) Priority ¶
func (r *PreflightReconciler) Priority() int
func (*PreflightReconciler) Reconcile ¶
func (r *PreflightReconciler) Reconcile(ctx context.Context, m *BGPRouterManager, sc *ServerWithConfig, newc *v2alpha1api.CiliumBGPVirtualRouter, cstate *agent.ControlPlaneState) error
type ServerLogger ¶
type ServerLogger struct {
// contains filtered or unexported fields
}
implement github.com/osrg/gobgp/v3/pkg/log/Logger interface
func NewServerLogger ¶
func NewServerLogger(l *logrus.Logger, asn uint32) *ServerLogger
func (*ServerLogger) GetLevel ¶
func (l *ServerLogger) GetLevel() gobgpLog.LogLevel
func (*ServerLogger) SetLevel ¶
func (l *ServerLogger) SetLevel(level gobgpLog.LogLevel)
type ServerWithConfig ¶
type ServerWithConfig struct { // a gobgp backed BgpServer configured in accordance to the accompanying // CiliumBGPVirtualRouter configuration. Server *server.BgpServer // The CiliumBGPVirtualRouter configuration which drives the configuration // of the above BgpServer. // // If this field is nil it means the above BgpServer has had no // configuration applied to it. Config *v2alpha1api.CiliumBGPVirtualRouter // Holds any announced PodCIDR routes. PodCIDRAnnouncements []Advertisement // Holds any announced Service routes. ServiceAnnouncements map[resource.Key][]Advertisement }
ServerWithConfig is a container for grouping a gobgp BgpServer with the Cilium's BGP control plane related configuration.
It exports a method set for manipulating the BgpServer. However, this struct is a dumb object. The calling code is required to keep the BgpServer's configuration and associated configuration fields in sync.
func NewServerWithConfig ¶
func NewServerWithConfig(ctx context.Context, startReq *gobgp.StartBgpRequest) (*ServerWithConfig, error)
NewServerWithConfig will start an underlying BgpServer utilizing startReq for its initial configuration.
The returned ServerWithConfig has a nil CiliumBGPVirtualRouter config, and is ready to be provided to ReconcileBGPConfig.
Canceling the provided context will kill the BgpServer along with calling the underlying BgpServer's Stop() method.
func (*ServerWithConfig) AddNeighbor ¶
func (sc *ServerWithConfig) AddNeighbor(ctx context.Context, n *v2alpha1api.CiliumBGPNeighbor) error
AddNeighbor will add the CiliumBGPNeighbor to the gobgp.BgpServer, creating a BGP peering connection.
func (*ServerWithConfig) AdvertisePath ¶
func (sc *ServerWithConfig) AdvertisePath(ctx context.Context, ip *net.IPNet) (Advertisement, error)
AdvertisePath will advertise the provided IP network to any existing and all subsequently added Neighbors currently peered with this BgpServer.
`ip` can be an ipv4 or ipv6 and this method will handle the differences between MP BGP and BGP.
It is an error to advertise an IPv6 path when no IPv6 address is configured on this Cilium node, selfsame for IPv4.
Nexthop of the path will always set to "0.0.0.0" in IPv4 and "::" in IPv6, so that GoBGP selects appropriate actual nexthop address and advertise it.
An Advertisement is returned which may be passed to WithdrawPath to remove this Advertisement.
func (*ServerWithConfig) RemoveNeighbor ¶
func (sc *ServerWithConfig) RemoveNeighbor(ctx context.Context, n *v2alpha1api.CiliumBGPNeighbor) error
RemoveNeighbor will remove the CiliumBGPNeighbor from the gobgp.BgpServer, disconnecting the BGP peering connection.
func (*ServerWithConfig) WithdrawPath ¶
func (sc *ServerWithConfig) WithdrawPath(ctx context.Context, advert Advertisement) error
WithdrawPath withdraws an Advertisement produced by AdvertisePath from this BgpServer.