From 7fa4876c7a4886d34e68d195e97ef92e7cf5bcf2 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Fri, 2 May 2025 15:32:20 +0200 Subject: [PATCH] Initial config for a bare-bones VPP container lab image --- Dockerfile.bookworm | 20 ++++++++++++++++++++ README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++ bootstrap.vpp | 3 +++ clab.vpp | 1 + manual-post.vpp | 1 + manual-pre.vpp | 1 + startup.conf | 39 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 Dockerfile.bookworm create mode 100644 README.md create mode 100644 bootstrap.vpp create mode 100644 clab.vpp create mode 100644 manual-post.vpp create mode 100644 manual-pre.vpp create mode 100644 startup.conf diff --git a/Dockerfile.bookworm b/Dockerfile.bookworm new file mode 100644 index 0000000..c61a87c --- /dev/null +++ b/Dockerfile.bookworm @@ -0,0 +1,20 @@ +FROM debian:bookworm +ARG DEBIAN_FRONTEND=noninteractive +ARG VPP_INSTALL_SKIP_SYSCTL=true +ARG REPO=release +RUN apt-get update +RUN apt-get -y install curl procps tcpdump iproute2 iptables binutils \ + bridge-utils iputils-ping netcat-traditional net-tools nmap \ + python3 python3-dev python3-pip +RUN mkdir -p /var/log/vpp +RUN curl -s https://packagecloud.io/install/repositories/fdio/${REPO}/script.deb.sh | bash +RUN apt-get update +RUN apt-get -y install vpp vpp-plugin-core +RUN apt-get -y clean +COPY startup.conf /etc/vpp/startup.conf +COPY bootstrap.vpp /etc/vpp/bootstrap.vpp +COPY manual-pre.vpp /etc/vpp/manual-pre.vpp +COPY clab.vpp /etc/vpp/clab.vpp +COPY manual-post.vpp /etc/vpp/manual-post.vpp +CMD ["/usr/bin/vpp","-c","/etc/vpp/startup.conf"] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..be1cae9 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# VPP Containerlab Docker image + +This docker container creates a VPP instance based on the latest release. +It starts up as per normal, using /etc/vpp/startup.conf (which Containerlab +will replace), and once started, it'll execute /etc/vpp/bootstrap.vpp within +the dataplane. There are three relevant files: + +1. manual-pre.vpp -- can be supplied by the user, to run any configuration + statements before containerlab takes control. +1. clab.vpp -- generated by containerlab. It will bind the vethpair interfaces + into the dataplane. +1. manual-post.vpp -- can be supplied by the user, to run any configuration + statements after containerlab is finished with its per-lab statements. + +## Building + +docker build -f Dockerfile.bookworm . -t pimvanpelt/vpp-containerlab + +## Starting the container + +docker network create --driver=bridge network2 --subnet=172.19.1.0/24 +docker rm clab-pim +docker run --cap-add=NET_ADMIN --cap-add=SYS_NICE --cap-add=SYS_PTRACE \ + --device=/dev/net/tun:/dev/net/tun --device=/dev/vfio/vfio:/dev/vfio/vfio \ + --device=/dev/vhost-net:/dev/vhost-net \ + --privileged=True --name clab-pim \ + docker.io/pimvanpelt/vpp-containerlab +docker network connect network2 clab-pim + +## Configuring VPP + +docker exec -it clab-pim vppctl + +vpp-clab# create host-interface v2 name eth1 +vpp-clab# set interface name host-eth1 eth1 +vpp-clab# set interface mtu 1500 eth1 +vpp-clab# set interface ip address eth1 172.19.1.2/24 +vpp-clab# set interface ip address eth1 fec0::2/64 +vpp-clab# set interface state eth1 up + +## References + +https://s3-docs.fd.io/vpp/22.02/usecases/vpp_testbench/index.html +https://git.ipng.ch/ipng/drone-hugo +https://github.com/ligato/vpp-base/tree/master + diff --git a/bootstrap.vpp b/bootstrap.vpp new file mode 100644 index 0000000..50fe9ea --- /dev/null +++ b/bootstrap.vpp @@ -0,0 +1,3 @@ +exec /etc/vpp/manual-pre.vpp +exec /etc/vpp/clab.vpp +exec /etc/vpp/manual-post.vpp diff --git a/clab.vpp b/clab.vpp new file mode 100644 index 0000000..9eb9738 --- /dev/null +++ b/clab.vpp @@ -0,0 +1 @@ +comment { This file will be overwritten / generated by containerlab upon deploy } diff --git a/manual-post.vpp b/manual-post.vpp new file mode 100644 index 0000000..801ccd1 --- /dev/null +++ b/manual-post.vpp @@ -0,0 +1 @@ +comment { These commands are executed after Containerlab stuff } diff --git a/manual-pre.vpp b/manual-pre.vpp new file mode 100644 index 0000000..5b9e973 --- /dev/null +++ b/manual-pre.vpp @@ -0,0 +1 @@ +comment { These commands are executed before Containerlab stuff } diff --git a/startup.conf b/startup.conf new file mode 100644 index 0000000..1082e55 --- /dev/null +++ b/startup.conf @@ -0,0 +1,39 @@ +unix { + interactive + log /var/log/vpp/vpp.log + full-coredump + cli-listen /run/vpp/cli.sock + cli-prompt vpp-clab# + cli-no-pager + poll-sleep-usec 100 + exec /etc/vpp/bootstrap.vpp +} + +api-trace { + on +} + +memory { + main-heap-size 512M + main-heap-page-size 4k +} + +buffers { + buffers-per-numa 16000 + default data-size 2048 + page-size 4k +} + +statseg { + size 64M + page-size 4k + per-node-counters on +} + +plugins { + plugin default { enable } + plugin dpdk_plugin.so { disable } + plugin linux_cp_plugin.so { enable } + plugin linux_nl_plugin.so { enable } + plugin sflow_plugin.so { enable } +}