|
| 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 | + |
| 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 |
0 commit comments