manager

package
v1.14.8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewBGPRouterManager

func NewBGPRouterManager(params bgpRouterManagerParams) agent.BGPRouterManager

NewBGPRouterManager constructs a GoBGP-backed BGPRouterManager.

See BGPRouterManager for details.

Types

type BGPRouterManager

type BGPRouterManager struct {
	lock.RWMutex
	Servers     LocalASNMap
	Reconcilers []ConfigReconciler
	// contains filtered or unexported fields
}

BGPRouterManager implements the pkg.bgpv1.agent.BGPRouterManager interface.

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 Manager 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

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.

func (*BGPRouterManager) GetPeers

func (m *BGPRouterManager) GetPeers(ctx context.Context) ([]*models.BgpPeer, error)

GetPeers gets peering state from previously initialized bgp instances.

func (*BGPRouterManager) GetRoutes

GetRoutes retrieves routes from the RIB of underlying router

func (*BGPRouterManager) Stop

func (m *BGPRouterManager) Stop()

Stop cleans up all servers, should be called at shutdown

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
	// Reconcile If the `Config` field in `params.sc` is nil the reconciler should unconditionally
	// perform the reconciliation actions, as no previous configuration is present.
	Reconcile(ctx context.Context, params ReconcileParams) 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, params ReconcileParams) error

type ExportPodCIDRReconcilerOut

type ExportPodCIDRReconcilerOut struct {
	cell.Out

	Reconciler ConfigReconciler `group:"bgp-config-reconciler"`
}

func NewExportPodCIDRReconciler

func NewExportPodCIDRReconciler() ExportPodCIDRReconcilerOut

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, params ReconcileParams) error

type LBServiceReconcilerOut

type LBServiceReconcilerOut struct {
	cell.Out

	Reconciler ConfigReconciler `group:"bgp-config-reconciler"`
}

func NewLBServiceReconciler

func NewLBServiceReconciler(diffStore DiffStore[*slim_corev1.Service], epDiffStore DiffStore[*k8s.Endpoints]) LBServiceReconcilerOut

type LocalASNMap

type LocalASNMap map[int64]*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

Priority of neighbor reconciler is higher than pod/service announcements. This is important for graceful restart case, where all expected routes are pushed into gobgp RIB before neighbors are added. So, gobgp can send out all prefixes within initial update message exchange with neighbors before sending EOR marker.

func (*NeighborReconciler) Reconcile

func (r *NeighborReconciler) Reconcile(ctx context.Context, params ReconcileParams) error

Reconcile reconciles the peers of the provided BGP server with the provided CiliumBGPVirtualRouter.

type NeighborReconcilerMetadata added in v1.14.8

type NeighborReconcilerMetadata map[string]neighborReconcilerMetadata

NeighborReconcilerMetadata keeps a map of peers to passwords, fetched from secrets. Key is PeerAddress+PeerASN.

type NeighborReconcilerOut

type NeighborReconcilerOut struct {
	cell.Out

	Reconciler ConfigReconciler `group:"bgp-config-reconciler"`
}

func NewNeighborReconciler

func NewNeighborReconciler() NeighborReconcilerOut

type PreflightReconciler

type PreflightReconciler struct{}

func (*PreflightReconciler) Priority

func (r *PreflightReconciler) Priority() int

func (*PreflightReconciler) Reconcile

func (r *PreflightReconciler) Reconcile(ctx context.Context, params ReconcileParams) error

type PreflightReconcilerOut

type PreflightReconcilerOut struct {
	cell.Out

	Reconciler ConfigReconciler `group:"bgp-config-reconciler"`
}

func NewPreflightReconciler

func NewPreflightReconciler() PreflightReconcilerOut

type ReconcileParams

type ReconcileParams struct {
	Server *ServerWithConfig
	NewC   *v2alpha1api.CiliumBGPVirtualRouter
	CState *agent.ControlPlaneState
}

type ServerWithConfig

type ServerWithConfig struct {
	// backed BgpServer configured in accordance to the accompanying
	// CiliumBGPVirtualRouter configuration.
	Server types.Router

	// 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 []types.Advertisement

	// Holds any announced Service routes.
	ServiceAnnouncements map[resource.Key][]types.Advertisement

	// Holds neighbor metadata
	NeighborReconcilerMetadata NeighborReconcilerMetadata
}

ServerWithConfig is a container for providing interface with underlying router implementation and 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, params types.ServerParameters, cstate *agent.ControlPlaneState) (*ServerWithConfig, error)

NewServerWithConfig will start an underlying BgpServer utilizing types.ServerParameters 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.

Jump to

Keyboard shortcuts

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