-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM python:3.11-slim | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
ENV DEPS libreadline-dev \ | ||
valgrind \ | ||
libtool-bin \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
protobuf-compiler-grpc \ | ||
libgrpc-dev \ | ||
libgrpc++-dev \ | ||
git \ | ||
make \ | ||
automake \ | ||
build-essential \ | ||
g++ \ | ||
libtool \ | ||
pkg-config \ | ||
ca-certificates \ | ||
libboost-dev \ | ||
libboost-system-dev \ | ||
libboost-thread-dev | ||
|
||
WORKDIR /app | ||
|
||
COPY controller.py /app/ | ||
COPY node_manager.py /app/ | ||
COPY switch_controller.py /app/ | ||
COPY p4runtime_lib /app/p4runtime_lib | ||
COPY requirements.txt /app/ | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt && \ | ||
apt-get update && \ | ||
apt-get install -y --no-install-recommends $DEPS && \ | ||
git clone https://github.com/p4lang/PI.git && \ | ||
cd PI && \ | ||
git checkout 05cb92564af77ae4826565cbde84e3fd4960c6bd && \ | ||
git submodule update --init --recursive && \ | ||
./autogen.sh && \ | ||
./configure --with-proto --without-internal-rpc --without-cli --without-bmv2 && \ | ||
make -j2 && \ | ||
make install-strip && \ | ||
ldconfig && \ | ||
apt-get purge -y $DEPS && \ | ||
apt-get autoremove --purge -y && \ | ||
apt-get clean && \ | ||
rm -rf /app/PI /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
|
||
ENTRYPOINT ["python3", "controller.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
beautifulsoup4==4.12.3 | ||
blinker==1.8.2 | ||
click==8.1.7 | ||
Flask==3.0.3 | ||
grpcio==1.64.1 | ||
grpcio==1.66.1 | ||
itsdangerous==2.2.0 | ||
Jinja2==3.1.4 | ||
MarkupSafe==2.1.5 | ||
protobuf==3.20.0 | ||
protobuf==5.28.0 | ||
scapy==2.5.0 | ||
Werkzeug==3.0.3 | ||
soupsieve==2.6 | ||
Werkzeug==3.0.4 |
13 changes: 13 additions & 0 deletions
13
examples/container_migration_in_kubernetes/config/switches.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"id": 0, | ||
"name": "s1", | ||
"addr": "0.0.0.0:50051", | ||
"proto_dump_file": "/config/s1-p4runtime-requests.txt", | ||
"runtime_file": "/config/s1-runtime.json", | ||
"p4info_file_path": "/config/load_balance.p4.p4info.txt", | ||
"bmv2_file_path": "/config/load_balance.json", | ||
"master": true, | ||
"lb_nodes": [{ "ip": "10.0.2.2", "mac": "08:00:00:00:02:02", "port": 2 }] | ||
} | ||
] |
11 changes: 11 additions & 0 deletions
11
examples/container_migration_in_kubernetes/http-client/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3.11-slim | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app | ||
|
||
COPY main.py /app/ | ||
|
||
RUN pip install requests | ||
|
||
CMD ["python3", "main.py"] |
26 changes: 26 additions & 0 deletions
26
examples/container_migration_in_kubernetes/http-client/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import time | ||
|
||
import requests | ||
|
||
|
||
def main(): | ||
server_ip = os.getenv("SERVER_IP", "localhost") | ||
server_port = os.getenv("SERVER_PORT", "12345") | ||
|
||
server_url = f"http://{server_ip}:{server_port}" | ||
print(f"Connecting to server at: {server_url}") | ||
while True: | ||
try: | ||
response = requests.get(server_url) | ||
print("Server Response:") | ||
print(response.text) | ||
except requests.exceptions.RequestException as e: | ||
print(f"Error connecting to server: {e}") | ||
time.sleep(5) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
33 changes: 33 additions & 0 deletions
33
examples/container_migration_in_kubernetes/manifests/http-client-deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: http-client | ||
labels: | ||
app: http-client | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: http-client | ||
template: | ||
metadata: | ||
labels: | ||
app: http-client | ||
spec: | ||
containers: | ||
- name: http-client | ||
image: docker.io/skosorin/http-client | ||
imagePullPolicy: IfNotPresent | ||
resources: | ||
requests: | ||
memory: "128Mi" | ||
cpu: "0.5" | ||
limits: | ||
memory: "256Mi" | ||
cpu: "1" | ||
env: | ||
# P4 load balancer IP | ||
- name: SERVER_IP | ||
value: "10.0.1.10" | ||
- name: SERVER_PORT | ||
value: "12345" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters