Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMultiplePolicies is a static error typed when the controller encounters // multiple policies which apply to its host. ErrMultiplePolicies = fmt.Errorf("more then one CiliumBGPPeeringPolicy applies to this node, please ensure only a single Policy matches this node's labels") )
Functions ¶
func PolicySelection ¶
func PolicySelection(ctx context.Context, node *corev1.Node, policies []*v2alpha1api.CiliumBGPPeeringPolicy) (*v2alpha1api.CiliumBGPPeeringPolicy, error)
PolicySelection returns a CiliumBGPPeeringPolicy which applies to the provided *corev1.Node, enforced by a set of policy selection rules.
Policy selection follows the following rules:
- A policy matches a node if said policy's "nodeSelector" field matches the node's
- If (N > 1) policies match the provided *corev1.Node an error is returned. only a single policy may apply to a node to avoid ambiguity at this stage of development.
Types ¶
type BGPRouterManager ¶
type BGPRouterManager interface { // ConfigurePeers evaluates the provided CiliumBGPPeeringPolicy // and the implementation will configure itself to apply this policy. // // A ControllerState structure is provided which captures Cilium's runtime // state at the time of this method's invocation. It must remain read-only. // // ConfigurePeers should block until it can ensure a subsequent call // to ConfigurePeers can occur without conflict. // // ConfigurePeers should not be called concurrently and expects invocations // to be serialized contingent to the method's completion. // // An error is returned only when the implementation can determine a // critical flaw with the peering policy, not when network connectivity // is an issue. // // Providing a nil policy to ConfigurePeers will withdrawal all routes // and disconnect from the peers. ConfigurePeers(ctx context.Context, policy *v2alpha1api.CiliumBGPPeeringPolicy, state *ControlPlaneState) error }
BGPRouterManager provides a declarative API for defining BGP peers.
type ControlPlaneState ¶ added in v1.12.0
type ControlPlaneState struct { // The Kubernetes Node resource at time of construction. Node *corev1.Node // Parsed 'cilium.io/bgp-virtual-router' annotations of the the node this // control plane is running on. Annotations bgpv1.AnnotationMap // The current IPv4 address of the agent, reachable externally. IPv4 net.IP // The current IPv6 address of the agent, reachable externally. IPv6 net.IP }
ControlPlaneState captures a subset of Cilium's runtime state.
This state carries information interesting to various BGP sub-systems and provides a contract for information a sub-system will be provided about Cilium's runtime state.
ControlPlaneState should be a point-in-time snapshot of Cilium's runtime state and remain read-only to all sub systems its passed to.
type Controller ¶
type Controller struct { // NOTE: Swap the usage of Node here to CiliumNode // once #18609 merges // // NodeInformer is a shared informer for Node // resources NodeInformer cache.SharedIndexInformer // NodeLister provides cached and indexed lookups for // Node API objects. NodeLister v1.NodeLister // BGPPolicyInformer is a shared informer for CiliumBGPPeerinPolicy BGPPolicyInformer cache.SharedIndexInformer // PolicyLister provides cached and indexed lookups of // for CilumBGPPeeringPolicy API objects. PolicyLister v2alpha1.CiliumBGPPeeringPolicyLister // 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 // 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(ctx context.Context, rtMgr BGPRouterManager, opts ...ControllerOpt) (*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.
Cancel the provided CTX to stop the Controller.
func (*Controller) FullWithdrawal ¶
func (c *Controller) FullWithdrawal(ctx context.Context)
FullWithdrawal will instruct the configured BGPRouterManager to withdraw all BGP servers and peers.
func (*Controller) Reconcile ¶
func (c *Controller) Reconcile(ctx context.Context) error
Reconcile is the control loop for the Controller.
Reconcile will be invoked when one or more event sources trigger a signal via the Controller's Signaler structure.
On signal, Reconcile will obtain the state of the world necessary to drive the BGP control plane toward any new BGP peering policies.
Reconcile will only allow a single CiliumBGPPeeringPolicy to apply to the node its running on.
func (*Controller) Run ¶
func (c *Controller) Run(ctx context.Context)
Run places the Controller into its control loop.
Kubernetes shared informers are started just before entering the long running 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 ControllerOpt ¶ added in v1.12.0
type ControllerOpt func(*Controller)
ControllerOpt is a signature for defining configurable options for a Controller
type Signaler ¶ added in v1.12.0
type Signaler struct {
Sig chan struct{}
}
Signaler multiplexes multiple event sources into a single level-triggered event.
Signaler should always be constructed with a channel of size 1.
Use of a Signaler allows for bursts of events to be "rolled-up". This is a suitable approach since the Controller checks the entire state of the world on each iteration of its control loop.
Additionally, this precludes any need for ordering between different event sources.
func (Signaler) Event ¶ added in v1.12.0
func (s Signaler) Event(_ interface{})
Event adds an edge triggered event to the Signaler.
A controller which uses this Signaler will be notified of this event some time after.
This signature adheres to the common event handling signatures of cache.ResourceEventHandlerFuncs for convenience.