-
Notifications
You must be signed in to change notification settings - Fork 17
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
Better, more configurable Docker support #25
Changes from all commits
0916ef4
af99914
eefe95d
51f5c4e
6d47ccb
45cea89
bc9797d
bb30312
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
# CMake | ||
CMakeLists.txt.user | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Testing | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
compile_commands.json | ||
CTestTestfile.cmake | ||
_deps | ||
bin/ | ||
configuration/ | ||
volumes/ | ||
containers/config/htpasswd |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the binaries were added by accident. We can change the CMake scripts to name our executables "cold_benchmarker.x" to help gitignore catch these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies. I of course would make sure that the repository is clean before a merge. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
{ | ||
"config": { | ||
"rdma_device": "", | ||
"rdma_device": "eth0", | ||
"rdma_device_port": 10000, | ||
"resource_manager_address": "", | ||
"resource_manager_port": 0, | ||
"resource_manager_secret": 0 | ||
"resource_manager_address": "172.31.82.200", | ||
"resource_manager_port": 3000, | ||
"resource_manager_secret": 12345 | ||
}, | ||
"executor": { | ||
"use_docker": false, | ||
"repetitions": 100, | ||
"warmup_iters": 0, | ||
"pin_threads": false | ||
"pin_threads": false, | ||
"docker": { | ||
"use_docker": true, | ||
"image": "rfaas-registry/rfaas-base", | ||
"network": "mynet", | ||
"ip": "172.31.82.202", | ||
"volume": "/home/ubuntu/rfaas/containers/opt", | ||
"registry_ip": "172.31.82.200", | ||
"registry_port": 5000 | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build -t rfaas-base:latest - < rfaas-base.Dockerfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# This script builds the rfaas-base docker container, pushes it to the | ||
# registry, sets up a docker volume, and generates example configuration | ||
# json which should then be updated in config/executor_manager.json. | ||
# The script also configures a docker network for suitable use with | ||
# docker_rdma_sriov | ||
|
||
# NOTE: Run this script from repo root, and make sure the sriov docker plugin | ||
# is installed | ||
|
||
set -e | ||
|
||
if [ $# -lt 3 ]; then | ||
echo "usage: ./init_docker.sh <REGISTRY IP> <REGISTRY PORT> <SUBNET>" | ||
exit | ||
fi | ||
|
||
REG_IP=$1 # IP or name of the docker registry | ||
REG_PORT=$2 # Port of the docker registry | ||
SUBNET=$3 # Subnet for the docker network | ||
|
||
IMG_NAME=rfaas-base | ||
REG_IMG=$REG_IP:$REG_PORT/$IMG_NAME | ||
|
||
# Build the docker container, login and push to the registry | ||
sudo docker build -t $IMG_NAME - < containers/rfaas-base.Dockerfile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be simpler not to use Also, it's safer if never request to execute anything with superuser permissions - less likely that any mistake will have bad consequences :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. That is a great point. Principle of least privilege! |
||
echo "built rfaas-base image" | ||
sudo docker login $REG_IP:$REG_PORT | ||
echo "logged into docker daemon" | ||
|
||
if sudo docker push $REG_IMG; then | ||
echo "ERROR: make sure a docker registry is actually running on $REG_IP:$REG_PORT. | ||
Start one with scripts/run_registry.sh" | ||
exit | ||
else | ||
echo "pushed rfaas-base image to $REG_IMG" | ||
fi | ||
|
||
# Set up docker network | ||
net_name=testnet | ||
#sudo docker network create -d sriov --subnet=$SUBNET -o netdevice=$DEVICE $net_name | ||
echo "set up docker network" | ||
|
||
# Configure volume | ||
volume=$(pwd)/volumes/rfaas-test/opt # Do not put a trailing slash | ||
mkdir -p $volume/bin | ||
cp bin/executor $volume/bin | ||
cp examples/libfunctions.so $volume | ||
|
||
# Print json to be updated | ||
config=$(jq -n --arg use_docker "true" \ | ||
--arg image "$REG_IMG" \ | ||
--arg network "$net_name" \ | ||
--arg ip "<ip of container (un-used ip within $SUBNET)>" \ | ||
--arg volume $volume \ | ||
--arg registry_ip "$REG_IP" \ | ||
--arg registry_port "$REG_PORT" \ | ||
'{"docker": { | ||
"use_docker": true, | ||
"image": $image, | ||
"network": $network, | ||
"ip": $ip, | ||
"volume": $volume, | ||
"registry_ip": $registry_ip, | ||
"registry_port": $registry_port | ||
}}' | ||
) | ||
|
||
echo "Update config/executor_manager.json with" | ||
echo "$config" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as for executables :-) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Container version should be same ubuntu version as where `executor` | ||
# was built (due to glibc versioning) | ||
|
||
FROM ubuntu:22.04 | ||
|
||
#ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update -y && apt-get upgrade -y \ | ||
&& apt-get install -y \ | ||
libibverbs-dev librdmacm-dev | ||
|
||
RUN mkdir -p /opt/bin | ||
WORKDIR "/opt/bin" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
sudo docker network create -d sriov --subnet=172.31.80.0/20 -o netdevice=eth0 mynet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The subnet should depend on your local network - maybe we can make it a parameter? Wrapping network initialization is definitely a good idea! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another idea: add a second parameter for two types of networking - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will definitely parameterize this. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
#DOCKER=docker | ||
DOCKER=docker_rdma_sriov | ||
|
||
sudo $DOCKER run --rm --net=host -i --volume /home/ubuntu/rfaas/containers/opt:/opt rfaas-base /opt/executor $1 | ||
|
||
#sudo docker exec -it base /bin/bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
#include <rfaas/connection.hpp> | ||
#include <rfaas/devices.hpp> | ||
#include <rfaas/executor.hpp> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Push an image to the local docker registry | ||
|
||
if [ $# -lt 3 ]; then | ||
echo "usage: ./push_image.sh <IMAGE NAME> <REGISTRY NAME or IP> <REGISTRY PORT>"; | ||
exit | ||
fi | ||
|
||
IMAGE=$1 | ||
IP=$2 | ||
PORT=$3 | ||
docker push $IP:$PORT/$IMAGE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "3" | ||
|
||
services: | ||
registry: | ||
image: registry:2 | ||
container_name: rfaas-registry | ||
ports: | ||
- "5000:5000" | ||
environment: | ||
REGISTRY_AUTH: htpasswd | ||
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd | ||
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm | ||
REGISTRY_STORAGE_DELETE_ENABLED: "true" | ||
#REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt | ||
#REGISTRY_HTTP_TLS_KEY: /certs/domain.unencrypted.key | ||
#REGISTRY_HTTP_SECRET: supersecrettext | ||
volumes: | ||
- /home/ubuntu/rfaas/containers/registry:/var/lib/registry | ||
- /home/ubuntu/rfaas/containers/config:/auth | ||
#- /home/ubuntu/rfaas/containers/config/certs:/certs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# Run this script on the server where you want the docker registry to be hosted | ||
# Recommended to host the registry on the same server as the executor manager | ||
|
||
# NOTE: Run this script from the repo root | ||
|
||
PORT=5000 | ||
NAME="rfaas-registry" | ||
|
||
set -e | ||
|
||
# Make password file if it doesn't already exist | ||
cfg=containers/config | ||
mkdir -p $cfg | ||
if [ -s $cfg/htpasswd ]; then | ||
echo "htpasswd exists" | ||
else | ||
sudo htpasswd -Bc $cfg/htpasswd $USER | ||
echo "created htpasswd file" | ||
fi | ||
|
||
# Generate certs to use TLS (if they dont already exist) | ||
## if [ -s $cfg/certs/domain.key ]; then | ||
## echo "using certs in $cfg/certs" | ||
## else | ||
## mkdir -p $cfg/certs | ||
## openssl genpkey -algorithm RSA -out $cfg/certs/domain.key -aes256 | ||
## | ||
## openssl req -new \ | ||
## -key $cfg/certs/domain.key \ | ||
## -out $cfg/certs/domain.csr \ | ||
## -addext 'subjectAltName = IP:172.31.82.200' | ||
## | ||
## openssl x509 -req -days 365 \ | ||
## -in $cfg/certs/domain.csr \ | ||
## -signkey $cfg/certs/domain.key \ | ||
## -out $cfg/certs/domain.crt | ||
## | ||
## openssl rsa -in $cfg/certs/domain.key -out $cfg/certs/domain.unencrypted.key | ||
## echo "generated certs in $cfg/certs" | ||
## fi | ||
|
||
# Start registry | ||
sudo docker-compose -f scripts/registry.yaml up -d | ||
echo "started docker registry $NAME on port $PORT" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a leftover :-) Did you have trouble with compiling rFaaS on machines with libc++?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps my system was weirdly configured, but compilation with clang only worked with explicit linking of stdc++. However, compilation with gcc worked just fine, so I went with that.