Examples#


This VPP agent examples folder in the repo contains several examples that illustrate VPP agent functionality. Each example is structured as an individual executable with its own main.go file. Each example focuses on a simple use case.

Note

All examples use etcd, GoVPP and Kafka. Please make sure there are running instances of etcd, Kafka and VPP before running through an example. The quickstart guide can guide you through a setup, or follow the instructions below using the pre-built docker image.

Current examples:

  • govpp_call is an example of a plugin with a configurator and a channel to send/receive data to and from VPP. It shows how to transform northbound model data to VPP binary API calls.

  • localclient_vpp_plugins demonstrates how to use the localclient package to push example configuration information into VPP plugins running in the same agent instance (i.e. in the same OS process). The configuration data is transported via go channels.

  • localclient_vpp_nat demonstrates how to set up NAT global configuration and Destination NAT. The example uses localclient to communicate example configuration data to the respective VPP plugins.

  • localclient_linux_tap configures simple topology consisting of VPP Tap interfaces with the linux host counterparts. The example demonstrates how to use the localclient package to push example configuration data for the respective interface types into linux and VPP plugins running within the same agent instance (i.e. within the same OS process). The configuration data is transported via go channels.

  • localclient_linux_veth configures simple topology consisting of VPP af-packet interfaces attached to linux Veth pairs. This example uses the localclient package to push the configuration to VPP agent plugins.

  • grpc_vpp_remote_client demonstrates how to use the remoteclient package to push example configuration data into VPP plugins running within different VPP agent OS processes.

  • grpc_vpp_notifications demonstrates how to use the notifications package to receive VPP notifications streamed by different VPP agent processes.

  • CN-Infra examples demonstrates how to use the Ligato Infra framework plugins.

  • Custom VPP Plugin contains a working example of custom agent which adds support for a custom VPP plugin. This example can serve as skeleton code for developing custom agents, that add new VPP functionality that is not part of the official VPP Agent.

How to run an example#

1. Download Image

docker pull ligato/vpp-agent

2. Start etcd server on localhost

docker run --rm --name etcd -p 2379:2379 -e ETCDCTL_API=3 quay.io/coreos/etcd /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379


2b. (Optional) start Kafka on localhost

sudo docker run -p 2181:2181 -p 9092:9092 --name kafka --rm \ --env ADVERTISED_HOST=172.17.0.1 --env ADVERTISED_PORT=9092 spotify/kafka

Note: For more information about Kafka and ARM64, see Kafka ARM64.

3. Start VPP vpp unix { interactive } plugins { plugin dpdk_plugin.so { disable } }

4. Start desired example

Example can be started now from the specific directory.

go run main.go  \
--etcd-config=/opt/vpp-agent/dev/etcd.conf \
--kafka-config=/opt/vpp-agent/dev/kafka.conf