|
1 |
| -Example Voting App |
2 |
| -========= |
| 1 | +## Assignment#06-Kubernetes with hand-on lab |
| 2 | +## Project Overview |
3 | 3 |
|
4 |
| -A simple distributed application running across multiple Docker containers. |
| 4 | +This repository is used as part of a class lab exercise to deploy a microservices-based voting application on Kubernetes using Minikube. It demonstrates the use of Kubernetes Deployments, Services, and Scaling. |
| 5 | +## Original Source |
| 6 | +This project is adapted from [kodekloudhub/example-voting-app](https://github.com/kodekloudhub/example-voting-app). for educational purposes. |
5 | 7 |
|
6 |
| -Getting started |
7 |
| ---------------- |
8 | 8 |
|
9 |
| -Download [Docker Desktop](https://www.docker.com/products/docker-desktop) for Mac or Windows. [Docker Compose](https://docs.docker.com/compose) will be automatically installed. On Linux, make sure you have the latest version of [Compose](https://docs.docker.com/compose/install/). |
10 |
| - |
11 |
| - |
12 |
| -## Linux Containers |
13 |
| - |
14 |
| -The Linux stack uses Python, Node.js, .NET Core (or optionally Java), with Redis for messaging and Postgres for storage. |
15 |
| - |
16 |
| -> If you're using [Docker Desktop on Windows](https://store.docker.com/editions/community/docker-ce-desktop-windows), you can run the Linux version by [switching to Linux containers](https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers), or run the Windows containers version. |
17 |
| -
|
18 |
| -Run in this directory: |
19 |
| -``` |
20 |
| -docker-compose up |
21 |
| -``` |
22 |
| -The app will be running at [http://localhost:5000](http://localhost:5000), and the results will be at [http://localhost:5001](http://localhost:5001). |
23 |
| - |
24 |
| -Alternately, if you want to run it on a [Docker Swarm](https://docs.docker.com/engine/swarm/), first make sure you have a swarm. If you don't, run: |
25 |
| -``` |
26 |
| -docker swarm init |
27 |
| -``` |
28 |
| -Once you have your swarm, in this directory run: |
29 |
| -``` |
30 |
| -docker stack deploy --compose-file docker-stack.yml vote |
31 |
| -``` |
32 |
| - |
33 |
| -## Windows Containers |
34 |
| - |
35 |
| -An alternative version of the app uses Windows containers based on Nano Server. This stack runs on .NET Core, using [NATS](https://nats.io) for messaging and [TiDB](https://github.com/pingcap/tidb) for storage. |
36 |
| - |
37 |
| -You can build from source using: |
38 |
| - |
39 |
| -``` |
40 |
| -docker-compose -f docker-compose-windows.yml build |
41 |
| -``` |
42 |
| - |
43 |
| -Then run the app using: |
44 |
| - |
45 |
| -``` |
46 |
| -docker-compose -f docker-compose-windows.yml up -d |
47 |
| -``` |
48 |
| - |
49 |
| -> Or in a Windows swarm, run `docker stack deploy -c docker-stack-windows.yml vote` |
50 |
| -
|
51 |
| -The app will be running at [http://localhost:5000](http://localhost:5000), and the results will be at [http://localhost:5001](http://localhost:5001). |
52 |
| - |
53 |
| - |
54 |
| -Run the app in Kubernetes |
55 |
| -------------------------- |
56 |
| - |
57 |
| -The folder k8s-specifications contains the yaml specifications of the Voting App's services. |
58 |
| - |
59 |
| -First create the vote namespace |
60 |
| - |
61 |
| -``` |
62 |
| -$ kubectl create namespace vote |
63 |
| -``` |
64 |
| - |
65 |
| -Run the following command to create the deployments and services objects: |
66 |
| -``` |
67 |
| -$ kubectl create -f k8s-specifications/ |
68 |
| -deployment "db" created |
69 |
| -service "db" created |
70 |
| -deployment "redis" created |
71 |
| -service "redis" created |
72 |
| -deployment "result" created |
73 |
| -service "result" created |
74 |
| -deployment "vote" created |
75 |
| -service "vote" created |
76 |
| -deployment "worker" created |
77 |
| -``` |
78 |
| - |
79 |
| -The vote interface is then available on port 31000 on each host of the cluster, the result one is available on port 31001. |
80 |
| - |
81 |
| -Architecture |
82 |
| ------ |
83 |
| - |
84 |
| - |
85 |
| - |
86 |
| -* A front-end web app in [Python](/vote) or [ASP.NET Core](/vote/dotnet) which lets you vote between two options |
87 |
| -* A [Redis](https://hub.docker.com/_/redis/) or [NATS](https://hub.docker.com/_/nats/) queue which collects new votes |
88 |
| -* A [.NET Core](/worker/src/Worker), [Java](/worker/src/main) or [.NET Core 2.1](/worker/dotnet) worker which consumes votes and stores them in… |
89 |
| -* A [Postgres](https://hub.docker.com/_/postgres/) or [TiDB](https://hub.docker.com/r/dockersamples/tidb/tags/) database backed by a Docker volume |
90 |
| -* A [Node.js](/result) or [ASP.NET Core SignalR](/result/dotnet) webapp which shows the results of the voting in real time |
91 |
| - |
92 |
| - |
93 |
| -Note |
94 |
| ----- |
95 |
| - |
96 |
| -The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client. |
0 commit comments