Compare commits

...

5 Commits

17 changed files with 176 additions and 16 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
clab-*
**/*.bak

View File

@ -2,24 +2,24 @@
This docker container creates a VPP instance based on the latest VPP release. It starts up as per This docker container creates a VPP instance based on the latest VPP release. It starts up as per
normal, using /etc/vpp/startup.conf (which Containerlab might replace when it starts its normal, using /etc/vpp/startup.conf (which Containerlab might replace when it starts its
containers). Once started, it'll execute /etc/vpp/bootstrap.vpp within the dataplane. There are containers). Once started, it'll execute `/etc/vpp/bootstrap.vpp` within the dataplane. There are
three relevant files: two relevant files:
1. `manual-pre.vpp` -- can be supplied by the user, to run any configuration statements before 1. `clab.vpp` -- generated by `files/init-container.sh`. Its purpose is to bind the `veth`
containerlab takes control.
1. `clab.vpp` -- generated by `files/container-init.sh`. Its purpose is to bind the `veth`
interfaces that containerlab has added to the container into the VPP dataplane (see below). interfaces that containerlab has added to the container into the VPP dataplane (see below).
1. `vppcfg.vpp` -- generated by `files/init-container.sh`. Its purpose is to read the user
specified `vppcfg.yaml` file and convert it into VPP CLI commands. If no YAML file is
specified, or if it is not syntactically valid, an empty file is generated instead.
1. `manual-post.vpp` -- can be supplied by the user, to run any configuration statements after For Containerlab users who wish to have more control over their VPP bootstrap, it's possible to
containerlab is finished with its per-lab statements. bind-mount `/etc/vpp/bootstrap.vpp`.
## Building ## Building
```bash ```bash
IMG=git.ipng.ch/ipng/vpp-containerlab IMG=git.ipng.ch/ipng/vpp-containerlab
TAG=latest TAG=latest
docker build --no-cache -f Dockerfile.bookworm -t $IMG . docker build --no-cache -f docker/Dockerfile.bookworm -t $IMG docker/
docker image tag $IMG $IMG:$TAG docker image tag $IMG $IMG:$TAG
docker push $IMG docker push $IMG
docker push $IMG:$TAG docker push $IMG:$TAG

View File

@ -0,0 +1,19 @@
protocol bfd bfd1 {
interface "eth2" { interval 100 ms; multiplier 30; };
}
protocol ospf v2 ospf4 {
ipv4 { import all; export all; };
area 0 {
interface "loop0" { stub yes; };
interface "eth2" { type pointopoint; cost 10; bfd on; };
};
}
protocol ospf v3 ospf6 {
ipv6 { import all; export all; };
area 0 {
interface "loop0" { stub yes; };
interface "eth2" { type pointopoint; cost 10; bfd on; };
};
}

16
config/vpp1/vppcfg.yaml Normal file
View File

@ -0,0 +1,16 @@
interfaces:
eth1:
description: 'To client1'
mtu: 1500
lcp: eth1
addresses: [ 10.82.98.65/28, 2001:db8:8298:101::1/64 ]
eth2:
description: 'To vpp2'
mtu: 9000
lcp: eth2
addresses: [ 10.82.98.16/31, 2001:db8:8298:1::1/64 ]
loopbacks:
loop0:
description: 'vpp1'
lcp: loop0
addresses: [ 10.82.98.0/32, 2001:db8:8298::/128 ]

View File

@ -0,0 +1,19 @@
protocol bfd bfd1 {
interface "eth2" { interval 100 ms; multiplier 30; };
}
protocol ospf v2 ospf4 {
ipv4 { import all; export all; };
area 0 {
interface "loop0" { stub yes; };
interface "eth2" { type pointopoint; cost 10; bfd on; };
};
}
protocol ospf v3 ospf6 {
ipv6 { import all; export all; };
area 0 {
interface "loop0" { stub yes; };
interface "eth2" { type pointopoint; cost 10; bfd on; };
};
}

16
config/vpp2/vppcfg.yaml Normal file
View File

@ -0,0 +1,16 @@
interfaces:
eth1:
description: 'To client2'
mtu: 1500
lcp: eth1
addresses: [ 10.82.98.81/28, 2001:db8:8298:102::1/64 ]
eth2:
description: 'To vpp1'
mtu: 9000
lcp: eth2
addresses: [ 10.82.98.17/31, 2001:db8:8298:1::2/64 ]
loopbacks:
loop0:
description: 'vpp2'
lcp: loop0
addresses: [ 10.82.98.1/32, 2001:db8:8298::1/128 ]

View File

@ -4,7 +4,8 @@ ARG VPP_INSTALL_SKIP_SYSCTL=true
ARG REPO=release ARG REPO=release
EXPOSE 22/tcp EXPOSE 22/tcp
RUN apt-get update && apt-get -y install curl procps tcpdump iproute2 iptables \ RUN apt-get update && apt-get -y install curl procps tcpdump iproute2 iptables \
iputils-ping net-tools git python3 python3-pip vim-tiny openssh-server && apt-get clean iputils-ping net-tools git python3 python3-pip vim-tiny openssh-server bird2 \
mtr-tiny traceroute && apt-get clean
# Install VPP # Install VPP
RUN mkdir -p /var/log/vpp /root/.ssh/ RUN mkdir -p /var/log/vpp /root/.ssh/
@ -17,7 +18,8 @@ RUN git clone https://github.com/pimvanpelt/vppcfg.git && cd vppcfg && python3 -
pip install --break-system-packages dist/vppcfg-*-py3-none-any.whl pip install --break-system-packages dist/vppcfg-*-py3-none-any.whl
# Config files # Config files
COPY files/startup.conf files/*.vpp /etc/vpp/ COPY files/etc/vpp/* /etc/vpp/
COPY files/etc/bird/* /etc/bird/
COPY files/init-container.sh /sbin/ COPY files/init-container.sh /sbin/
RUN chmod 755 /sbin/init-container.sh RUN chmod 755 /sbin/init-container.sh
CMD ["/sbin/init-container.sh"] CMD ["/sbin/init-container.sh"]

View File

@ -0,0 +1 @@
# Containerlab user overrides go in this file.

View File

@ -0,0 +1,26 @@
# Bird2 configuration for VPP Containerlab
# router id 192.0.2.0;
timeformat base iso long;
timeformat log iso long;
timeformat protocol iso long;
timeformat route iso long;
log "/var/log/bird/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug };
protocol device { scan time 30; }
protocol direct { ipv4; ipv6; check link yes; }
protocol kernel kernel4 {
ipv4 { import none; export where source != RTS_DEVICE; };
learn off; scan time 300;
}
protocol kernel kernel6 {
ipv6 { import none; export where source != RTS_DEVICE; };
learn off; scan time 300;
}
include "bird-local.conf";

View File

@ -0,0 +1,2 @@
exec /etc/vpp/clab.vpp
exec /etc/vpp/vppcfg.vpp

View File

@ -1,3 +1,6 @@
# This is the vpp-containerlab default startup.conf, which is meant to be
# overridden by Containerlab's node/fdio_vpp/vpp_startup_config.go.tpl
unix { unix {
interactive interactive
log /var/log/vpp/vpp.log log /var/log/vpp/vpp.log

View File

@ -2,7 +2,9 @@
STARTUP_CONFIG=${STARTUP_CONFIG:="/etc/vpp/startup.conf"} STARTUP_CONFIG=${STARTUP_CONFIG:="/etc/vpp/startup.conf"}
CLAB_VPP_FILE=${CLAB_VPP_FILE:=/etc/vpp/clab.vpp} CLAB_VPP_FILE=${CLAB_VPP_FILE:=/etc/vpp/clab.vpp}
VPPCFG_VPP_FILE=${VPPCFG_VPP_FILE:=/etc/vpp/vppcfg.vpp}
NETNS=${NETNS:="dataplane"} NETNS=${NETNS:="dataplane"}
BIRD_ENABLED=${BIRD_ENABLED:="true"}
echo "Creating dataplane namespace" echo "Creating dataplane namespace"
/usr/bin/mkdir -p /etc/netns/$NETNS /usr/bin/mkdir -p /etc/netns/$NETNS
@ -14,6 +16,15 @@ sed -i -e 's,^#PermitRootLogin prohibit-password,PermitRootLogin yes,' /etc/ssh/
sed -i -e 's,^root:.*,root:$y$j9T$kG8pyZEVmwLXEtXekQCRK.$9iJxq/bEx5buni1hrC8VmvkDHRy7ZMsw9wYvwrzexID:20211::::::,' /etc/shadow sed -i -e 's,^root:.*,root:$y$j9T$kG8pyZEVmwLXEtXekQCRK.$9iJxq/bEx5buni1hrC8VmvkDHRy7ZMsw9wYvwrzexID:20211::::::,' /etc/shadow
/etc/init.d/ssh start /etc/init.d/ssh start
if [ "$BIRD_ENABLED" == "true" ]; then
echo "Starting Bird in $NETNS"
mkdir -p /run/bird /var/log/bird
chown bird:bird /var/log/bird
ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/)
sed -i -e "s,.*router id .*,router id $ROUTERID; # Set by container-init.sh," /etc/bird/bird.conf
/usr/bin/nsenter --net=/var/run/netns/$NETNS /usr/sbin/bird -u bird -g bird
fi
echo "Generating $CLAB_VPP_FILE" echo "Generating $CLAB_VPP_FILE"
: > $CLAB_VPP_FILE : > $CLAB_VPP_FILE
MTU=9216 MTU=9216
@ -30,5 +41,11 @@ set interface state $IFNAME up
EOF EOF
done done
echo "Generating $VPPCFG_VPP_FILE"
: > $VPPCFG_VPP_FILE
if [ -r /etc/vpp/vppcfg.yaml ]; then
vppcfg plan --novpp -c /etc/vpp/vppcfg.yaml -o $VPPCFG_VPP_FILE
fi
echo "Starting VPP" echo "Starting VPP"
exec /usr/bin/vpp -c $STARTUP_CONFIG exec /usr/bin/vpp -c $STARTUP_CONFIG

View File

@ -1,3 +0,0 @@
exec /etc/vpp/manual-pre.vpp
exec /etc/vpp/clab.vpp
exec /etc/vpp/manual-post.vpp

View File

@ -1 +0,0 @@
comment { These commands are executed after Containerlab stuff }

View File

@ -1 +0,0 @@
comment { These commands are executed before Containerlab stuff }

42
vpp.clab.yml Normal file
View File

@ -0,0 +1,42 @@
name: learn-vpp
prefix: ""
topology:
kinds:
fdio_vpp:
image: git.ipng.ch/ipng/vpp-containerlab:latest
linux:
image: alpine:latest
nodes:
vpp1:
kind: fdio_vpp
binds:
- config/vpp1/vppcfg.yaml:/etc/vpp/vppcfg.yaml:ro
- config/vpp1/bird-local.conf:/etc/bird/bird-local.conf:ro
vpp2:
kind: fdio_vpp
binds:
- config/vpp2/vppcfg.yaml:/etc/vpp/vppcfg.yaml:ro
- config/vpp2/bird-local.conf:/etc/bird/bird-local.conf:ro
client1:
kind: linux
exec:
- ip link set address 00:c1:ab:00:00:01 dev eth1
- ip addr add 10.82.98.66/28 dev eth1
- ip route add 10.82.98.0/24 via 10.82.98.65
- ip addr add 2001:db8:8298:101::2/64 dev eth1
- ip route add 2001:db8:8298::/48 via 2001:db8:8298:101::1
client2:
kind: linux
exec:
- ip link set address 00:c1:ab:00:00:02 dev eth1
- ip addr add 10.82.98.82/28 dev eth1
- ip route add 10.82.98.0/24 via 10.82.98.81
- ip addr add 2001:db8:8298:102::2/64 dev eth1
- ip route add 2001:db8:8298::/48 via 2001:db8:8298:102::1
links:
- endpoints: ["vpp1:eth2", "vpp2:eth2"]
- endpoints: ["client1:eth1", "vpp1:eth1"]
- endpoints: ["client2:eth1", "vpp2:eth1"]