Skip to content

Latest commit

 

History

History
157 lines (123 loc) · 10 KB

README.md

File metadata and controls

157 lines (123 loc) · 10 KB

OPI gRPC to EVPN GW FRR bridge

Linters CodeQL OpenSSF Scorecard tests Docker License codecov Go Report Card Go Doc Pulls Last Release GitHub stars GitHub Contributors

This repo includes OPI reference code for EVPN Gateway based on FRR. The specification for these APIs can be found here.

I Want To Contribute

This project welcomes contributions and suggestions. We are happy to have the Community involved via submission of Issues and Pull Requests (with substantive content or even just fixes). We are hoping for the documents, test framework, etc. to become a community process with active engagement. PRs can be reviewed by by any number of people, and a maintainer may accept.

See CONTRIBUTING and GitHub Basic Process for more details.

Getting started

docker-compose is deprecated. For details, see Migrate to Compose V2.

Run docker-compose up -d or docker compose up -d

Manual gRPC example

using grpcurl

# create
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"vrf" : {"spec" : {"vni" : 1234, "loopback_ip_prefix" : {"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24}, "vtep_ip_prefix": {"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24} }}, "vrf_id" : "testvrf" }' localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.CreateVrf"
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"logical_bridge" : {"spec" : {"vni": 10, "vlan_id": 10 } }, "logical_bridge_id" : "testbridge" }' localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.CreateLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"bridge_port" : {"spec" : {mac_address: "qrvMAAAB", "ptype": "BRIDGE_PORT_TYPE_ACCESS", "logical_bridges": ["//network.opiproject.org/bridges/testbridge"] }}, "bridge_port_id" : "testport"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.CreateBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"svi" : {"spec" : {"vrf": "//network.opiproject.org/vrfs/testvrf", "logical_bridge": "//network.opiproject.org/bridges/testbridge", mac_address: "qrvMAAAB", "gw_ip_prefix": [{"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24}] } }, "svi_id" : "testsvi" }' localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.CreateSvi
# get
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/ports/testinterface"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.GetBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/bridges/testbridge"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.GetLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/svis/testsvi"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.GetSvi
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/vrfs/testvrf"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.GetVrf
#list
docker-compose exec opi-evpn-bridge grpcurl -plaintext localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.ListBridgePorts
docker-compose exec opi-evpn-bridge grpcurl -plaintext localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.ListLogicalBridges
docker-compose exec opi-evpn-bridge grpcurl -plaintext localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.ListSvis
docker-compose exec opi-evpn-bridge grpcurl -plaintext localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.ListVrfs
# delete
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/ports/testinterface"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.DeleteBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/bridges/testbridge"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.DeleteLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name" : "//network.opiproject.org/svis/testsvi"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.DeleteSvi
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name" : "//network.opiproject.org/vrfs/testvrf"}' localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.DeleteVrf

using grpc_cli

$ docker run --rm -it --network=container:opi-evpn-bridge-opi-evpn-bridge-1 docker.io/namely/grpc-cli ls localhost:50151
grpc.reflection.v1.ServerReflection
grpc.reflection.v1alpha.ServerReflection
opi_api.network.evpn_gw.v1alpha1.BridgePortService
opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService
opi_api.network.evpn_gw.v1alpha1.SviService
opi_api.network.evpn_gw.v1alpha1.VrfService

$ docker run --rm -it --network=container:opi-evpn-bridge-opi-evpn-bridge-1 docker.io/namely/grpc-cli call localhost:50151 VrfService.ListVrfs ""
connecting to localhost:50151
...
Rpc succeeded with OK status

using godpu

$ docker run --rm -it --network=host docker.io/opiproject/godpu:main evpn --help
Tests DPU evpn functionality

Usage:
  godpu evpn [flags]
  godpu evpn [command]

Aliases:
  evpn, g

Available Commands:
  create-bp   Create a bridge port
  create-lb   Create a logical bridge
  create-svi  Create a SVI
  create-vrf  Create a VRF
  delete-bp   Delete a bridge port
  delete-lb   Delete a logical bridge
  delete-svi  Delete a SVI
  delete-vrf  Delete a VRF
  get-bp      Show details of a bridge port
  get-lb      Show details of a logical bridge
  get-svi     Show details of a SVI
  get-vrf     Show details of a VRF
  list-bps    Show details of all bridge ports
  list-lbs    Show details of all logical bridges
  list-svis   Show details of all SVIs
  list-vrfs   Show details of all Vrfs
  update-bp   Update the bridge port
  update-lb   update the logical bridge
  update-svi  update the SVI
  update-vrf  update the VRF

Flags:
  -h, --help   help for evpn

Use "godpu evpn [command] --help" for more information about a command.

Manual HTTP example

In addition HTTP is supported via grpc gateway, for example:

curl -kL http://10.10.10.10:8082/v1/inventory/1/inventory/2

Architecture Diagram

OPI EVPN Bridge Architcture Diagram

Tests

Test your APIs even if unmerged using your private fork like this:

chmod a+w go.*
docker run --rm -it -v `pwd`:/app -w /app golang:alpine go mod edit -replace github.com/opiproject/opi-api@main=github.com/YOURUSERNAME/opi-api@main
docker run --rm -it -v `pwd`:/app -w /app golang:alpine go get -u github.com/YOURUSERNAME/opi-api/network/evpn-gw/v1alpha1/gen/go@0e2810d
docker run --rm -it -v `pwd`:/app -w /app golang:alpine go mod tidy

Generate mocks like this:

go install github.com/vektra/mockery/v2@latest
make mock-generate

# or using docker
docker run -v "$PWD":/src -w /src vektra/mockery --config=utils/mocks/.mockery.yaml --name=Netlink --dir pkg/utils --output pkg/utils/mocks --boilerplate-file pkg/utils/mocks/boilerplate.txt --with-expecter

POC diagrams

OPI EVPN Bridge POC Diagram for CI/CD OPI EVPN Bridge Diagram for L2VXLAN OPI EVPN Bridge Diagram for L3VXLAN Asymmetric IRB OPI EVPN Bridge Diagram for L3VXLAN Symmetric IRB OPI EVPN Bridge Diagram for L2VXLAN in_Symmetric IRB OPI EVPN Bridge Diagram for Leaf1_Detailed_View