This repository is about the DCN project of NYU. Students should implement a simple email clients/servers (SMTP, POP3) and HTTP servers based on Flask, and then deploy them using Docker and Kubernetes. There was a time that people can access the public IP address to experience how email clients and servers work. However, after the semester ends, the free account to access IBM Kubernetes server was also retracted by our teacher, thus you can only test those files locally, and the testing methods can be seen on Part 2.
To access the whole document for the project, please visit this link, the extraction code is t0h6.
Public IP (Now aborted) : 169.57.112.50
Port Mapping:
Server Name | Local Port | k8s Port |
---|---|---|
AU (PORT1) | 5000 | 30000 |
AE (PORT2) | 6000 | 30001 |
BE (PORT3) | 7000 | 30002 |
BU (PORT4) | 53533 | 30003 |
Test case
Alice send email:
http://169.57.112.50:30000/email?from=169.57.112.50:30001&to=169.57.112.50:30002&message=hi.
Bob retrieve email:
http://169.57.112.50:30003/email?from=169.57.112.50:30002
First, run four web servers. In order to do this, you need to start four command line interfaces such as powershell or cmd. In each CLI, type the following commands:
cd AU
python AU.py
cd AE
python AE.py
cd BE
python BE.py
cd BU
python BU.py
The port number of each server is shown as blow:
Server Name | Port |
---|---|
AU | 5000 |
AE | 6000 |
BE | 7000 |
BU | 53533 |
Then, use the following test case:
Alice send email:
http://localhost:5000/email?from=localhost:6000&to=localhost:7000&message=hi.
Bob retrieve email:
http://localhost:53533/email?from=localhost:7000
In this way, Alice sent a email with the content "hi." to Bob through her agent server AU, and Bob will read the email through his agent server BU during his spare time.
Suppose you are in the root directory of the project, then type in the following commands through CLI. Remember to change the parameters accordingly.
cd AU
docker build -t USERNAME/au:latest .
cd ../AE
docker build -t USERNAME/ae:latest .
cd ../BE
docker build -t USERNAME/be:latest .
cd ../BU
docker build -t USERNAME/bu:latest .
To see if you have already built the four images successfully, use the following command:
docker image ls
To get servers running within Docker containers communicate with each other, you should create a Docker network with the following command:
docker network create N_Name
Once created network, run the containers by specifying the network name:
docker run --network N_Name --name C_Name -p PORT1:PORT1 -it USERNAME/au:latest
docker run --network N_Name --name C_Name -p PORT2:PORT2 -it USERNAME/ae:latest
docker run --network N_Name --name C_Name -p PORT3:PORT3 -it USERNAME/bu:latest
docker run --network N_Name --name C_Name -p PORT4:PORT4 -it USERNAME/be:latest
Once the servers have started, use docker inspect N_Name
command to see the IP address of AE and BE, then use the IP address of AE and BE instead of localhost
.
Alice send email:
http://localhost:5000/email?from=IP_AE:6000&to=IP_BE:7000&message=hi.
Bob retrieve email:
http://localhost:53533/email?from=IP_BE:7000
docker login
docker push USERNAME/au:latest
docker push USERNAME/ae:latest
docker push USERNAME/be:latest
docker push USERNAME/bu:latest
kubectl apply -f deploy_email.yml
Alice send email:
http://169.57.112.50:30000/email?from=169.57.112.50:30001&to=169.57.112.50:30002&message=hi.
Bob retrieve email: