-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from GillisWerrebrouck/development
Development
- Loading branch information
Showing
82 changed files
with
2,461 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
# RailwayCompany | ||
# Railway System Architecture | ||
|
||
## Run all the services | ||
|
||
### Run Docker setup | ||
|
||
Execute the following command to build all microservices and start all docker containers. | ||
|
||
``` | ||
bash build.sh && docker-compose up --build | ||
``` | ||
|
||
To initialise a basic railway network with stations, use the following REST calls (either both should be executed or none); | ||
``` | ||
curl -X POST http://localhost:8080/station/init | ||
curl -X POST http://localhost:8080/network/init | ||
``` | ||
|
||
### Run Kubernetes setup | ||
|
||
``` | ||
kubectl create -f kubernetes-deployment.yaml | ||
``` | ||
|
||
All services will start and all pods will be created. Execute the following command to check if all pods are running stable; | ||
|
||
``` | ||
while true; do clear; kubectl get pods; sleep 3; done; | ||
``` | ||
|
||
To access the frontend you should have portforwarding enabled for the frontend service, as well as for the route-db service and the apigateway service. The reason why the route-db service needs to be port forwarded is due to the fact that there is a canvas displaying all station nodes and route nodes on the frontend which uses a package that needs access to the Neo4j database. | ||
|
||
If portforwarding is not an option, then try ssh tunneling (for all three services mentioned above) by using the following command as a template. | ||
|
||
``` | ||
ssh -L <port>:<hosted_ip>:<port> -i '<ssl cert>' <username>@<ip> -oPort=22 | ||
-oProxyCommand="ssh -i <ssl cert> -oPort=22 <username>@<domain|url> -W %h:%p" | ||
``` | ||
|
||
To initialise a basic railway network with stations, use the following REST calls (either both should be executed or none); | ||
|
||
``` | ||
curl -X POST http://localhost:8080/station/init | ||
curl -X POST http://localhost:8080/network/init | ||
``` | ||
|
||
There is also a bash script `chaos.sh` in the root of this project that automatically kills services that aren't labelled as immune. This script has a default delay of 30 seconds. This can be changed by setting the environment variable DELAY to a certain value. Execute the following command to see all pods that are or aren't labelled immune. | ||
|
||
``` | ||
kubectl --namespace default -l 'chaos=immune' get pods | ||
kubectl --namespace default -l 'chaos!=immune' get pods | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /bin/bash | ||
|
||
base="railway-app-" | ||
declare -a services=( | ||
"api-gateway" | ||
"delay" | ||
"maintenance" | ||
"route-management" | ||
"staff" | ||
"station" | ||
"ticket-sale" | ||
"ticket-validation" | ||
"timetable" | ||
"train" | ||
) | ||
|
||
for s in "${services[@]}" | ||
do | ||
cd $base$s | ||
chmod +x mvnw | ||
./mvnw package -DskipTests | ||
cd .. | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
# Randomly delete pods in a Kubernetes namespace. | ||
# Pods with label 'chaos=immune' will be spared. | ||
set -ex | ||
|
||
: ${DELAY:=30} | ||
: ${NAMESPACE:=default} | ||
|
||
while true; do | ||
kubectl \ | ||
--namespace "${NAMESPACE}" \ | ||
-o 'jsonpath={.items[*].metadata.name}' \ | ||
-l 'chaos!=immune' \ | ||
get pods | \ | ||
tr " " "\n" | \ | ||
shuf | \ | ||
head -n 1 | | ||
xargs -t --no-run-if-empty \ | ||
kubectl --namespace "${NAMESPACE}" delete pod | ||
sleep "${DELAY}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
version: "3" | ||
services: | ||
zookeeper-container: | ||
image: confluentinc/cp-zookeeper | ||
environment: | ||
- ZOOKEEPER_CLIENT_PORT=2181 | ||
kafka-container: | ||
image: confluentinc/cp-kafka | ||
depends_on: | ||
- zookeeper-container | ||
environment: | ||
- KAFKA_BROKER_ID=1 | ||
- KAFKA_ZOOKEEPER_CONNECT=zookeeper-container:2181 | ||
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka-container:9092 | ||
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 | ||
|
||
route-db: | ||
image: neo4j:3.5.6 | ||
environment: | ||
- NEO4J_AUTH=neo4j/route | ||
ports: | ||
- 7687:7687 | ||
# not good to expose a database port but this is just for the purpose of the frontend (graph visualisation) | ||
|
||
delay-request-db: | ||
image: redis | ||
|
||
staff-db: | ||
image: mongo | ||
train-db: | ||
image: mongo | ||
|
||
maintenance-db: | ||
image: mysql:5.7 | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=maintenancedatabase | ||
- MYSQL_DATABASE=Maintenance | ||
station-db: | ||
image: mysql:5.7 | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=stationdatabase | ||
- MYSQL_DATABASE=Station | ||
ticket-sale-db: | ||
image: mysql:5.7 | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=ticketsaledatabase | ||
- MYSQL_DATABASE=TicketSale | ||
ticket-validation-db: | ||
image: mysql:5.7 | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=ticketvalidationdatabase | ||
- MYSQL_DATABASE=TicketValidation | ||
timetable-db: | ||
image: mysql:5.7 | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=timetabledatabase | ||
- MYSQL_DATABASE=Timetable | ||
|
||
delay-service: | ||
build: ./railway-app-delay | ||
image: gilliswerrebrouck/railway-app-delay-service | ||
volumes: | ||
- ./railway-app-delay/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
maintenance-service: | ||
build: ./railway-app-maintenance | ||
image: gilliswerrebrouck/railway-app-maintenance-service | ||
volumes: | ||
- ./railway-app-maintenance/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- maintenance-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- maintenance-db | ||
route-service: | ||
build: ./railway-app-route-management | ||
image: gilliswerrebrouck/railway-app-route-management-service | ||
volumes: | ||
- ./railway-app-route-management/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- route-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- route-db | ||
staff-service: | ||
build: ./railway-app-staff | ||
image: gilliswerrebrouck/railway-app-staff-service | ||
volumes: | ||
- ./railway-app-staff/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- staff-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- staff-db | ||
station-service: | ||
build: ./railway-app-station | ||
image: gilliswerrebrouck/railway-app-station-service | ||
volumes: | ||
- ./railway-app-station/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- station-db | ||
- delay-request-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- station-db | ||
- delay-request-db | ||
ticket-sale-service: | ||
build: ./railway-app-ticket-sale | ||
image: gilliswerrebrouck/railway-app-ticket-sale-service | ||
volumes: | ||
- ./railway-app-ticket-sale/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- ticket-sale-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- ticket-sale-db | ||
ticket-validation-service: | ||
build: ./railway-app-ticket-validation | ||
image: gilliswerrebrouck/railway-app-ticket-validation-service | ||
volumes: | ||
- ./railway-app-ticket-validation/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- ticket-validation-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- ticket-validation-db | ||
timetable-service: | ||
build: ./railway-app-timetable | ||
image: gilliswerrebrouck/railway-app-timetable-service | ||
volumes: | ||
- ./railway-app-timetable/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- timetable-db | ||
- route-service | ||
- station-service | ||
- train-service | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- timetable-db | ||
- route-service | ||
- station-service | ||
- train-service | ||
train-service: | ||
build: ./railway-app-train | ||
image: gilliswerrebrouck/railway-app-train-service | ||
volumes: | ||
- ./railway-app-train/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- train-db | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- train-db | ||
apigateway: | ||
build: ./railway-app-api-gateway | ||
image: gilliswerrebrouck/railway-app-api-gateway-service | ||
volumes: | ||
- ./railway-app-api-gateway/target:/app | ||
links: | ||
- kafka-container | ||
- zookeeper-container | ||
- delay-service | ||
- maintenance-service | ||
- route-service | ||
- staff-service | ||
- station-service | ||
- ticket-sale-service | ||
- ticket-validation-service | ||
- timetable-service | ||
- train-service | ||
depends_on: | ||
- kafka-container | ||
- zookeeper-container | ||
- delay-service | ||
- maintenance-service | ||
- route-service | ||
- staff-service | ||
- station-service | ||
- ticket-sale-service | ||
- ticket-validation-service | ||
- timetable-service | ||
- train-service | ||
ports: | ||
- 8080:8080 | ||
|
||
frontend: | ||
build: ./railway-app-frontend | ||
image: gilliswerrebrouck/railway-app-frontend | ||
volumes: | ||
- ./railway-app-frontend/target:/app | ||
links: | ||
- apigateway | ||
- route-db | ||
depends_on: | ||
- apigateway | ||
- route-db | ||
ports: | ||
- 80:80 |
Oops, something went wrong.