Bez popisu

Bret Fisher 226edf0184 compose and K8s file cleanup (#273) před 2 roky
.github f0fb81f707 Adding docker hub to push list (#271) před 2 roky
healthchecks 383b74158e healthchecks! move to compose spec version! před 4 roky
k8s-specifications 226edf0184 compose and K8s file cleanup (#273) před 2 roky
result 3ccc624fd7 update result node.js deps for multi-arch před 2 roky
seed-data a33c638b2f adding data seeding před 4 roky
vote 89e063d047 Update TargetFramework to 3.1 před 4 roky
worker 7e7445a601 Clean up worker service (#272) před 2 roky
.gitignore 4350dd6738 ignore node_modules in git and docker build před 5 roky
LICENSE e41af6b81c Add LICENSE and MAINTAINERS před 9 roky
MAINTAINERS af94bc5c08 added new maintainers! před 4 roky
README.md 226edf0184 compose and K8s file cleanup (#273) před 2 roky
architecture.png 82fd54e28f Update architecture diagram před 9 roky
docker-compose.images.yml 226edf0184 compose and K8s file cleanup (#273) před 2 roky
docker-compose.yml 226edf0184 compose and K8s file cleanup (#273) před 2 roky
docker-stack.yml 226edf0184 compose and K8s file cleanup (#273) před 2 roky

README.md

Example Voting App

A simple distributed application running across multiple Docker containers.

Getting started

Download Docker Desktop for Mac or Windows. Docker Compose will be automatically installed. On Linux, make sure you have the latest version of Compose.

This solution uses Python, Node.js, .NET, with Redis for messaging and Postgres for storage.

Run in this directory to build and run the app:

docker compose up

The vote app will be running at http://localhost:5000, and the results will be at http://localhost:5001.

Alternately, if you want to run it on a Docker Swarm, first make sure you have a swarm. If you don't, run:

docker swarm init

Once you have your swarm, in this directory run:

docker stack deploy --compose-file docker-stack.yml vote

Run the app in Kubernetes

The folder k8s-specifications contains the YAML specifications of the Voting App's services.

Run the following command to create the deployments and services objects in the vote namespace:

kubectl create -f k8s-specifications/
vote "vote" created
deployment "db" created
deployment "db" created
service "db" created
deployment "redis" created
service "redis" created
deployment "result" created
service "result" created
deployment "vote" created
service "vote" created
deployment "worker" created

The vote interface is then available on port 31000 on each host of the cluster, the result one is available on port 31001.

Architecture

Architecture diagram

  • A front-end web app in Python which lets you vote between two options
  • A Redis which collects new votes
  • A .NET worker which consumes votes and stores them in…
  • A Postgres database backed by a Docker volume
  • A Node.js web app which shows the results of the voting in real time

Notes

The voting application only accepts one vote per client browser. It does not register additional votes if a vote has already been submitted from a client.

This isn't an example of a properly architected perfectly designed distributed app... it's just a simple example of the various types of pieces and languages you might see (queues, persistent data, etc), and how to deal with them in Docker at a basic level.