Skip to content
Open
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
2 changes: 2 additions & 0 deletions bincompat-traefik3.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/workdir/
/rootfs/
48 changes: 48 additions & 0 deletions bincompat-traefik3.0/.scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Scripts for Bincompat Traefik on Unikraft

These are companions instruction to the main instructions in the [`README`](README.md).

Use scripts as quick actions for building and running the bincompat Traefik application on Unikraft:

**Note**: Run scripts from the application directory.

## Build for <plat> / <arch>:

```console
./.scripts/build/<plat>.<arch>
```

e.g.:

```console
./.scripts/build/qemu.x86_64
./.scripts/build/fc.x86_64
```

## Build for <plat> / <arch> using a different compiler

```console
CC=/path/to/compiler ./.scripts/build/<plat>.<arch>
```

e.g.

```console
CC=/usr/bin/gcc-12 ./.scripts/build/qemu.x86_64
CC=/usr/bin/clang ./.scripts/build/qemu.x86_64
CC=/usr/bin/gcc-12 ./.scripts/build/fc.x86_64
CC=/usr/bin/clang ./.scripts/build/fc.x86_64
```

## Run on <plat> / <arch>

```console
./.scripts/run/<plat>.<arch>
```

e.g.

```console
./.scripts/run/qemu.x86_64
./.scripts/run/fc.x86_64
```
4 changes: 4 additions & 0 deletions bincompat-traefik3.0/.scripts/build/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

./.scripts/build/rootfs.x86_64
./.scripts/build/kernel.fc.x86_64
4 changes: 4 additions & 0 deletions bincompat-traefik3.0/.scripts/build/kernel.fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

. ./.scripts/common.sh
build_elfloader_base fc.x86_64
4 changes: 4 additions & 0 deletions bincompat-traefik3.0/.scripts/build/kernel.qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

. ./.scripts/common.sh
build_elfloader_base qemu.x86_64
4 changes: 4 additions & 0 deletions bincompat-traefik3.0/.scripts/build/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

./.scripts/build/rootfs.x86_64
./.scripts/build/kernel.qemu.x86_64
5 changes: 5 additions & 0 deletions bincompat-traefik3.0/.scripts/build/rootfs.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

rm -f initrd.cpio
docker build -o ./rootfs -f Dockerfile .
./workdir/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/
22 changes: 22 additions & 0 deletions bincompat-traefik3.0/.scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

elfloader_net="elfloader-net"

if ! test -d workdir; then
mkdir workdir
fi

ln -sfn "../../$elfloader_net/workdir" workdir/base

build_elfloader_base()
{
APP_DIR=$(pwd)

(
cd "../$elfloader_net" &&
./setup.sh &&
make distclean &&
make defconfig UK_DEFCONFIG="$APP_DIR/.scripts/defconfig/$1" &&
make -j$(nproc)
) || exit 1
}
36 changes: 36 additions & 0 deletions bincompat-traefik3.0/.scripts/defconfig/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CONFIG_PLAT_KVM=y
CONFIG_KVM_VMM_FIRECRACKER=y
CONFIG_ARCH_X86_64=y
CONFIG_APPELFLOADER_DEPENDENCIES=y
CONFIG_APPELFLOADER_BRK=y
CONFIG_APPELFLOADER_CUSTOMAPPNAME=y
CONFIG_APPELFLOADER_STACK_NBPAGES=128
CONFIG_APPELFLOADER_VFSEXEC_EXECBIT=n
CONFIG_APPELFLOADER_VFSEXEC=y
CONFIG_APPELFLOADER_HFS=y
CONFIG_APPELFLOADER_HFS_ETCRESOLVCONF=y
CONFIG_APPELFLOADER_HFS_ETCHOSTS=y
CONFIG_APPELFLOADER_HFS_ETCHOSTNAME=y
CONFIG_APPELFLOADER_HFS_REPLACEEXIST=y
CONFIG_LIBPOSIX_PROCESS_ARCH_PRCTL=y
CONFIG_LIBVFSCORE=y
CONFIG_LIBVFSCORE_AUTOMOUNT_UP=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBDEVFS=y
CONFIG_LIBDEVFS_AUTOMOUNT=y
CONFIG_LIBUKBOOT_MAINTHREAD=y=y
CONFIG_LIBUKBOOT_SHUTDOWNREQ_HANDLER=y
CONFIG_LIBPOSIX_PROCESS_MULTITHREADING=y
CONFIG_LIBPOSIX_FUTEX=y
CONFIG_LIBPOSIX_EVENT=y

# Networking support
CONFIG_LIBLWIP=y
CONFIG_LIBUKNETDEV_EINFO_LIBPARAM=y

# Uncomment for debugging.
#CONFIG_LIBUKDEBUG_PRINTD=y
#CONFIG_LIBUKDEBUG_PRINTK_INFO=y
#CONFIG_LIBSYSCALL_SHIM_STRACE=y
#CONFIG_LIBSYSCALL_SHIM_DEBUG=y
36 changes: 36 additions & 0 deletions bincompat-traefik3.0/.scripts/defconfig/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CONFIG_PLAT_KVM=y
CONFIG_KVM_VMM_QEMU=y
CONFIG_ARCH_X86_64=y
CONFIG_APPELFLOADER_DEPENDENCIES=y
CONFIG_APPELFLOADER_BRK=y
CONFIG_APPELFLOADER_CUSTOMAPPNAME=y
CONFIG_APPELFLOADER_STACK_NBPAGES=128
CONFIG_APPELFLOADER_VFSEXEC_EXECBIT=n
CONFIG_APPELFLOADER_VFSEXEC=y
CONFIG_APPELFLOADER_HFS=y
CONFIG_APPELFLOADER_HFS_ETCRESOLVCONF=y
CONFIG_APPELFLOADER_HFS_ETCHOSTS=y
CONFIG_APPELFLOADER_HFS_ETCHOSTNAME=y
CONFIG_APPELFLOADER_HFS_REPLACEEXIST=y
CONFIG_LIBPOSIX_PROCESS_ARCH_PRCTL=y
CONFIG_LIBVFSCORE=y
CONFIG_LIBVFSCORE_AUTOMOUNT_UP=y
CONFIG_LIBRAMFS=y
CONFIG_LIBUKCPIO=y
CONFIG_LIBDEVFS=y
CONFIG_LIBDEVFS_AUTOMOUNT=y
CONFIG_LIBUKBOOT_MAINTHREAD=y=y
CONFIG_LIBUKBOOT_SHUTDOWNREQ_HANDLER=y
CONFIG_LIBPOSIX_PROCESS_MULTITHREADING=y
CONFIG_LIBPOSIX_FUTEX=y
CONFIG_LIBPOSIX_EVENT=y

# Networking support
CONFIG_LIBLWIP=y
CONFIG_LIBUKNETDEV_EINFO_LIBPARAM=y

# Uncomment for debugging.
#CONFIG_LIBUKDEBUG_PRINTD=y
#CONFIG_LIBUKDEBUG_PRINTK_INFO=y
#CONFIG_LIBSYSCALL_SHIM_STRACE=y
#CONFIG_LIBSYSCALL_SHIM_DEBUG=y
38 changes: 38 additions & 0 deletions bincompat-traefik3.0/.scripts/run/fc.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

if test ! -f initrd.cpio; then
echo "No initrd.cpio file found." 1>&2
echo "Did you run the build script?" 1>&2
exit 1
fi

base_kernel="workdir/base/build/elfloader_fc-x86_64"
if test ! -f "$base_kernel"; then
echo "No kernel file $base_kernel." 1>&2
echo "Did you run the build script?" 1>&2
exit 1
fi

{
# Remove previously created network interfaces.
sudo ip link set dev virbr0 down
sudo ip link del dev virbr0
sudo ip link set dev tap0 down
sudo ip link del dev tap0
} > /dev/null 2>&1

# Create tap interface for Firecracker networking.
sudo ip tuntap add dev tap0 mode tap
sudo ip address add 172.44.0.1/24 dev tap0
sudo ip link set dev tap0 up

# Pack filesystem as an initial ramdisk CPIO file.
rm -f initrd.cpio
../repos/unikraft/support/scripts/mkcpio initrd.cpio ./rootfs/
Comment on lines +29 to +31

# Remove previously created files.
rm -f firecracker.socket

firecracker-x86_64 \
--api-sock firecracker.socket \
--config-file fc.x86_64.json
37 changes: 37 additions & 0 deletions bincompat-traefik3.0/.scripts/run/qemu.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

if test ! -f initrd.cpio; then
echo "No initrd.cpio file found." 1>&2
echo "Did you run the build script?" 1>&2
exit 1
fi

base_kernel="workdir/base/build/elfloader_qemu-x86_64"
if test ! -f "$base_kernel"; then
echo "No kernel file $base_kernel." 1>&2
echo "Did you run the build script?" 1>&2
exit 1
fi

{
# Remove previously created network interface.
sudo ip link set dev virbr0 down
sudo ip link del dev virbr0
sudo ip link set dev tap0 down
sudo ip link del dev tap0
} > /dev/null 2>&1

# Create bridge interface for QEMU networking.
sudo ip link add dev virbr0 type bridge
sudo ip address add 172.44.0.1/24 dev virbr0
sudo ip link set dev virbr0 up
Comment on lines +24 to +27

sudo qemu-system-x86_64 \
-nographic \
-enable-kvm \
-m 2048 \
-cpu max \
-netdev bridge,id=en0,br=virbr0 -device virtio-net-pci,netdev=en0 \
-append "traefik netdev.ip=172.44.0.2/24:172.44.0.1::: vfs.fstab=[ \"initrd0:/:extract::ramfs=1:\" ] -- /usr/local/bin/traefik --providers.file.watch=false --providers.file.filename=/etc/traefik/config.yml --api.insecure=true" \
-kernel "$base_kernel" \
-initrd ./initrd.cpio
1 change: 1 addition & 0 deletions bincompat-traefik3.0/.scripts/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/log/
14 changes: 14 additions & 0 deletions bincompat-traefik3.0/.scripts/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Testing Traefik on Unikraft

These are companion instructions to the main instructions in the [`README`](../../README.md) and to the scripted run instructions in the [`.scripts/README`](../README.md).
Use these scripts to test Traefik on Unikraft.

**Note**: Run scripts from the application directory.

Use the `all.sh` script to test all builds and all available runs:

```console
./.scripts/test/all.sh
```

Logs are stored in the `./.scripts/test/log/` directory.
31 changes: 31 additions & 0 deletions bincompat-traefik3.0/.scripts/test/all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

test_build()
{
printf "%-46s ... " build."$1"
./.scripts/build/"$1" > ./.scripts/test/log/build."$1" 2>&1
if test $? -eq 0; then
echo "PASSED"
else
echo "FAILED"
fi
}

test_build_run()
{
printf "%-46s ... " build."$1"
./.scripts/build/"$1" > ./.scripts/test/log/build."$1" 2>&1
if test $? -eq 0; then
echo "PASSED"
else
echo "FAILED"
fi

printf " %-42s ... " run."$1"
./.scripts/test/wrapper.sh ./.scripts/run/"$1" 2> ./.scripts/test/log/run."$1"
}

./setup.sh
test -d ./.scripts/test/log || mkdir ./.scripts/test/log
test_build_run qemu.x86_64
test_build_run fc.x86_64
Loading