Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metallb v0.14.8 rock image #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions frr/9.1.0/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: frr
summary: Rock for FRRouting.
description: >
This rock is a drop in replacement for the
quay.io/frrouting/frr image.
version: 9.1.0
license: Apache-2.0

base: ubuntu@22.04
build-base: ubuntu@22.04
platforms:
amd64:
arm64:

entrypoint-service: frr
services:
frr:
command: /usr/sbin/docker-start [ -h ]
override: replace
startup: enabled

parts:
build-deps:
plugin: nil
build-packages:
# Basic build requirements from documentation
- autoconf
- automake
- bison
- build-essential
- flex
- git
- install-info
- libc-ares-dev
- libcap-dev
- libelf-dev
- libjson-c-dev
- libpam0g-dev
- libreadline-dev
- libsnmp-dev
- libsqlite3-dev
- libtool
- make
- perl
- pkg-config
- python3-dev
- python3-sphinx
- texinfo
# Protobuf build requirements
- libprotobuf-c-dev
- protobuf-c-compiler
# Libyang2 extra build requirements
- cmake
- libpcre2-dev
# GRPC extra build requirements
- libgrpc-dev
- libgrpc++-dev
- protobuf-compiler-grpc
# additional requirements
- liblua5.3-dev
- libssl-dev
- lua5.3
- librtr-dev

users:
after: [build-deps]
plugin: nil
overlay-script: |
groupadd -R $CRAFT_OVERLAY -r -g 92 frr
groupadd -R $CRAFT_OVERLAY -r -g 85 frrvty

useradd -R $CRAFT_OVERLAY -r -u 92 -g 85 \
-d /home/frr -s /bin/bash -m frr
usermod -R $CRAFT_OVERLAY -a -G frrvty frr

mkdir -p $CRAFT_OVERLAY/etc/sudoers.d
echo 'frr ALL = NOPASSWD: ALL' | tee $CRAFT_OVERLAY/etc/sudoers.d/frr

libyang:
after: [users]
plugin: nil
source-type: git
source: https://github.com/CESNET/libyang.git
source-tag: v2.1.128
source-depth: 1
override-build: |
mkdir -p build
cd build
mkdir -p $CRAFT_PART_INSTALL/usr

cmake -DCMAKE_INSTALL_PREFIX:PATH=$CRAFT_PART_INSTALL/usr \
-DCMAKE_BUILD_TYPE:String="Release" ..
make -j $(nproc)
make install

frr:
after: [libyang]
plugin: nil
source-type: git
source: https://github.com/FRRouting/frr
source-tag: docker/9.1.0
source-depth: 1
override-build: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CRAFT_STAGE/usr/lib

./bootstrap.sh
./configure \
--prefix=$CRAFT_PART_INSTALL/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=$CRAFT_PART_INSTALL/usr/lib/frr \
--enable-rpki \
--enable-vtysh \
--enable-multipath=64 \
--enable-vty-group=frrvty \
--enable-user=frr \
--enable-group=frr \
--enable-scripting
make -j $(nproc)
make install

mkdir -p $CRAFT_PART_INSTALL/usr/sbin
cp $CRAFT_PART_SRC/docker/debian/docker-start \
$CRAFT_PART_INSTALL/usr/sbin/docker-start

runtime-deps:
plugin: nil
stage-packages:
- libc-ares2
- libcap2
- libjson-c5
- libpam0g
- libreadline8
- libsnmp40
- libsqlite3-0
- libprotobuf-c1
- libpcre2-posix3
- libgrpc++1
- libgrpc10
- liblua5.3-0
- lua5.3
- libssl3
- librtr0
60 changes: 60 additions & 0 deletions metallb/v0.14.8/controller/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: metallb-controller
summary: Rock for the Metallb controller.
description: >
This rock is a drop in replacement for the
quay.io/metallb/controller image.
version: v0.14.8
license: Apache-2.0

base: bare
build-base: ubuntu@22.04
platforms:
amd64:
arm64:

entrypoint-service: controller
services:
controller:
command: /controller [ -h ]
override: replace
startup: enabled

parts:
add-base-files:
plugin: nil
stage-packages:
# Original Dockerfile uses gcr.io/distroless/static:latest as a base.
# This image contains the following:
# https://github.com/GoogleContainerTools/distroless/blob/1533e54a73805ec13fe0cc68218fc7a215a0a6f7/base/README.md
- ca-certificates
- tzdata
- base-passwd

# Can't have stage packages and stage slices together, apparently.
add-base-slices:
plugin: nil
stage-packages:
- base-files_tmp

build-deps:
plugin: nil
build-snaps:
- go/1.22/stable

controller:
after: [build-deps]
plugin: go
source-type: git
source: https://github.com/metallb/metallb
source-tag: v0.14.8
source-depth: 1
override-build: |
GIT_COMMIT=`git rev-parse HEAD`
# We'll use the tag name.
GIT_BRANCH=`git describe --tags --abbrev=0`

CGO_ENABLED=0 go build -v -o $CRAFT_PART_INSTALL/controller \
-ldflags "-X 'go.universe.tf/metallb/internal/version.gitCommit=${GIT_COMMIT}' -X 'go.universe.tf/metallb/internal/version.gitBranch=${GIT_BRANCH}'" \
./controller

cp $CRAFT_PART_BUILD/LICENSE $CRAFT_PART_INSTALL/
72 changes: 72 additions & 0 deletions metallb/v0.14.8/speaker/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: metallb-speaker
summary: Rock for the Metallb speaker.
description: >
This rock is a drop in replacement for the
quay.io/metallb/speaker image.
version: v0.14.8
license: Apache-2.0

base: bare
build-base: ubuntu@22.04
platforms:
amd64:
arm64:

entrypoint-service: speaker
services:
speaker:
command: /speaker [ -h ]
override: replace
startup: enabled

parts:
add-base-files:
plugin: nil
stage-packages:
# Original Dockerfile uses gcr.io/distroless/static:latest as a base.
# This image contains the following:
# https://github.com/GoogleContainerTools/distroless/blob/1533e54a73805ec13fe0cc68218fc7a215a0a6f7/base/README.md
- ca-certificates
- tzdata
- base-passwd
# Helm charts may expect the image to be able to copy some files.
- bash
- coreutils
override-build: |
ln -sf bash "${CRAFT_PART_INSTALL}/bin/sh"

# Can't have stage packages and stage slices together, apparently.
add-base-slices:
plugin: nil
stage-packages:
- base-files_tmp

build-deps:
plugin: nil
build-snaps:
- go/1.22/stable

speaker:
after: [build-deps]
plugin: go
source-type: git
source: https://github.com/metallb/metallb
source-tag: v0.14.8
source-depth: 1
override-build: |
GIT_COMMIT=`git rev-parse HEAD`
# We'll use the tag name.
GIT_BRANCH=`git describe --tags --abbrev=0`

# build frr metrics
CGO_ENABLED=0 go build -v -o $CRAFT_PART_INSTALL/frr-metrics \
-ldflags "-X 'go.universe.tf/metallb/internal/version.gitCommit=${GIT_COMMIT}' -X 'go.universe.tf/metallb/internal/version.gitBranch=${GIT_BRANCH}'" \
./frr-tools/metrics/exporter.go

# build speaker
CGO_ENABLED=0 go build -v -o $CRAFT_PART_INSTALL/speaker \
-ldflags "-X 'go.universe.tf/metallb/internal/version.gitCommit=${GIT_COMMIT}' -X 'go.universe.tf/metallb/internal/version.gitBranch=${GIT_BRANCH}'" \
./speaker

cp $CRAFT_PART_BUILD/LICENSE $CRAFT_PART_INSTALL/
cp $CRAFT_PART_SRC/frr-tools/reloader/frr-reloader.sh $CRAFT_PART_INSTALL/
12 changes: 6 additions & 6 deletions tests/integration/test_metallb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def _get_rock_image(name: str, version: str):
rock = env_util.get_build_meta_info_for_rock_version(name, version, IMG_PLATFORM)
return rock.image


def test_metallb_0_14_5(function_instance: harness.Instance):
@pytest.mark.parametrize("metallb_version,frr_version", [("v0.14.5", "9.0.2"), ("v0.14.8", "9.1.0")])
def test_metallb(function_instance: harness.Instance, metallb_version: str, frr_version: str):
images = [
HelmImage(
uri=_get_rock_image("metallb-controller", "v0.14.5"), prefix="controller"
uri=_get_rock_image("metallb-controller", metallb_version), prefix="controller"
),
HelmImage(uri=_get_rock_image("metallb-speaker", "v0.14.5"), prefix="speaker"),
HelmImage(uri=_get_rock_image("frr", "9.0.2"), prefix="frr"),
HelmImage(uri=_get_rock_image("metallb-speaker", metallb_version), prefix="speaker"),
HelmImage(uri=_get_rock_image("frr", frr_version), prefix="frr"),
]

# We need to run frr as root because of:
Expand All @@ -33,7 +33,7 @@ def test_metallb_0_14_5(function_instance: harness.Instance):
images=images,
namespace=constants.K8S_NS_KUBE_SYSTEM,
repository="https://metallb.github.io/metallb",
chart_version="v0.14.5",
chart_version=metallb_version,
runAsUser=0,
)
helm_command += [
Expand Down
13 changes: 7 additions & 6 deletions tests/sanity/test_frr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
IMG_PLATFORM = "amd64"
IMG_NAME = "frr"

V9_0_2_EXPECTED_FILES = [
EXPECTED_FILES = [
"/usr/sbin/docker-start",
"/usr/lib/frr/watchfrr",
]

# Just a line that the help string is expected to contain.
V9_0_2_EXPECTED_HELPSTR = "Watchdog program to monitor status of frr daemons"
EXPECTED_HELPSTR = "Watchdog program to monitor status of frr daemons"


def test_sanity():
@pytest.mark.parametrize("frr_version", ["9.0.2", "9.1.0"])
def test_sanity(frr_version: str):
rock = env_util.get_build_meta_info_for_rock_version(
IMG_NAME, "9.0.2", IMG_PLATFORM
IMG_NAME, frr_version, IMG_PLATFORM
)

# check rock filesystem
docker_util.ensure_image_contains_paths(rock.image, V9_0_2_EXPECTED_FILES)
docker_util.ensure_image_contains_paths(rock.image, EXPECTED_FILES)

docker_run = docker_util.run_in_docker(
rock.image, ["/usr/lib/frr/watchfrr", "--help"]
)
assert V9_0_2_EXPECTED_HELPSTR in docker_run.stdout
assert EXPECTED_HELPSTR in docker_run.stdout
Loading