Skip to content

Files

Latest commit

 

History

History

10-Swarm-Multi-Service-Multi-Node-Web-App

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

A Multi-Service Multi-Node Web App

Creating networks, volumes, and services for a web-based "cats vs. dogs" voting app.

Here is a basic diagram of how the 5 services will work:

diagram

  • All images are on Docker Hub, so all commands are written inside commands.sh file. We can paste those commands into swarm shell.
  • 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)
  • 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

Services (names below should be service names)

  • vote

    • adityahajare/examplevotingapp_vote
    • web front end for users to vote dog/cat
    • ideally published on TCP 80. Container listens on 80
    • on frontend network
    • 2+ replicas of this container
  • redis

    • redis:3.2
    • key/value storage for incoming votes
    • no public ports
    • on frontend network
    • 1 replica NOTE VIDEO SAYS TWO BUT ONLY ONE NEEDED
  • worker

    • adityahajare/examplevotingapp_worker:java
    • backend processor of redis and storing results in postgres
    • no public ports
    • on frontend and backend networks
    • 1 replica
  • db

    • postgres:9.4
    • one named volume needed, pointing to /var/lib/postgresql/data
    • on backend network
    • 1 replica
    • remember set env for password-less connections -e POSTGRES_HOST_AUTH_METHOD=trust
  • result

    • adityahajare/examplevotingapp_result
    • web app that shows results
    • runs on high port since just for admins (lets imagine)
    • so run on a high port of your choosing (I choose 5001), container listens on 80
    • on backend network
    • 1 replica