Skip to content

feat: add BGPVRFInstance CRD support for EVPN VRF configuration#130

Merged
privateip merged 1 commit into
mainfrom
feat/bgp-vrf-instance
Jun 25, 2026
Merged

feat: add BGPVRFInstance CRD support for EVPN VRF configuration#130
privateip merged 1 commit into
mainfrom
feat/bgp-vrf-instance

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Summary

Add support for the BGPVRFInstance CRD, 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 resources
  • internal/controller/indexer.go — index by routerRef.name for router-side lookups
  • internal/controller/status.gosetVRFInstanceCondition helper

CNI: VRF Instance Lifecycle

  • cmdAdd creates BGPVRFInstance (route distinguisher + import/export route targets) before BGPAdvertisement, ensuring the BGP runtime has VRF context when originating EVPN paths
  • cmdDel deletes BGPAdvertisement first (to withdraw prefixes), then BGPVRFInstance

Reconciler & Model

  • BuildDesiredRouter gathers VRF instance from BGPVRFInstance CRDs and populates DesiredRouter.VRFInstance
  • model.DesiredVRFInstance type with name, route distinguisher, and import/export route targets

GoBGP Runtime

  • Apply refactored from a single 135-line monolithic function into 6 focused helpers:
    • startGoBGP — server bootstrapping
    • applyGlobal — ASN/RouterID reconfigure + BGP start
    • applyPeers — peer add/update/delete lifecycle
    • applyVRF — VRF creation + stale VRF cleanup
    • applyEVPN — EVPN path advertisement
    • applyPolicies — policy add/update/delete lifecycle
  • Cyclomatic complexity reduced from 35 → ~8
  • Added appliedVRFs tracking field for stale VRF removal
  • New helper functions: applyVRF, deleteVRF, parseRouteTargetsToAPI

Lint Fixes

  • Extract testVPC/testAttachment constants (goconst: "abc" 3x)
  • Use BGPPeerByRouterName constant instead of hardcoded field path (goconst: 3x)

- 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>
@privateip privateip requested a review from a team as a code owner June 25, 2026 03:03
@privateip privateip requested a review from gaghan430 June 25, 2026 03:03
@privateip privateip merged commit 111b334 into main Jun 25, 2026
5 checks passed
@privateip privateip deleted the feat/bgp-vrf-instance branch June 25, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants