Allow container to interop with pre 0.75 containerlab
This commit is contained in:
@@ -9,7 +9,7 @@ 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 \
|
iputils-ping net-tools git python3 python3-pip vim-tiny nano joe openssh-server \
|
||||||
mtr-tiny traceroute rsync && apt-get clean
|
mtr-tiny traceroute rsync && apt-get clean
|
||||||
|
|
||||||
# Install VPP - sideload from local debs if --build-context vppdebs=<path> is provided,
|
# Install VPP - sideload from local debs if --build-context vppdebs=<path> is provided,
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
STARTUP_CONFIG=${STARTUP_CONFIG:="/config/vpp/startup.conf"}
|
STARTUP_CONFIG=${STARTUP_CONFIG:="/config/vpp/startup.conf"}
|
||||||
VPPCFG_YAML_FILE=${VPPCFG_YAML_FILE:=/config/vpp/vppcfg.yaml}
|
VPPCFG_YAML_FILE=${VPPCFG_YAML_FILE:="/config/vpp/vppcfg.yaml"}
|
||||||
VPPCFG_VPP_FILE=${VPPCFG_VPP_FILE:=/config/vpp/config/vppcfg.vpp}
|
VPPCFG_VPP_FILE=${VPPCFG_VPP_FILE:="/config/vpp/config/vppcfg.vpp"}
|
||||||
CLAB_VPP_FILE=${CLAB_VPP_FILE:=/config/vpp/config/clab.vpp}
|
CLAB_VPP_FILE=${CLAB_VPP_FILE:="/config/vpp/config/clab.vpp"}
|
||||||
NETNS=${NETNS:="dataplane"}
|
NETNS=${NETNS:="dataplane"}
|
||||||
BIRD_ENABLED=${BIRD_ENABLED:="true"}
|
BIRD_ENABLED=${BIRD_ENABLED:="true"}
|
||||||
|
BIRD_CONFIG=${BIRD_CONFIG:="/config/bird/bird.conf"}
|
||||||
FRR_ENABLED=${FRR_ENABLED:="false"}
|
FRR_ENABLED=${FRR_ENABLED:="false"}
|
||||||
|
FRR_CONFIG=${FRR_CONFIG:="/config/frr/frr.conf"}
|
||||||
|
|
||||||
echo "Creating dataplane namespace"
|
echo "Creating dataplane namespace"
|
||||||
/usr/bin/mkdir -p /etc/netns/$NETNS
|
/usr/bin/mkdir -p /etc/netns/$NETNS
|
||||||
@@ -19,26 +21,40 @@ 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
|
||||||
|
|
||||||
|
# TODO(pim): Remove this after containerlab 0.75 is released
|
||||||
|
if [ -r /etc/vpp/startup.conf ]; then
|
||||||
|
echo "Detected old containerlab binary - invoking backwards compatible behavior"
|
||||||
|
STARTUP_CONFIG="/etc/vpp/startup.conf"
|
||||||
|
VPPCFG_YAML_FILE="/etc/vpp/vppcfg.yaml"
|
||||||
|
VPPCFG_VPP_FILE="/config/vpp/config/vppcfg.vpp"
|
||||||
|
CLAB_VPP_FILE="/config/vpp/config/clab.vpp"
|
||||||
|
BIRD_CONFIG="/etc/bird/bird.conf"
|
||||||
|
FFR_CONFIG="/etc/frr/frr.conf"
|
||||||
|
mkdir -p /config/vpp/config/
|
||||||
|
echo "comment { please upgrade to containerlab 0.75+ }" > /config/vpp/config/manual-pre.vpp
|
||||||
|
echo "comment { please upgrade to containerlab 0.75+ }" > /config/vpp/config/manual-post.vpp
|
||||||
|
else
|
||||||
echo "Initializing /config"
|
echo "Initializing /config"
|
||||||
for dir in vpp bird frr; do
|
for dir in vpp bird frr; do
|
||||||
rsync -av --ignore-existing /etc/$dir/ /config/$dir/
|
rsync -av --ignore-existing /etc/$dir/ /config/$dir/
|
||||||
rm -rf /etc/$dir/
|
rm -rf /etc/$dir/
|
||||||
ln -s /config/$dir /etc/$dir
|
ln -s /config/$dir /etc/$dir
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$BIRD_ENABLED" == "true" ]; then
|
if [ "$BIRD_ENABLED" == "true" ]; then
|
||||||
echo "Starting Bird in $NETNS"
|
echo "Starting Bird in $NETNS"
|
||||||
mkdir -p /run/bird /var/log/bird
|
mkdir -p /run/bird /var/log/bird
|
||||||
chown bird:bird /var/log/bird
|
chown bird:bird /var/log/bird
|
||||||
ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/)
|
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," /config/bird/bird.conf
|
sed -i -e "s,.*router id .*,router id $ROUTERID; # Set by container-init.sh," $BIRD_CONFIG
|
||||||
/usr/bin/nsenter --net=/run/netns/$NETNS /usr/sbin/bird -u bird -g vpp -c /config/bird/bird.conf
|
/usr/bin/nsenter --net=/run/netns/$NETNS /usr/sbin/bird -u bird -g vpp -c $BIRD_CONFIG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FRR_ENABLED" == "true" ]; then
|
if [ "$FRR_ENABLED" == "true" ]; then
|
||||||
echo "Starting FRRouting in $NETNS"
|
echo "Starting FRRouting in $NETNS"
|
||||||
ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/)
|
ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/)
|
||||||
sed -i -e "s,^ip router-id .*,ip router-id $ROUTERID," /config/frr/frr.conf
|
sed -i -e "s,^ip router-id .*,ip router-id $ROUTERID," $FRR_CONFIG
|
||||||
/etc/init.d/frr start
|
/etc/init.d/frr start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -58,11 +74,16 @@ set interface state $IFNAME up
|
|||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -s $VPPCFG_YAML_FILE ]; then
|
||||||
echo "Generating $VPPCFG_YAML_FILE into $VPPCFG_VPP_FILE"
|
echo "Generating $VPPCFG_YAML_FILE into $VPPCFG_VPP_FILE"
|
||||||
: > $VPPCFG_VPP_FILE
|
: > $VPPCFG_VPP_FILE
|
||||||
if [ -r $VPPCFG_YAML_FILE ]; then
|
if [ -r $VPPCFG_YAML_FILE ]; then
|
||||||
vppcfg plan --novpp -c $VPPCFG_YAML_FILE -o $VPPCFG_VPP_FILE
|
vppcfg plan --novpp -c $VPPCFG_YAML_FILE -o $VPPCFG_VPP_FILE
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Generating empty $VPPCFG_VPP_FILE due to missing or empty $VPPCFG_YAML_FILE"
|
||||||
|
echo "comment { please provide a vppcfg.yaml file }" > $VPPCFG_VPP_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Starting VPP"
|
echo "Starting VPP"
|
||||||
exec /usr/bin/vpp -c $STARTUP_CONFIG
|
exec /usr/bin/vpp -c $STARTUP_CONFIG
|
||||||
|
|||||||
Reference in New Issue
Block a user