Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 3fdc3f7

Browse files
committed
added visualizer, fixed some errs
1 parent 1d96e97 commit 3fdc3f7

File tree

18 files changed

+405
-13
lines changed

18 files changed

+405
-13
lines changed

database/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FROM bstaijen/mariadb-galera-cluster:0.3
2-
ADD setup.sql /docker-entrypoint-initdb.d/
2+
ADD setup.sql /docker-entrypoint-initdb.d/
3+
ADD mariadb.png /docker-entrypoint-initdb.d/mariadb.png

database/mariadb.png

29.6 KB
Loading

database/setup.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS CommentService.comments (id INT NOT NULL AUTO_INCREME
1414
CREATE USER 'authentication_service'@'%' IDENTIFIED BY 'password';
1515
GRANT ALL ON ProfileService.* TO 'authentication_service'@'%';
1616

17-
CREATE USER 'profile_service'@'%' IDENTIFIED BY 'password';
17+
CREATE USER 'profile_service'@'%' IDENTIFIED BY 'password';
1818
GRANT ALL ON ProfileService.* TO 'profile_service'@'%';
1919

2020
CREATE USER 'comment_service'@'%' IDENTIFIED BY 'password';
@@ -24,4 +24,8 @@ CREATE USER 'photo_service'@'%' IDENTIFIED BY 'password';
2424
GRANT ALL ON PhotoService.* TO 'photo_service'@'%';
2525

2626
CREATE USER 'vote_service'@'%' IDENTIFIED BY 'password';
27-
GRANT ALL ON VoteService.* TO 'vote_service'@'%';
27+
GRANT ALL ON VoteService.* TO 'vote_service'@'%';
28+
29+
INSERT INTO ProfileService.users(`username`, `email`, `password`) VALUES ('bstaijen','bjorge.staijen@mariadb.com','$2a$10$1CSYrh6MYJdBoAnJMcQ22.sZ2QBfWL7VlfpQayOt8otdOa1Myjt7O');
30+
31+
INSERT INTO PhotoService.photos(`title`, `user_id`, `filename`, `contentType`, `photo`) VALUES ('The MariaDB seal',1,'94049535630251382.png','image/png', LOAD_FILE('/docker-entrypoint-initdb.d/mariadb.png'));

docker-compose.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '2'
22

33
services:
44
webserver:
5-
image: "webserver"
5+
image: bstaijen/mariadb-microservice-webserver:demo
66
depends_on:
77
- authentication
88
- photo
@@ -23,7 +23,7 @@ services:
2323
labels:
2424
- "com.mariadb.host=webserver"
2525
authentication:
26-
image: "authenticationsvc"
26+
image: bstaijen/mariadb-microservice-authenticationsvc:demo
2727
depends_on:
2828
- registrator
2929
ports:
@@ -41,7 +41,7 @@ services:
4141
labels:
4242
- "com.mariadb.host=authenticationsvc"
4343
photo:
44-
image: "photosvc"
44+
image: bstaijen/mariadb-microservice-photosvc:demo
4545
depends_on:
4646
- registrator
4747
ports:
@@ -62,7 +62,7 @@ services:
6262
labels:
6363
- "com.mariadb.host=photosvc"
6464
vote:
65-
image: "votesvc"
65+
image: bstaijen/mariadb-microservice-votesvc:demo
6666
depends_on:
6767
- registrator
6868
ports:
@@ -81,7 +81,7 @@ services:
8181
labels:
8282
- "com.mariadb.host=votesvc"
8383
comment:
84-
image: "commentsvc"
84+
image: bstaijen/mariadb-microservice-commentsvc:demo3
8585
depends_on:
8686
- registrator
8787
ports:
@@ -90,16 +90,19 @@ services:
9090
environment:
9191
- "PORT=5004"
9292
- "PROFILE_SERVICE_URL=http://profile:5000/"
93+
- "PHOTO_SERVICE_URL=http://photo:5002/"
94+
- "VOTE_SERVICE_URL=http://vote:5003/"
9395
- "DB_USERNAME=comment_service"
9496
- "DB_PASSWORD=password"
9597
- "DB_HOST=db"
9698
- "DB_PORT=3306"
9799
- "DB=CommentService"
100+
- "SECRET_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZ"
98101
- "affinity:com.mariadb.host!=commentsvc"
99102
labels:
100103
- "com.mariadb.host=commentsvc"
101104
profile:
102-
image: "profilesvc"
105+
image: bstaijen/mariadb-microservice-profilesvc:demo
103106
depends_on:
104107
- registrator
105108
ports:
@@ -117,7 +120,7 @@ services:
117120
labels:
118121
- "com.mariadb.host=profilesvc"
119122
db:
120-
image: bstaijen/mariadb-microservice-database:0.3
123+
image: bstaijen/mariadb-microservice-database:demo
121124
depends_on:
122125
- registrator
123126
restart: always
@@ -155,4 +158,15 @@ services:
155158
- "8500:8500"
156159
- "8600:53/udp"
157160
command: "-server -bootstrap -ui-dir /ui"
161+
restart: always
162+
vizualizer:
163+
image: bstaijen/mariadb-microservice-vizualizersvc:demo
164+
ports:
165+
- 3000:3000
166+
environment:
167+
- SWARM_HOST
168+
- SWARM_CA
169+
- SWARM_KEY
170+
- SWARM_CERT
171+
- "constraint:node==master"
158172
restart: always

vizualizer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM node:onbuild
2+
EXPOSE 3000

vizualizer/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Docker Swarm Visualization
2+
3+
## Running - new stack version
4+
5+
```
6+
docker stack deploy viz -c docker-compose.stack.yml
7+
```
8+
9+
## Running - old compose version
10+
11+
This assumes you have created your Swarm with Machine and the master is called `swarm-0`.
12+
13+
```
14+
source scripts/setup.sh
15+
scripts/up.sh swarm-0
16+
```
17+
18+
Browse to http://localhost:3000 to see the console. Add url parameter multiply=true to multiply the number of ocntainers and hosts for testing. http://localhost:3000/?multiply=true. When you use multuply, use cmd-- to reduce size of display, uses 2000 pix for svg viewport width. I tested it with 100 hosts and 12000 containers.
19+
20+
<img src="../static/viz-demo.png"></img>

vizualizer/docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
viz:
2+
build: .
3+
ports:
4+
- 3000:3000
5+
environment:
6+
- SWARM_HOST
7+
- SWARM_CA
8+
- SWARM_KEY
9+
- SWARM_CERT
10+
- "constraint:node==master"
11+
restart: always

vizualizer/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "viz",
3+
"version": "0.0.1",
4+
"description": "visualize docker containers on a swarm master",
5+
"scripts": {
6+
"start": "node viz"
7+
},
8+
"dependencies": {
9+
"async": "^1.2.1",
10+
"dockerode": "latest",
11+
"express": "latest",
12+
"socket.io": "^1.3.5"
13+
}
14+
}
2.77 KB
Loading
4.01 KB
Loading

0 commit comments

Comments
 (0)