feat: add BGPVRFInstance CRD support for EVPN VRF configuration#130
Merged
Conversation
- Add BGPVRFInstance controller with status reconciliation - Index BGPVRFInstance by routerRef.name for lookup - CNI creates BGPVRFInstance (with route distinguisher and route targets) before BGPAdvertisement on cmdAdd; deletes both on cmdDel - Reconciler gathers VRF instance into DesiredRouter model - GoBGPRuntime.Apply refactored into focused helpers (startGoBGP, applyGlobal, applyPeers, applyVRF, applyEVPN, applyPolicies), reducing cyclomatic complexity from 35 to ~8 - Add appliedVRFs tracking for stale VRF cleanup - Fix goconst: extract testVPC/testAttachment constants, use BGPPeerByRouterName constant for indexer field lookups Co-Authored-By: Claude <noreply@anthropic.com>
scotwells
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for the
BGPVRFInstanceCRD, enabling per-node VRF configuration in the GoBGP data plane for multi-cloud VPC networking.Changes
New: BGPVRFInstance Controller
internal/controller/bgpvrfinstance_controller.go— reconciler that sets Ready condition on BGPVRFInstance resourcesinternal/controller/indexer.go— index byrouterRef.namefor router-side lookupsinternal/controller/status.go—setVRFInstanceConditionhelperCNI: VRF Instance Lifecycle
cmdAddcreatesBGPVRFInstance(route distinguisher + import/export route targets) beforeBGPAdvertisement, ensuring the BGP runtime has VRF context when originating EVPN pathscmdDeldeletesBGPAdvertisementfirst (to withdraw prefixes), thenBGPVRFInstanceReconciler & Model
BuildDesiredRoutergathers VRF instance fromBGPVRFInstanceCRDs and populatesDesiredRouter.VRFInstancemodel.DesiredVRFInstancetype with name, route distinguisher, and import/export route targetsGoBGP Runtime
Applyrefactored from a single 135-line monolithic function into 6 focused helpers:startGoBGP— server bootstrappingapplyGlobal— ASN/RouterID reconfigure + BGP startapplyPeers— peer add/update/delete lifecycleapplyVRF— VRF creation + stale VRF cleanupapplyEVPN— EVPN path advertisementapplyPolicies— policy add/update/delete lifecycleappliedVRFstracking field for stale VRF removalapplyVRF,deleteVRF,parseRouteTargetsToAPILint Fixes
testVPC/testAttachmentconstants (goconst: "abc" 3x)BGPPeerByRouterNameconstant instead of hardcoded field path (goconst: 3x)