reconcilerv2

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPrefixLenIPv4 = 32
	MaxPrefixLenIPv6 = 128
)
View Source
const (
	CRDStatusUpdateInterval = 5 * time.Second
)

Variables

View Source
var StateReconcilers = cell.ProvidePrivate(
	NewStatusReconciler,
)

Functions

func CreatePolicy

func CreatePolicy(name string, peerAddr netip.Addr, v4Prefixes, v6Prefixes types.PolicyPrefixMatchList, advert v2alpha1.BGPAdvertisement) (*types.RoutePolicy, error)

func FamilyAdvertisementsEqual

func FamilyAdvertisementsEqual(first, second PeerFamilyAdvertisements) bool

func GetPeerAddressFromConfig

func GetPeerAddressFromConfig(conf *v2alpha1.CiliumBGPNodeInstance, peerName string) (netip.Addr, error)

func PeerAdvertisementsEqual

func PeerAdvertisementsEqual(first, second PeerAdvertisements) bool

func PolicyName

func PolicyName(peer, family string, advertType v2alpha1.BGPAdvertisementType, resourceID string) string

PolicyName returns a unique route policy name for the provided peer, family and advertisement type. If there a is a need for multiple route policies per advertisement type, unique resourceID can be provided.

Types

type AFPathsMap

type AFPathsMap map[types.Family]PathMap

AFPathsMap is a map of paths per address family, indexed by the family

func ReconcileAFPaths

func ReconcileAFPaths(rp *ReconcileAFPathsParams) (AFPathsMap, error)

ReconcileAFPaths reconciles BGP advertisements per address family. It will consume desired and current paths (AFPathsMap) and will return the outcome of the reconciliation.

type CiliumPeerAdvertisement

type CiliumPeerAdvertisement struct {
	// contains filtered or unexported fields
}

func (*CiliumPeerAdvertisement) GetConfiguredAdvertisements

func (p *CiliumPeerAdvertisement) GetConfiguredAdvertisements(conf *v2alpha1.CiliumBGPNodeInstance, selectAdvertTypes ...v2alpha1.BGPAdvertisementType) (PeerAdvertisements, error)

GetConfiguredAdvertisements can be called to get all configured advertisements of given BGPAdvertisementType for each peer. Advertisements are selected based on below criteria: Each peer is selected from the BGP node instance configuration. For each peer, the peer configuration is fetched from local store. Peer configuration contains the list of families and the advertisement selector. We iterate over all advertisements ( available from local store ), select only those that match the advertisement selector of the family. Information of peer -> family -> advertisements is returned to the consumer. Linear scan [ Peers ] - O(n) ( number of peers ) Linear scan [ Families ] - O(m) ( max 2 ) Linear scan [ Advertisements ] - O(k) ( number of advertisements - 3-4 types, which is again filtered)

type ConfigReconciler

type ConfigReconciler interface {
	// Name returns the name of a reconciler.
	Name() string
	// Priority is used to determine the order in which reconcilers are called. Reconcilers are called from lowest to
	// highest.
	Priority() int
	// Init is called upon virtual router instance creation. Reconcilers can initialize any instance-specific
	// resources here, and clean them up upon Cleanup call.
	Init(i *instance.BGPInstance) error
	// Cleanup is called upon virtual router instance deletion. When called, reconcilers are supposed
	// to clean up all instance-specific resources saved outside the instance Metadata.
	Cleanup(i *instance.BGPInstance)
	// Reconcile performs the reconciliation actions for given BGPInstance.
	Reconcile(ctx context.Context, params ReconcileParams) error
}

func GetActiveReconcilers

func GetActiveReconcilers(log logrus.FieldLogger, reconcilers []ConfigReconciler) []ConfigReconciler

GetActiveReconcilers returns a list of reconcilers in order of priority that should be used to reconcile the BGP config.

type NeighborReconciler

type NeighborReconciler struct {
	Logger       logrus.FieldLogger
	SecretStore  store.BGPCPResourceStore[*slim_corev1.Secret]
	PeerConfig   store.BGPCPResourceStore[*v2alpha1.CiliumBGPPeerConfig]
	DaemonConfig *option.DaemonConfig
}

NeighborReconciler is a ConfigReconciler which reconciles the peers of the provided BGP server with the provided CiliumBGPVirtualRouter.

func (*NeighborReconciler) Cleanup added in v1.16.1

func (r *NeighborReconciler) Cleanup(_ *instance.BGPInstance)

func (*NeighborReconciler) Init added in v1.16.1

func (*NeighborReconciler) Name

func (r *NeighborReconciler) Name() string

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

type NeighborReconcilerIn

type NeighborReconcilerIn struct {
	cell.In
	Logger       logrus.FieldLogger
	SecretStore  store.BGPCPResourceStore[*slim_corev1.Secret]
	PeerConfig   store.BGPCPResourceStore[*v2alpha1.CiliumBGPPeerConfig]
	DaemonConfig *option.DaemonConfig
}

type NeighborReconcilerMetadata

type NeighborReconcilerMetadata map[string][]*PeerData

NeighborReconcilerMetadata keeps a map of running peers to peer configuration. key is the peer name.

type NeighborReconcilerOut

type NeighborReconcilerOut struct {
	cell.Out

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

func NewNeighborReconciler

func NewNeighborReconciler(params NeighborReconcilerIn) NeighborReconcilerOut

type PathMap

type PathMap map[string]*types.Path

PathMap is a map of paths indexed by the NLRI string

type PeerAdvertisements

type PeerAdvertisements map[string]PeerFamilyAdvertisements

PeerAdvertisements is a map of peer name to its family advertisements This is the top level map that is returned to the consumer with requested advertisements.

type PeerData

type PeerData struct {
	Peer     *v2alpha1.CiliumBGPNodePeer
	Config   *v2alpha1.CiliumBGPPeerConfigSpec
	Password string
}

PeerData keeps a peer and its configuration. It also keeps the TCP password from secret store. +deepequal-gen=true Note: If you change PeerDate, do not forget to 'make generate-k8s-api', which will update DeepEqual method.

func (*PeerData) DeepEqual

func (in *PeerData) DeepEqual(other *PeerData) bool

DeepEqual is an autogenerated deepequal function, deeply comparing the receiver with other. in must be non-nil.

type PeerFamilyAdvertisements

type PeerFamilyAdvertisements map[v2alpha1.CiliumBGPFamily][]v2alpha1.BGPAdvertisement // key is the address family type

type PodCIDRReconciler

type PodCIDRReconciler struct {
	// contains filtered or unexported fields
}

func (*PodCIDRReconciler) Cleanup added in v1.16.1

func (r *PodCIDRReconciler) Cleanup(_ *instance.BGPInstance)

func (*PodCIDRReconciler) Init added in v1.16.1

func (*PodCIDRReconciler) Name

func (r *PodCIDRReconciler) Name() string

func (*PodCIDRReconciler) Priority

func (r *PodCIDRReconciler) Priority() int

func (*PodCIDRReconciler) Reconcile

func (r *PodCIDRReconciler) Reconcile(ctx context.Context, p ReconcileParams) error

type PodCIDRReconcilerIn

type PodCIDRReconcilerIn struct {
	cell.In

	Logger       logrus.FieldLogger
	PeerAdvert   *CiliumPeerAdvertisement
	DaemonConfig *option.DaemonConfig
}

type PodCIDRReconcilerMetadata

type PodCIDRReconcilerMetadata struct {
	AFPaths       AFPathsMap
	RoutePolicies RoutePolicyMap
}

PodCIDRReconcilerMetadata is a map of advertisements per family, key is family type

type PodCIDRReconcilerOut

type PodCIDRReconcilerOut struct {
	cell.Out

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

func NewPodCIDRReconciler

func NewPodCIDRReconciler(params PodCIDRReconcilerIn) PodCIDRReconcilerOut

type PodIPPoolReconciler

type PodIPPoolReconciler struct {
	// contains filtered or unexported fields
}

func (*PodIPPoolReconciler) Cleanup added in v1.16.1

func (r *PodIPPoolReconciler) Cleanup(_ *instance.BGPInstance)

func (*PodIPPoolReconciler) Init added in v1.16.1

func (*PodIPPoolReconciler) Name

func (r *PodIPPoolReconciler) Name() string

func (*PodIPPoolReconciler) Priority

func (r *PodIPPoolReconciler) Priority() int

func (*PodIPPoolReconciler) Reconcile

type PodIPPoolReconcilerIn

type PodIPPoolReconcilerIn struct {
	cell.In

	Logger     logrus.FieldLogger
	PeerAdvert *CiliumPeerAdvertisement
	PoolStore  store.BGPCPResourceStore[*v2alpha1.CiliumPodIPPool]
}

type PodIPPoolReconcilerMetadata

type PodIPPoolReconcilerMetadata struct {
	PoolAFPaths       ResourceAFPathsMap
	PoolRoutePolicies ResourceRoutePolicyMap
}

PodIPPoolReconcilerMetadata holds any announced pod ip pool CIDRs keyed by pool name of the backing CiliumPodIPPool.

type PodIPPoolReconcilerOut

type PodIPPoolReconcilerOut struct {
	cell.Out

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

type PreflightReconciler

type PreflightReconciler struct {
	Logger logrus.FieldLogger
}

PreflightReconciler reconciles BPG Global configuration. This reconciler is similar to v1 preflight reconciler. It must be run before any other reconcilers for given BGP instance.

func (*PreflightReconciler) Cleanup added in v1.16.1

func (r *PreflightReconciler) Cleanup(_ *instance.BGPInstance)

func (*PreflightReconciler) Init added in v1.16.1

func (*PreflightReconciler) Name

func (r *PreflightReconciler) Name() string

func (*PreflightReconciler) Priority

func (r *PreflightReconciler) Priority() int

func (*PreflightReconciler) Reconcile

type PreflightReconcilerIn

type PreflightReconcilerIn struct {
	cell.In

	Logger logrus.FieldLogger
}

type PreflightReconcilerOut

type PreflightReconcilerOut struct {
	cell.Out

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

func NewPreflightReconciler

func NewPreflightReconciler(params PreflightReconcilerIn) PreflightReconcilerOut

type ReconcileAFPathsParams

type ReconcileAFPathsParams struct {
	Logger       logrus.FieldLogger
	Ctx          context.Context
	Router       types.Router
	DesiredPaths AFPathsMap
	CurrentPaths AFPathsMap
}

type ReconcileParams

type ReconcileParams struct {
	BGPInstance   *instance.BGPInstance
	DesiredConfig *v2alpha1.CiliumBGPNodeInstance
	CiliumNode    *v2api.CiliumNode
}

type ReconcileRoutePoliciesParams

type ReconcileRoutePoliciesParams struct {
	Logger          logrus.FieldLogger
	Ctx             context.Context
	Router          types.Router
	DesiredPolicies RoutePolicyMap
	CurrentPolicies RoutePolicyMap
}

type ResourceAFPathsMap

type ResourceAFPathsMap map[resource.Key]AFPathsMap

ResourceAFPathsMap holds the AF paths keyed by the resource name.

type ResourceRoutePolicyMap

type ResourceRoutePolicyMap map[resource.Key]RoutePolicyMap

ResourceRoutePolicyMap holds the route policies per resource.

type RoutePolicyMap

type RoutePolicyMap map[string]*types.RoutePolicy

RoutePolicyMap holds routing policies configured by the policy reconciler keyed by policy name.

func ReconcileRoutePolicies

func ReconcileRoutePolicies(rp *ReconcileRoutePoliciesParams) (RoutePolicyMap, error)

ReconcileRoutePolicies reconciles routing policies between the desired and the current state. It returns the updated routing policies and an error if the reconciliation fails.

type ServiceReconciler

type ServiceReconciler struct {
	// contains filtered or unexported fields
}

func (*ServiceReconciler) Cleanup added in v1.16.1

func (r *ServiceReconciler) Cleanup(i *instance.BGPInstance)

func (*ServiceReconciler) Init added in v1.16.1

func (*ServiceReconciler) Name

func (r *ServiceReconciler) Name() string

func (*ServiceReconciler) Priority

func (r *ServiceReconciler) Priority() int

func (*ServiceReconciler) Reconcile

func (r *ServiceReconciler) Reconcile(ctx context.Context, p ReconcileParams) error

type ServiceReconcilerIn

type ServiceReconcilerIn struct {
	cell.In

	Logger       logrus.FieldLogger
	PeerAdvert   *CiliumPeerAdvertisement
	SvcDiffStore store.DiffStore[*slim_corev1.Service]
	EPDiffStore  store.DiffStore[*k8s.Endpoints]
}

type ServiceReconcilerMetadata

type ServiceReconcilerMetadata struct {
	ServicePaths          ResourceAFPathsMap
	ServiceAdvertisements PeerAdvertisements
	ServiceRoutePolicies  ResourceRoutePolicyMap
}

ServiceReconcilerMetadata holds any announced service CIDRs per address family.

type ServiceReconcilerOut

type ServiceReconcilerOut struct {
	cell.Out

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

type StateReconcileParams added in v1.16.2

type StateReconcileParams struct {
	// ConfigMode is the current configuration mode of BGP control plane
	// This is required by some reconcilers to determine if they need to run or not.
	ConfigMode *mode.ConfigMode

	// UpdatedInstance is the BGP instance that is being updated.
	UpdatedInstance *instance.BGPInstance

	// DeletedInstance is the BGP instance that is already deleted.
	DeletedInstance string
}

type StateReconciler added in v1.16.2

type StateReconciler interface {
	Name() string
	Priority() int
	Reconcile(ctx context.Context, params StateReconcileParams) error
}

func GetActiveStateReconcilers added in v1.16.2

func GetActiveStateReconcilers(log logrus.FieldLogger, reconcilers []StateReconciler) []StateReconciler

type StatusReconciler added in v1.16.2

type StatusReconciler struct {
	lock.Mutex

	Logger            logrus.FieldLogger
	ClientSet         k8s_client.Clientset
	LocalNodeResource daemon_k8s.LocalCiliumNodeResource
	// contains filtered or unexported fields
}

func (*StatusReconciler) Name added in v1.16.2

func (r *StatusReconciler) Name() string

func (*StatusReconciler) Priority added in v1.16.2

func (r *StatusReconciler) Priority() int

func (*StatusReconciler) Reconcile added in v1.16.2

func (r *StatusReconciler) Reconcile(ctx context.Context, params StateReconcileParams) error

type StatusReconcilerIn added in v1.16.2

type StatusReconcilerIn struct {
	cell.In

	Job       job.Group
	ClientSet k8s_client.Clientset
	Logger    logrus.FieldLogger
	LocalNode daemon_k8s.LocalCiliumNodeResource
}

type StatusReconcilerOut added in v1.16.2

type StatusReconcilerOut struct {
	cell.Out

	Reconciler StateReconciler `group:"bgp-state-reconciler-v2"`
}

func NewStatusReconciler added in v1.16.2

func NewStatusReconciler(in StatusReconcilerIn) StatusReconcilerOut

Jump to

Keyboard shortcuts

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