feat(cni): replace GoBGP direct calls with BGPVRFInstance CRD#113
Merged
Conversation
Refactor the CNI plugin to manage BGP VRF configuration through Kubernetes CRDs (BGPVRFInstance) instead of calling GoBGP APIs directly, and fix a route distinguisher collision that caused ambiguous BGP advertisements across cluster nodes. - Replace direct GoBGP gRPC calls with BGPVRFInstance create/delete on container ADD/DEL; cosmos reconciles BGP state asynchronously - Switch RD formula from routerID:vrfTableID (Type 1, volatile) to ASN:uint32(vpcHex) (Type 0, stable and globally unique per VPC); eliminates both the per-node collision and the 65535 Type 1 NN wire limit - Remove resolveRouterID and all node-lookup logic from the CNI; routerID is no longer needed for RD computation - Switch containerlab worker BGPInstance manifests (iad/sjc/dfw) from routerIDSource Manual to Auto so each node derives a unique router ID from its IPv6 InternalIP (route reflector unchanged) - Order BGPVRFInstance deletion before local data-plane teardown in cmdDel so BGP withdrawal reaches remote peers before forwarding state is removed - Add unit tests for all CNI helper functions using controller-runtime fake client; no kernel privileges required Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
scotwells
approved these changes
Jun 16, 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
BGPVRFInstanceCRD create/delete; cosmos reconciles BGP state asynchronously, decoupling the CNI from the GoBGP implementationrouterID:vrfTableID(Type 1, shared per-cluster routerID + locally-allocated volatile table ID) toASN:uint32(vpcHex)(Type 0, stable and globally unique per VPC); also eliminates the 65535 Type 1 NN wire limitcmdDel: BGPVRFInstance is deleted immediately afterRouteIngressDelso remote peers receive the withdrawal before local forwarding state is removediad/sjc/dfw) fromrouterIDSource: ManualtoAutoso each node derives a unique router ID from its IPv6 InternalIP (route reflector left unchanged)resolveRouterIDand all node-lookup logic from the CNI; router ID is no longer needed for RD computationparseConf,bgpVRFInstanceName,routeDistinguisher,routeTarget,lookupBGPConfig) usingcontroller-runtimefake client; no kernel privileges requiredBreaking change
Existing
BGPVRFInstanceobjects must be deleted before deploying. The RD changes for every instance (both the formula and the NN component). BGP will withdraw the old RD and advertise the new one after cosmos reconciles; traffic to affected VPCs is interrupted until re-advertisement completes.Test plan
task lint— 0 issuestask test:unit— all tests pass with-raceASN:uint32(vpcHex)RD format🤖 Generated with Claude Code