Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBGPControlPlaneDisabled is set when the BGP control plane is disabled
	ErrBGPControlPlaneDisabled = fmt.Errorf("BGP control plane is disabled")
)

Functions

This section is empty.

Types

type BGPRouterManager

type BGPRouterManager interface {
	// ReconcileInstances evaluates the provided CiliumBGPNodeConfig
	// and the implementation will configure itself to apply this configuration.
	ReconcileInstances(ctx context.Context, bgpnc *v2.CiliumBGPNodeConfig, ciliumNode *v2.CiliumNode) error

	// GetPeers fetches peer states for all BGP instances managed by this
	// manager. It returns a mapping of instance name to its peer states.
	GetPeers(ctx context.Context, req *GetPeersRequest) (*GetPeersResponse, error)

	// GetPeersLegacy fetches BGP peering state from underlying routing
	// daemon.
	//
	// List of all peers will be returned and if there are multiple
	// instances of BGP daemon running locally, then peers can be
	// differentiated based on local AS number.
	//
	// Deprecated: This is a legacy method used by the REST API and will be removed in the future.
	GetPeersLegacy(ctx context.Context) ([]*models.BgpPeer, error)

	// GetRoutesLegacy fetches BGP routes from underlying routing daemon's RIBs.
	//
	// Deprecated: This is a legacy method used by the REST API and will be removed in the future.
	GetRoutesLegacy(ctx context.Context, params restapi.GetBgpRoutesParams) ([]*models.BgpRoute, error)

	// GetRoutes fetches BGP routes from underlying routing daemon's RIBs.
	GetRoutes(ctx context.Context, req *GetRoutesRequest) (*GetRoutesResponse, error)

	// GetRoutePolicies fetches BGP routing policies from underlying routing daemon.
	GetRoutePolicies(ctx context.Context, params *GetRoutePoliciesRequest) (*GetRoutePoliciesResponse, error)

	// GetRoutePoliciesLegacy fetches BGP routing policies from underlying routing daemon.
	//
	// Deprecated: This is a legacy method used by the REST API and will be removed in the future.
	GetRoutePoliciesLegacy(ctx context.Context, params restapi.GetBgpRoutePoliciesParams) ([]*models.BgpRoutePolicy, error)

	// Stop will stop all BGP instances and clean up local state.
	Stop(ctx cell.HookContext) error
}

BGPRouterManager provides a declarative API for defining BGP peers.

type Controller

type Controller struct {
	Logger *slog.Logger

	// CiliumNodeResource provides a stream of events for changes to the local CiliumNode resource.
	CiliumNodeResource daemon_k8s.LocalCiliumNodeResource
	// LocalCiliumNode is the CiliumNode object for the local node.
	LocalCiliumNode *v2.CiliumNode

	// BGP node store
	BGPNodeConfigStore store.BGPCPResourceStore[*v2.CiliumBGPNodeConfig]

	// Sig informs the Controller that a Kubernetes
	// event of interest has occurred.
	//
	// The signal itself provides no other information,
	// when it occurs the Controller will query each
	// informer for the latest API information required
	// to drive it's control loop.
	Sig *signaler.BGPCPSignaler

	// BGPMgr is an implementation of the BGPRouterManager interface
	// and provides a declarative API for configuring BGP peers.
	BGPMgr BGPRouterManager
}

Controller is the agent side BGP Control Plane controller.

Controller listens for events and drives BGP related sub-systems to maintain a desired state.

func NewController

func NewController(params ControllerParams) (*Controller, error)

NewController constructs a new BGP Control Plane Controller.

When the constructor returns the Controller will be actively watching for events and configuring BGP related sub-systems.

The constructor requires an implementation of BGPRouterManager to be provided. This implementation defines which BGP backend will be used (GoBGP, FRR, Bird, etc...) NOTE: only GoBGP currently implemented.

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context) error

Reconcile is the main reconciliation loop for the BGP Control Plane Controller.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context)

Run places the Controller into its control loop.

When new events trigger a signal the control loop will be evaluated.

A cancel of the provided ctx will kill the control loop along with the running informers.

type ControllerParams

type ControllerParams struct {
	cell.In

	Logger                  *slog.Logger
	Lifecycle               cell.Lifecycle
	Health                  cell.Health
	JobGroup                job.Group
	Shutdowner              hive.Shutdowner
	Sig                     *signaler.BGPCPSignaler
	RouteMgr                BGPRouterManager
	BGPNodeConfigStore      store.BGPCPResourceStore[*v2.CiliumBGPNodeConfig]
	DaemonConfig            *option.DaemonConfig
	LocalCiliumNodeResource daemon_k8s.LocalCiliumNodeResource
}

ControllerParams contains all parameters needed to construct a Controller

type GetPeersRequest added in v1.19.2

type GetPeersRequest struct{}

GetPeersRequest is a request for GetPeers method.

type GetPeersResponse added in v1.19.2

type GetPeersResponse struct {
	Instances []InstancePeerStates
}

GetPeersResponse is the response type for GetPeers method.

type GetRoutePoliciesRequest added in v1.20.0

type GetRoutePoliciesRequest struct {
	InstanceName string
}

GetRoutePoliciesRequest is a request for GetRoutePolicies method.

type GetRoutePoliciesResponse added in v1.20.0

type GetRoutePoliciesResponse struct {
	Instances []InstanceRoutePolicies
}

GetRoutePoliciesResponse is the response type for GetRoutePolicies method.

type GetRoutesRequest added in v1.19.2

type GetRoutesRequest struct {
	TableType types.TableType
	Family    types.Family
}

GetRoutesRequest is a request for GetRoutes method.

type GetRoutesResponse added in v1.19.2

type GetRoutesResponse struct {
	Instances []InstanceRoutes
}

GetRoutesResponse is the response type for GetRoutes method.

type InstancePeerStates added in v1.19.2

type InstancePeerStates struct {
	Name  string            `json:"name,omitempty"`
	Peers []types.PeerState `json:"peers,omitempty"`
}

InstancePeerStates holds peer states for a specific BGP instance.

type InstanceRoutePolicies added in v1.20.0

type InstanceRoutePolicies struct {
	Name          string
	RoutePolicies []*types.RoutePolicy
}

InstanceRoutePolicies holds route policies for a specific BGP instance.

type InstanceRoutes added in v1.19.2

type InstanceRoutes struct {
	InstanceName string
	NeighborName string
	Routes       []*types.Route
}

InstanceRoutes holds routes for a specific BGP instance.

Directories

Path Synopsis
SPDX-License-Identifier: Apache-2.0 Copyright Authors of Cilium
SPDX-License-Identifier: Apache-2.0 Copyright Authors of Cilium

Jump to

Keyboard shortcuts

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