f-87: deploy: vxlan-public sur br-public, --public_vni (1), lab au VNI 1 #87

bootstrap_kvm.sh crée vxlan-public (VTEP = IPv4 du bridge principal,
nolearning) esclave du bridge public, recréé si le VNI ou le VTEP change.
Lab : bordures au VNI 1 (MAC 02:01:00:00:00:01) ; build.sh copie
bootstrap_kvm.sh, que hypervisor.sh appelle après la release 0.2.0.

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-25 23:31:25 +01:00
commit e8c45c74b3
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
10 changed files with 90 additions and 27 deletions

2
.gitignore vendored
View file

@ -37,3 +37,5 @@ docs/_build/
# Binaires compilés en local pour le lab (test/e2e/build.sh)
test/e2e/topologies/bin/*
!test/e2e/topologies/bin/.gitkeep
test/e2e/topologies/scripts/*
!test/e2e/topologies/scripts/.gitkeep

View file

@ -129,10 +129,10 @@ ne change pas. Le bridge n'est créé qu'au premier démarrage, comme le reste d
**Bordures (``evpn-3hv``, #87).** ``bd1`` et ``bd2`` (``192.168.14.21`` et ``.22``) jouent les
routeurs de bordure du segment public. Ce sont des nœuds ``host`` sans agent : leur provision
(``test/e2e/topologies/provision/border.sh``) crée ``br-public``, y accroche ``vxlan-66001``
(VNI 66001, VTEP = adresse de l'underlay, ``nolearning``), et pose sur le bridge la **gateway
anycast** ``240.0.0.1/24`` avec la même MAC sur les deux, ``02:01:00:01:01:d1`` (la MAC anycast
de two pour le VNI 66001), ainsi qu'une destination de test ``240.255.0.1/32`` sur une interface
(``test/e2e/topologies/provision/border.sh``) crée ``br-public``, y accroche ``vxlan-public``
(VNI 1, VTEP = adresse de l'underlay, ``nolearning``), et pose sur le bridge la **gateway
anycast** ``240.0.0.1/24`` avec la même MAC sur les deux, ``02:01:00:00:00:01`` (la MAC anycast
de two pour le VNI 1), ainsi qu'une destination de test ``240.255.0.1/32`` sur une interface
``dummy`` ``internet``. Leur ``frr.conf`` est celui d'un hyperviseur — iBGP AS 64600 vers les
deux route reflectors, ``advertise-all-vni`` — plus ``advertise-default-gw`` : la MAC et l'IP
de la gateway sont annoncées en type 2 avec la communauté *Default Gateway* (RFC 7432, §7.8 et

View file

@ -77,8 +77,8 @@ kvm_network () {
info "réseau"
# Bridge public : créé à vide, réservé pour un usage futur. Aucune adresse,
# aucun esclave, pas référencé dans la config agent.
# Bridge public : sans adresse. Il reçoit le VXLAN du segment public
# (kvm_public_segment) et les veth vp-<id>-e des VPC (interfaces.internet).
kvm_ensure_bridge "${DRY_RUN}" "${PUBLIC_BRIDGE}"
MASTER=""
@ -153,6 +153,49 @@ EOF
info " rollback désarmé"
}
# VXLAN du segment public, partagé avec les bordures, esclave du bridge public.
# VTEP = IPv4 du bridge principal, comme les VXLAN de l'agent ; sans
# apprentissage, les MAC distantes viennent d'EVPN. Recréé si le VNI ou le VTEP
# a changé.
kvm_public_segment () {
local DRY_RUN="${1}"
local WITH_NETWORK="${2}"
local BRIDGE="${3}"
local PUBLIC_BRIDGE="${4}"
local PUBLIC_VNI="${5}"
local NAME="vxlan-public"
local VTEP CURRENT=""
[[ ${WITH_NETWORK} -eq ${FLAGS_TRUE} ]] || return 0
[[ "${PUBLIC_VNI}" =~ ^[0-9]+$ ]] && (( PUBLIC_VNI >= 1 && PUBLIC_VNI <= 16777215 )) \
|| die "VNI du segment public invalide : ${PUBLIC_VNI} (1-16777215)"
info "segment public : ${NAME}, VNI ${PUBLIC_VNI}, sur ${PUBLIC_BRIDGE}"
if [[ ${DRY_RUN} -eq ${FLAGS_TRUE} ]]
then
VTEP="<ip(${BRIDGE})>"
else
VTEP=$(ip -j addr show dev "${BRIDGE}" | jq -r '[.[0].addr_info[] | select(.family=="inet" and .scope=="global")][0].local // ""')
[[ -n "${VTEP}" ]] || die "aucune adresse IPv4 globale sur ${BRIDGE} pour le VTEP du segment public"
if ip link show dev "${NAME}" >/dev/null 2>&1
then
CURRENT=$(ip -j -d link show dev "${NAME}" | jq -r '.[0].linkinfo.info_data | "\(.id) \(.local)"')
fi
fi
if [[ -n "${CURRENT}" && "${CURRENT}" != "${PUBLIC_VNI} ${VTEP}" ]]
then
info " ${NAME} porte ${CURRENT} (VNI VTEP) : recréé"
run "${DRY_RUN}" "ip link del dev '${NAME}'"
CURRENT=""
fi
[[ -n "${CURRENT}" ]] \
|| run "${DRY_RUN}" "ip link add '${NAME}' type vxlan id ${PUBLIC_VNI} local '${VTEP}' dstport 4789 nolearning"
run "${DRY_RUN}" "ip link set dev '${NAME}' mtu 1500 master '${PUBLIC_BRIDGE}'"
run "${DRY_RUN}" "ip link set up dev '${NAME}'"
}
# Point d'entrée appelé par deploy.sh --bootstrap.
bootstrap_host () {
local DRY_RUN="${1}"
@ -162,8 +205,10 @@ bootstrap_host () {
local BRIDGE="${5}"
local PUBLIC_BRIDGE="${6}"
local ROLLBACK_DELAY="${7}"
local PUBLIC_VNI="${8:-1}"
kvm_packages "${DRY_RUN}" "${WITH_PACKAGES}"
kvm_kernel "${DRY_RUN}"
kvm_network "${DRY_RUN}" "${WITH_NETWORK}" "${UPLINK}" "${BRIDGE}" "${PUBLIC_BRIDGE}" "${ROLLBACK_DELAY}"
kvm_packages "${DRY_RUN}" "${WITH_PACKAGES}"
kvm_kernel "${DRY_RUN}"
kvm_network "${DRY_RUN}" "${WITH_NETWORK}" "${UPLINK}" "${BRIDGE}" "${PUBLIC_BRIDGE}" "${ROLLBACK_DELAY}"
kvm_public_segment "${DRY_RUN}" "${WITH_NETWORK}" "${BRIDGE}" "${PUBLIC_BRIDGE}" "${PUBLIC_VNI}"
}

View file

@ -159,7 +159,7 @@ run_bootstrap () {
|| die "bootstrap_host() introuvable — ni ${SCRIPTS_DIR}/${NAME} ni ${BOOTSTRAP_URL} n'ont pu être chargés"
bootstrap_host "${DRY_RUN}" "${FLAGS_packages}" "${FLAGS_network}" \
"${FLAGS_uplink}" "${FLAGS_bridge}" "${FLAGS_pub_bridge}" "${FLAGS_rollback}"
"${FLAGS_uplink}" "${FLAGS_bridge}" "${FLAGS_pub_bridge}" "${FLAGS_rollback}" "${FLAGS_public_vni}"
}
resolve_tag () {
@ -335,7 +335,8 @@ main () {
DEFINE_boolean 'network' true 'Configure bridges during --bootstrap' 'n'
DEFINE_string 'uplink' 'eno1' 'Physical uplink interface' 'u'
DEFINE_string 'bridge' 'br-000000' 'Main bridge, uplink is enslaved to it' 'B'
DEFINE_string 'pub_bridge' 'br-public' 'Reserved empty bridge' 'P'
DEFINE_string 'pub_bridge' 'br-public' 'Public bridge, carries vxlan-public' 'P'
DEFINE_integer 'public_vni' 1 'VNI of the public segment (vxlan-public)' 'N'
DEFINE_integer 'rollback' 120 'Rollback reboot delay in seconds' 'R'
DEFINE_boolean 'verify' true 'Check assets against SHA256SUMS' 'V'

View file

@ -3,33 +3,42 @@
E2E_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "${E2E_DIR}/../.." && pwd)"
BIN_DIR="${BIN_DIR:-${E2E_DIR}/topologies/bin}"
SCRIPTS_DIR="${SCRIPTS_DIR:-${E2E_DIR}/topologies/scripts}"
BINARIES="agent dhcp metadata"
SCRIPTS="bootstrap_kvm.sh"
usage () {
cat >&2 <<USAGE
usage: ${0##*/} [--clean]
sans option : compile ${BINARIES} pour linux/amd64 depuis l'arbre courant dans ${BIN_DIR} ;
le prochain lab les installe par-dessus la release épinglée dans
topologies/provision/hypervisor.sh
--clean : vide ${BIN_DIR} ; le prochain lab teste la release seule
sans option : compile ${BINARIES} pour linux/amd64 depuis l'arbre courant dans ${BIN_DIR},
copie ${SCRIPTS} dans ${SCRIPTS_DIR} ; le prochain lab les installe par-dessus
la release épinglée dans topologies/provision/hypervisor.sh
--clean : vide ${BIN_DIR} et ${SCRIPTS_DIR} ; le prochain lab teste la release seule
USAGE
exit 2
}
clean () {
local binary
local binary script
for binary in ${BINARIES}; do
rm -f "${BIN_DIR}/${binary}" || return 1
done
for script in ${SCRIPTS}; do
rm -f "${SCRIPTS_DIR}/${script}" || return 1
done
}
build () {
local binary
local binary script
for binary in ${BINARIES}; do
echo "== ${binary}" >&2
(cd "${REPO_DIR}" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BIN_DIR}/${binary}" "./cmd/${binary}") || return 1
done
for script in ${SCRIPTS}; do
echo "== ${script}" >&2
cp "${REPO_DIR}/scripts/${script}" "${SCRIPTS_DIR}/${script}" || return 1
done
(cd "${BIN_DIR}" && sha256sum ${BINARIES} 2>/dev/null || shasum -a 256 ${BINARIES})
}

View file

@ -35,11 +35,11 @@ nodes:
{ role: host, image: debian12, cpus: 4, memory: 16384,
segments: [underlay, lan], addresses: { underlay: 192.168.14.11, lan: 10.33.0.11 },
frr: frr/hv1.conf, provision: provision/hypervisor.sh,
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin },
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin, scripts: scripts },
services: [agent.service] }
hv2:
{ role: host, image: debian12, cpus: 4, memory: 16384,
segments: [underlay, lan], addresses: { underlay: 192.168.14.12, lan: 10.33.0.12 },
frr: frr/hv2.conf, provision: provision/hypervisor.sh,
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin },
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts },
services: [agent.service] }

View file

@ -35,18 +35,18 @@ nodes:
{ role: host, image: debian12, cpus: 4, memory: 16384,
segments: [underlay, lan], addresses: { underlay: 192.168.14.11, lan: 10.33.0.11 },
frr: frr/hv1.conf, provision: provision/hypervisor.sh,
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin },
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/two.yml, bin: bin, scripts: scripts },
services: [agent.service] }
hv2:
{ role: host, image: debian12, cpus: 4, memory: 16384,
segments: [underlay, lan], addresses: { underlay: 192.168.14.12, lan: 10.33.0.12 },
frr: frr/hv2.conf, provision: provision/hypervisor.sh,
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin },
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts },
services: [agent.service] }
hv3:
{ role: host, image: debian12, cpus: 4, memory: 16384, segments: [underlay],
addresses: { underlay: 192.168.14.13 }, frr: frr/hv3.conf, provision: provision/hypervisor.sh,
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin },
post_provision: provision/hypervisor-post.sh, files: { agent.yml: agent/dnsmasq.yml, bin: bin, scripts: scripts },
services: [agent.service] }
bd1:
{ role: host, image: debian12, cpus: 1, memory: 1024, segments: [underlay],

View file

@ -1,16 +1,16 @@
#!/bin/sh
set -eu
VNI=66001
VNI=1
GATEWAY=240.0.0.1/24
GATEWAY_MAC=02:01:00:01:01:d1
GATEWAY_MAC=02:01:00:00:00:01
DESTINATION=240.255.0.1/32
VTEP=$(ip -4 -o addr show dev "${LAB_UPLINK}" scope global | awk 'NR == 1 {sub("/.*", "", $4); print $4}')
[ -n "${VTEP}" ] || { echo "border: no IPv4 on ${LAB_UPLINK}" >&2; exit 1; }
ip link add br-public type bridge
ip link set br-public address "${GATEWAY_MAC}"
ip link add "vxlan-${VNI}" type vxlan id "${VNI}" local "${VTEP}" dstport 4789 nolearning
ip link set "vxlan-${VNI}" mtu 1500 master br-public
ip link set "vxlan-${VNI}" up
ip link add vxlan-public type vxlan id "${VNI}" local "${VTEP}" dstport 4789 nolearning
ip link set vxlan-public mtu 1500 master br-public
ip link set vxlan-public up
ip link set br-public up
ip addr add "${GATEWAY}" dev br-public
ip link add internet type dummy

View file

@ -1,6 +1,7 @@
#!/bin/sh
set -eu
RELEASE=0.2.0
PUBLIC_VNI=1
GIT_SERVER=https://git.g3e.fr/
REPO=syonad/two
n=0
@ -28,6 +29,11 @@ for script in deploy.sh bootstrap_kvm.sh; do
done
chmod 0755 deploy.sh bootstrap_kvm.sh
bash ./deploy.sh --noup_script -i -u "${LAB_UPLINK}" -t "${RELEASE}"
if [ -f "${LAB_FILES}/scripts/bootstrap_kvm.sh" ]; then
bash -c 'FLAGS_TRUE=0; FLAGS_FALSE=1; . ./deploy.sh && . "$1" && kvm_public_segment "${FLAGS_FALSE}" "${FLAGS_TRUE}" br-000000 br-public "$2"' \
lab "${LAB_FILES}/scripts/bootstrap_kvm.sh" "${PUBLIC_VNI}"
echo "lab: segment public posé par le bootstrap_kvm.sh de l'arbre courant (VNI ${PUBLIC_VNI})"
fi
for binary in "${LAB_FILES}"/bin/*; do
[ -f "${binary}" ] || continue
name=$(basename "${binary}")

View file