Skip to content

Commit 0917fd5

Browse files
committed
Update readme and setup environment files
1 parent 8a136c3 commit 0917fd5

File tree

3 files changed

+98
-38
lines changed

3 files changed

+98
-38
lines changed

README.md

+16-23
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This way, we can run several emulated edge nodes by simply executing multiple Do
4848
- Docker CE 25.0.1
4949
- Sysbox CE 0.6.3
5050

51-
#### Setup environment using the Ansible playbook
51+
#### Setup environment and deploy using the Ansible playbook
5252

5353
Install [Ansible](https://www.ansible.com/), an agentless automation tool that you install on a single host, referred to as the control node.
5454
Then, using the [setup_playbook.yaml](setup_playbook.yaml) file, your Ansible control node can setup the environment to execute DFaaS on the managed node(s) specified in an inventory file.
@@ -69,13 +69,16 @@ Run the `ansible-playbook` command on the control node to execute the tasks spec
6969

7070
`-i` : path to an inventory file
7171
`--extra-vars` : to specify the Sysbox version and shiftfs branch to be installed
72+
`--tags` : to specify steps of the playbook to be executed
7273

7374
> The following command assumes you are using Ubuntu 22.04 LTS with kernel version 5.15 or 5.16.
7475

7576
```shell
76-
ansible-playbook -i inventory.yaml setup_playbook.yaml --extra-vars "sysbox_ver=0.6.3 shiftfs_ver=k5.16"
77+
ansible-playbook -i inventory.yaml setup_playbook.yaml --extra-vars "sysbox_ver=0.6.3 shiftfs_ver=k5.16" --tags "installation, deploy"
7778
```
7879

80+
This Ansible playbook installs the required software and executes the [docker-compose.yml](docker-compose.yml), deploying three DFaaS nodes containers, and a fourth container called [operator](operator), which deploys functions on DFaaS nodes and starts specified load tests.
81+
7982
#### Manual
8083

8184
_Ansible_
@@ -95,20 +98,6 @@ You can follow the [official user guide](https://github.com/nestybox/sysbox/blob
9598
> We instead recommend installing [shiftfs](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-package.md#installing-shiftfs)
9699
> according to your kernel version as suggested by the Sysbox CE user guide.
97100

98-
### Build Docker images
99-
100-
```shell
101-
# Paths assume you are executing from the project root directory
102-
docker build -t dfaas-agent-builder:latest -f docker/dfaas-agent-builder.dockerfile dfaasagent
103-
docker build -t dfaas-node:latest -f docker/dfaas-node.dockerfile docker
104-
```
105-
106-
### Run a 3 nodes network via Docker Compose
107-
See the provided [docker-compose.yml](docker-compose.yml) file for technical details.
108-
```shell
109-
docker compose up -d
110-
```
111-
112101
### Deploy functions
113102
This script deploy the same set of functions on each of the nodes by using [docker/files/deploy_functions.sh](docker/files/deploy_functions.sh).
114103
The [deploy_functions.sh](docker/files/deploy_functions.sh) script waits for the OpenFaaS gateway to be up (max 20 retries, 10s delay),
@@ -125,6 +114,8 @@ the default name you get when using the provided docker-compose.yml file.
125114
./utils/deploy-functions-to-nodes.sh 3 "dfaas-node-" "-1"
126115
```
127116

117+
Alternatively you can exploit the deployment functionalities of the [operator](operator).
118+
128119
### Invoke a function
129120
Each node exposes port `808x:80` (e.g., `node-1` exposed port is `8081:80`), where port `80` is the HAProxy port.
130121
This example assumes you run DFaaS nodes via Docker Compose with the provided [docker-compose.yml](docker-compose.yml) file.
@@ -163,10 +154,11 @@ jq -ncM '{method: "GET", url: "http://localhost:8081/function/figlet", body: "He
163154
vegeta report -every=200ms
164155
```
165156

157+
You can also start multiple parallel Vegeta attacks exploiting [operator](operator) functionalities.
158+
166159
### Create plots from vegeta results
167-
You can produce some plots from vegeta results by exploiting the `vegeta plot` command or
168-
our [utils/plot.py](utils/plot.py) script.
169-
To use our script, you need to install the required Python packages listed in [utils/plot-requirements.txt](utils/plot-requirements.txt).
160+
You can produce some plots from vegeta results by exploiting the `vegeta plot` command or our [plot-results.py](operator/docker/files/plot-results.py) script, which is automatically executed after tests execution with the [operator](operator).
161+
To use our script, you need to install the required Python packages listed in [plot-requirements.txt](operator/docker/files/plot-requirements.txt).
170162

171163
```shell
172164
# Encode results as JSON
@@ -175,10 +167,11 @@ cat $VEGFOLDER/results.bin | vegeta encode > $VEGFOLDER/results.json
175167
# Create plot with vegeta
176168
cat cat $VEGFOLDER/results.bin | vegeta plot > $VEGFOLDER/plot.html
177169
178-
# 1st arg: path int results.json
179-
# 2nd arg: path output plot
180-
# 3rd arg: rate req/s used for the attack
181-
./utils/plot.py $VEGFOLDER/results.json $VEGFOLDER/plot.png 50
170+
# 1st arg: path results.json
171+
# 2nd arg: path output folder
172+
# 3rd arg: rate req/s used for the attack (if merged is True specify rate=0)
173+
# 4th arg: boolean merged (is the input file merged from multiple attacks?)
174+
./operator/docker/files/plot-results.py $VEGFOLDER/results.json $VEGFOLDER/plots 50 False
182175
```
183176

184177
### Forwarding traffic as a malicious node

docker-compose.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ services:
5151
operator:
5252
image: dfaas-operator:latest
5353
build:
54-
context: ./docker
55-
dockerfile: docker/dfaas-operator.dockerfile
54+
context: ./operator/docker
55+
dockerfile: ./operator/docker/dfaas-operator.dockerfile
5656
env_file:
57-
- dfaasoperator.env
57+
- ./operator/dfaasoperator.env
5858
volumes:
59-
- $HOME/vegeta-results:/vegeta-results
59+
- $HOME:/tests
6060
networks:
6161
p2p-overlay:
6262

setup_playbook.yaml

+78-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- name: Update apt packages
1212
apt:
1313
update_cache: true
14+
tags:
15+
- installation
1416

1517
- name: Install required system packages
1618
apt:
@@ -29,54 +31,70 @@
2931
- apt-transport-https
3032
- software-properties-common
3133
- git
34+
tags:
35+
- installation
3236

3337
- name: Create directory for Docker's GPG key
3438
file:
3539
path: /etc/apt/keyrings
3640
state: directory
3741
mode: '0755'
42+
tags:
43+
- installation
3844

3945
- name: Add Docker's official GPG key
4046
apt_key:
4147
url: https://download.docker.com/linux/ubuntu/gpg
4248
keyring: /etc/apt/keyrings/docker.gpg
4349
state: present
50+
tags:
51+
- installation
4452

4553
- name: Change GPG key permissions
4654
file:
4755
path: /etc/apt/keyrings/docker.gpg
4856
state: file
4957
mode: 'a+r'
58+
tags:
59+
- installation
5060

5161
- name: Set up the stable repository
5262
apt_repository:
5363
repo: deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
5464
filename: docker
5565
state: present
5666
update_cache: true
67+
tags:
68+
- installation
5769

5870
- name: Install Docker and related packages
5971
apt:
6072
name: "{{ item }}"
6173
state: present
6274
update_cache: true
6375
loop:
64-
- docker-ce=5:27.0.3-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
65-
- docker-ce-cli=5:27.0.3-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
76+
- docker-ce=5:27.1.1-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
77+
- docker-ce-cli=5:27.1.1-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
6678
- containerd.io
6779
- docker-buildx-plugin
6880
- docker-compose-plugin
81+
tags:
82+
- installation
6983

7084
- name: Add Docker group
7185
group:
7286
name: docker
7387
state: present
88+
tags:
89+
- installation
7490

7591
- name: Add user to docker group
7692
user:
7793
name: "{{ ansible_user_id }}"
7894
groups: "docker"
7995
append: true
96+
tags:
97+
- installation
8098

8199
- name: Enable and start Docker services
82100
systemd:
@@ -86,51 +104,100 @@
86104
loop:
87105
- docker.service
88106
- containerd.service
107+
tags:
108+
- installation
89109

90110
- name: Create sysbox directory
91111
file:
92112
path: ./sysbox
93113
state: directory
114+
tags:
115+
- installation
94116

95117
- name: Download sysbox package
96118
get_url:
97119
url:
98120
https://downloads.nestybox.com/sysbox/releases/v{{ sysbox_ver }}/sysbox-ce_{{ sysbox_ver }}-0.linux_{{ arch_mapping[ansible_architecture] | default(ansible_architecture) }}.deb
99121
dest: ./sysbox/sysbox-ce.deb
122+
tags:
123+
- installation
100124

101125
- name: Install sysbox package
102126
apt: deb=./sysbox/sysbox-ce.deb
127+
tags:
128+
- installation
103129

104130
- name: Git clone shiftfs repository
105131
git:
106132
repo: https://github.com/toby63/shiftfs-dkms.git
107133
dest: ./shiftfs-{{ shiftfs_ver }}
108134
single_branch: yes
109135
version: '{{ shiftfs_ver }}'
136+
tags:
137+
- installation
110138

111139
- name: Update kernel
112140
shell: ./shiftfs-{{ shiftfs_ver }}/update1
141+
tags:
142+
- installation
113143

114144
- name: Build Makefile
115145
make:
116146
chdir: ./shiftfs-{{ shiftfs_ver }}
117147
file: Makefile.dkms
118-
- name: Git clone dfaas repository
119-
git:
120-
repo: https://github.com/UNIMIBInside/dfaas.git
121-
dest: ./dfaas-repo
122-
single_branch: yes
123-
version: stecattaneo-dev
148+
tags:
149+
- installation
150+
151+
- name: Copy dfaasagent directory
152+
ansible.builtin.copy:
153+
src: ./dfaasagent
154+
dest: ~/dfaas/
155+
tags:
156+
- deploy
157+
158+
- name: Copy docker directory
159+
ansible.builtin.copy:
160+
src: ./docker
161+
dest: ~/dfaas/
162+
tags:
163+
- deploy
164+
165+
- name: Copy docker compose file
166+
ansible.builtin.copy:
167+
src: ./docker-compose.yml
168+
dest: ~/dfaas/
169+
tags:
170+
- deploy
171+
172+
- name: Copy ENV file
173+
ansible.builtin.copy:
174+
src: ./dfaasagent.env
175+
dest: ~/dfaas/dfaasagent.env
176+
tags:
177+
- deploy
178+
179+
- name: Copy Operator directory
180+
ansible.builtin.copy:
181+
src: ./operator
182+
dest: ~/dfaas/
183+
tags:
184+
- deploy
185+
124186
- name: Build Docker images
125187
ansible.builtin.command:
126-
chdir: ./dfaas-repo
188+
chdir: ~/dfaas
127189
cmd: "{{ item }}"
128190
loop:
129191
- "docker build -t dfaas-agent-builder:latest -f docker/dfaas-agent-builder.dockerfile dfaasagent"
130192
- "docker build -t dfaas-node:latest -f docker/dfaas-node.dockerfile docker"
131-
- "docker build -t dfaas-operator:latest -f docker/dfaas-operator.dockerfile docker"
193+
- "docker build -t dfaas-operator:latest -f operator/docker/dfaas-operator.dockerfile operator/docker"
194+
tags:
195+
- deploy
196+
132197
- name: Deploy Docker Compose stack
133198
ansible.builtin.command:
134-
chdir: ./dfaas-repo
199+
chdir: ~/dfaas
135200
cmd: docker compose up -d
201+
tags:
202+
- deploy
136203

0 commit comments

Comments
 (0)