Docker-Image für Cruise Control gebaut & eingebunden
authorKai Moritz <kai@juplo.de>
Sun, 8 Oct 2023 17:59:29 +0000 (19:59 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 10 Nov 2023 12:39:26 +0000 (13:39 +0100)
.dockerignore [new file with mode: 0644]
.gitignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
README.sh
docker/docker-compose.yml

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..92dc507
--- /dev/null
@@ -0,0 +1,4 @@
+*
+!cruise-control/*.sh
+!cruise-control/*/build/*libs
+!cruise-control/config
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..799b81f
--- /dev/null
@@ -0,0 +1 @@
+docker/cruise-control-metrics-reporter.jar
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..6ec7b58
--- /dev/null
@@ -0,0 +1,10 @@
+ARG VERSION=7.5.1
+FROM confluentinc/cp-kafka-connect:${VERSION}
+USER root
+COPY cruise-control /opt/cruise-control/
+WORKDIR /opt/cruise-control
+ENV BOOTSTRAP_SERVERS=localhost:9092
+ENV ZOOKEEPER_CONNECT=localhost:2181
+RUN echo -e '#!/bin/bash\n sed -ie "s+^bootstrap\.servers=.*$+bootstrap.servers=${BOOTSTRAP_SERVERS}+;s+^zookeeper\.connect=.*$+zookeeper.connect=${ZOOKEEPER_CONNECT}+" config/cruisecontrol.properties\nexec ./kafka-cruise-control-start.sh "$@"' > run.sh; chmod a+x run.sh
+ENTRYPOINT [ "/opt/cruise-control/run.sh" ]
+CMD [ "config/cruisecontrol.properties" ]
index 7d6406d..fa8a4c7 100755 (executable)
--- a/README.sh
+++ b/README.sh
@@ -3,9 +3,15 @@
 if [ "$1" = "cleanup" ]
 then
   docker-compose -f docker/docker-compose.yml down -t0 -v --remove-orphans
+  (cd cruise-control; ./gradlew clean)
   exit
 fi
 
+git submodule update --init cruise-control || exit 1
+(cd cruise-control; ./gradlew jar) || exit 1
+(cd docker; ln -sf ../cruise-control/cruise-control-metrics-reporter/build/libs/cruise-control-metrics-reporter-*.jar cruise-control-metrics-reporter.jar)
+docker build -t juplo/cruise-control .
+
 docker-compose -f docker/docker-compose.yml up --remove-orphans setup || exit 1
 docker-compose -f docker/docker-compose.yml ps
 
index bc463c5..900001b 100644 (file)
@@ -21,7 +21,9 @@ services:
       KAFKA_INTER_BROKER_LISTENER_NAME: BROKER
       KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
       KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
+      - ./cruise-control-metrics-reporter.jar:/usr/share/java/kafka/cruise-control-metrics-reporter.jar:ro
       - kafka-1-data:/var/lib/kafka/data
     ports:
       - 9081:9081
@@ -40,7 +42,9 @@ services:
       KAFKA_INTER_BROKER_LISTENER_NAME: BROKER
       KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
       KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
+      - ./cruise-control-metrics-reporter.jar:/usr/share/java/kafka/cruise-control-metrics-reporter.jar:ro
       - kafka-2-data:/var/lib/kafka/data
     ports:
       - 9092:9082
@@ -64,7 +68,9 @@ services:
       KAFKA_INTER_BROKER_LISTENER_NAME: BROKER
       KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
       KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
+      - ./cruise-control-metrics-reporter.jar:/usr/share/java/kafka/cruise-control-metrics-reporter.jar:ro
       - kafka-3-data:/var/lib/kafka/data
     ports:
       - 9083:9083
@@ -72,6 +78,14 @@ services:
     depends_on:
       - zookeeper
 
+  cruise-control:
+    image: juplo/cruise-control
+    environment:
+      BOOTSTRAP_SERVERS: kafka-1:9092,kafka-2:9092,kafka-3:9092
+      ZOOKEEPER_CONNECT: zookeeper:2181/
+    ports:
+      - "9090:9090"
+
   schema-registry:
     image: confluentinc/cp-schema-registry:7.5.1
     environment:
@@ -135,6 +149,7 @@ services:
           echo -n Bereits konfiguriert: 
           cat INITIALIZED
           kafka-topics --bootstrap-server kafka:9092 --describe --topic test
+          kafka-topics --bootstrap-server kafka:9092 --describe --topic __CruiseControlMetrics
         else
           kafka-topics --bootstrap-server kafka:9092 \
                        --delete \
@@ -147,9 +162,21 @@ services:
                        --replication-factor 3 \
                        --config min.insync.replicas=2 \
           && echo Das Topic \'test\' wurde erfolgreich angelegt: \
-          && kafka-topics --bootstrap-server kafka:9092 --describe --topic test \
-          && date > INITIALIZED
-        fi
+          && kafka-topics --bootstrap-server kafka:9092 --describe --topic test
+          kafka-topics --bootstrap-server kafka:9092 \
+                       --delete \
+                       --if-exists \
+                       --topic __CruiseControlMetrics
+          kafka-topics --bootstrap-server kafka:9092 \
+                       --create \
+                       --topic __CruiseControlMetrics \
+                       --partitions 2 \
+                       --replication-factor 3 \
+                       --config min.insync.replicas=2 \
+          && echo Das Topic \'__CruiseControlMetrics\' wurde erfolgreich angelegt: \
+          && kafka-topics --bootstrap-server kafka:9092 --describe --topic __CruiseControlMetrics
+        fi \
+        && date > INITIALIZED
     stop_grace_period: 0s
     depends_on:
       - cli