Skip to content

Commit 8468674

Browse files
committed
Docker Swarm - A Multi-Service Multi-Node Web App
1 parent 999e183 commit 8468674

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# A Multi-Service Multi-Node Web App
2+
3+
## Creating networks, volumes, and services for a web-based "cats vs. dogs" voting app.
4+
Here is a basic diagram of how the 5 services will work:
5+
6+
![diagram](./architecture.png)
7+
- All images are on Docker Hub, so all commands are written inside `commands.sh` file. We can paste those commands into `swarm shell`.
8+
- a `backend` and `frontend` overlay networks are needed. Nothing different about them other than that backend will help protect database from the voting web app. (similar to how a VLAN setup might be in traditional architecture)
9+
- The database server should use a named volume for preserving data. Using `--mount` format to do this: `--mount type=volume,source=db-data,target=/var/lib/postgresql/data`
10+
11+
### Services (names below should be service names)
12+
- vote
13+
- adityahajare/examplevotingapp_vote
14+
- web front end for users to vote dog/cat
15+
- ideally published on TCP 80. Container listens on 80
16+
- on frontend network
17+
- 2+ replicas of this container
18+
19+
- redis
20+
- redis:3.2
21+
- key/value storage for incoming votes
22+
- no public ports
23+
- on frontend network
24+
- 1 replica NOTE VIDEO SAYS TWO BUT ONLY ONE NEEDED
25+
26+
- worker
27+
- adityahajare/examplevotingapp_worker:java
28+
- backend processor of redis and storing results in postgres
29+
- no public ports
30+
- on frontend and backend networks
31+
- 1 replica
32+
33+
- db
34+
- postgres:9.4
35+
- one named volume needed, pointing to /var/lib/postgresql/data
36+
- on backend network
37+
- 1 replica
38+
- remember set env for password-less connections -e POSTGRES_HOST_AUTH_METHOD=trust
39+
40+
- result
41+
- adityahajare/examplevotingapp_result
42+
- web app that shows results
43+
- runs on high port since just for admins (lets imagine)
44+
- so run on a high port of your choosing (I choose 5001), container listens on 80
45+
- on backend network
46+
- 1 replica
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
docker network create -d overlay backend
2+
docker network create -d overlay frontend
3+
4+
docker service create --name vote -p 80:80 --network frontend --replicas 2 adityahajare/examplevotingapp_vote
5+
6+
docker service create --name redis --network frontend redis:3.2
7+
8+
docker service create --name db --network backend -e POSTGRES_HOST_AUTH_METHOD=trust --mount type=volume,source=db-data,target=/var/lib/postgresql/data postgres:9.4
9+
10+
docker service create --name worker --network frontend --network backend adityahajare/examplevotingapp_worker:java
11+
12+
docker service create --name result --network backend -p 5001:80 adityahajare/examplevotingapp_result

0 commit comments

Comments
 (0)