Enabled up/down-scaling of the services
authorKai Moritz <kai@juplo.de>
Sat, 16 Oct 2021 15:01:51 +0000 (17:01 +0200)
committerKai Moritz <kai@juplo.de>
Thu, 21 Oct 2021 20:30:57 +0000 (22:30 +0200)
* Changed the default-port of the services, so that all services can be
  started local in parallel
* The queriable Kafka-Streams-Apps derive their local address automatically,
  so that they can be scaled up/down in Docker-Compose
* Added traefik as reverse-proxy to the setup

README.sh
counter
docker-compose.yml
query
recorder
top10
users

index 993701a..4b5f557 100755 (executable)
--- a/README.sh
+++ b/README.sh
@@ -1,11 +1,11 @@
 #!/bin/bash
 
 FORTUNE=juplo/wordcount--fortune:1.0.0
-RECORDER=juplo/wordcount--recorder:1.0.0
-USERS=juplo/wordcount--users:1.0.2
-COUNTER=juplo/wordcount--counter:1.0.0
-TOP10=juplo/wordcount--top10:1.0.0
-QUERY=juplo/wordcount--query:1.0.2
+RECORDER=juplo/wordcount--recorder:1.0.1
+USERS=juplo/wordcount--users:1.0.4
+COUNTER=juplo/wordcount--counter:1.0.1
+TOP10=juplo/wordcount--top10:1.0.1
+QUERY=juplo/wordcount--query:1.0.4
 
 if [ "$1" = "cleanup" ]
 then
@@ -48,34 +48,61 @@ else
 fi
 
 
-docker-compose up -d zookeeper kafka cli
+docker-compose up -d zookeeper kafka cli traefik
 
 echo "Waiting for the Kafka-Cluster to become ready..."
 docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
 docker-compose exec cli zookeeper-shell zookeeper:2181 ls /brokers/ids
 
 docker-compose up -d users
-while [ "$(http :8082/actuator/health | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service users..."; sleep 1; done
-http -v post :8082 username=bart firstName=Bart lastName=Simpson sex=MALE
-http -v post :8082 username=nerd firstName=Jane lastName=Doe sex=FEMALE
-http -v post :8082 username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE
+while [ "$(http users.localhost/actuator/health 2> /dev/null | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service users..."; sleep 1; done
+http -v post users.localhost username=bart firstName=Bart lastName=Simpson sex=MALE
+http -v post users.localhost username=nerd firstName=Jane lastName=Doe sex=FEMALE
+http -v post users.localhost username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE
 
 echo "Starting all instances..."
 docker-compose up -d
 
-while [ "$(http :8085/actuator/health 2>/dev/null | jq -r .status)" != "UP" ]; do echo "Waiting for service query..."; sleep 1; done
-http -v :8085/bart
+while [ "$(http query.localhost/actuator/health 2>/dev/null | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service query..."; sleep 1; done
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
+http -v query.localhost/bart
 sleep 1
-http -v :8085/bart
-http -v :8085/nerd
-http -v :8085/riddler
+http -v query.localhost/bart
+http -v query.localhost/nerd
+http -v query.localhost/riddler
+
+docker-compose up -d --scale query=5 query
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+sleep 1
+http -v --follow query.localhost/bart
+
+http -v --follow query.localhost/nerd
+http -v --follow query.localhost/nerd
+http -v --follow query.localhost/nerd
+http -v --follow query.localhost/nerd
+http -v --follow query.localhost/nerd
+
+http -v --follow query.localhost/riddler
+http -v --follow query.localhost/riddler
+http -v --follow query.localhost/riddler
+http -v --follow query.localhost/riddler
+http -v --follow query.localhost/riddler
diff --git a/counter b/counter
index 02ab54c..b1623c2 160000 (submodule)
--- a/counter
+++ b/counter
@@ -1 +1 @@
-Subproject commit 02ab54c6b3c099f5b0bd420fc0a37034badf1c71
+Subproject commit b1623c2b645c614424ceec3bc71008c900d82115
index 2594ac8..092eb76 100644 (file)
@@ -24,59 +24,73 @@ services:
     depends_on:
       - zookeeper
 
+
+  traefik:
+    image: "traefik:v2.5"
+    command:
+      #- "--log.level=DEBUG"
+      - "--api.insecure=true"
+      - "--providers.docker=true"
+      - "--providers.docker.exposedbydefault=false"
+      - "--entrypoints.web.address=:80"
+    ports:
+      - "80:80"
+      - "8080:8080"
+    volumes:
+      - "/var/run/docker.sock:/var/run/docker.sock:ro"
+
   recorder:
-    image: juplo/wordcount--recorder:1.0.0
+    image: juplo/wordcount--recorder:1.0.1
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.recorder.rule=Host(`recorder.localhost`)"
+      - "traefik.http.routers.recorder.entrypoints=web"
     environment:
       juplo.wordcount.recorder.bootstrap-server: kafka:9092
-      juplo.wordcount.recorder.topic: recordings
-    ports:
-      - 8081:8080
     depends_on:
       - kafka
 
   users:
-    image: juplo/wordcount--users:1.0.2
+    image: juplo/wordcount--users:1.0.4
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.users.rule=Host(`users.localhost`)"
+      - "traefik.http.routers.users.entrypoints=web"
     environment:
       juplo.wordcount.users.bootstrap-server: kafka:9092
-      juplo.wordcount.users.topic: users
-    ports:
-      - 8082:8080
     depends_on:
       - kafka
 
   counter:
-    image: juplo/wordcount--counter:1.0.0
+    image: juplo/wordcount--counter:1.0.1
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.counter.rule=Host(`counter.localhost`)"
+      - "traefik.http.routers.counter.entrypoints=web"
     environment:
       juplo.wordcount.counter.bootstrap-server: kafka:9092
-      juplo.wordcount.counter.application-id: counter
-      juplo.wordcount.counter.input-topic: recordings
-      juplo.wordcount.counter.output-topic: countings
-    ports:
-      - 8083:8080
     depends_on:
       - kafka
 
   top10:
-    image: juplo/wordcount--top10:1.0.0
+    image: juplo/wordcount--top10:1.0.1
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.top10.rule=Host(`top10.localhost`)"
+      - "traefik.http.routers.top10.entrypoints=web"
     environment:
       juplo.wordcount.top10.bootstrap-server: kafka:9092
-      juplo.wordcount.top10.application-id: top10
-      juplo.wordcount.top10.input-topic: countings
-      juplo.wordcount.top10.output-topic: top10
-    ports:
-      - 8084:8080
     depends_on:
       - kafka
 
   query:
-    image: juplo/wordcount--query:1.0.2
+    image: juplo/wordcount--query:1.0.4
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.query.rule=Host(`query.localhost`)"
+      - "traefik.http.routers.query.entrypoints=web"
     environment:
       juplo.wordcount.query.bootstrap-server: kafka:9092
-      juplo.wordcount.query.application-id: query
-      juplo.wordcount.query.ranking-input-topic: top10
-      juplo.wordcount.query.users-input-topic: users
-    ports:
-      - 8085:8080
     depends_on:
       - kafka
 
@@ -87,7 +101,7 @@ services:
       do
         /usr/games/fortune chalkboard
           | head -1
-          | http -v recorder:8080/bart;
+          | http -v recorder:8081/bart;
         echo;
         sleep 1;
       done"
@@ -99,7 +113,7 @@ services:
       do
         /usr/games/fortune computers
           | grep  -v '^[[:space:]]*--'
-          | http -v recorder:8080/nerd;
+          | http -v recorder:8081/nerd;
         echo;
         sleep 1;
       done"
@@ -111,7 +125,7 @@ services:
       do
         /usr/games/fortune riddles
           | awk -F':' '/^Q/ { print $$2 }'
-          | http -v recorder:8080/riddler;
+          | http -v recorder:8081/riddler;
         echo;
         sleep 1;
       done"
diff --git a/query b/query
index 0d1ed8c..251cf79 160000 (submodule)
--- a/query
+++ b/query
@@ -1 +1 @@
-Subproject commit 0d1ed8c65f422e5c0cd291c35dba67b1f2205997
+Subproject commit 251cf79927d4c1c941467c8fee0349c1a7eb4b93
index 338279a..c5700c2 160000 (submodule)
--- a/recorder
+++ b/recorder
@@ -1 +1 @@
-Subproject commit 338279a329a06be7a141a3930d80b2a2805719dc
+Subproject commit c5700c2117f6c445278f272572c8b5732bf53bbf
diff --git a/top10 b/top10
index 4b94d31..b3c3b1c 160000 (submodule)
--- a/top10
+++ b/top10
@@ -1 +1 @@
-Subproject commit 4b94d31fbd663cb277276def106be9873ec4a246
+Subproject commit b3c3b1c1ab19d197d323d7c69e03d9bd09147690
diff --git a/users b/users
index aaf3b32..097a537 160000 (submodule)
--- a/users
+++ b/users
@@ -1 +1 @@
-Subproject commit aaf3b3248937ffd1677a1eeb6a575c539b6ec84a
+Subproject commit 097a537e42272d105354a708e5138abf5488b28a