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>
Mon, 16 Oct 2023 20:39:44 +0000 (22:39 +0200)
.gitignore [new file with mode: 0644]
docker/.dockerignore [new file with mode: 0644]
docker/Dockerfile [new file with mode: 0644]
docker/README.sh [new file with mode: 0755]
docker/docker-compose.yml

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/docker/.dockerignore b/docker/.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/docker/Dockerfile b/docker/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" ]
diff --git a/docker/README.sh b/docker/README.sh
new file mode 100755 (executable)
index 0000000..7268bc9
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ "$1" = "cleanup" ]
+then
+  (cd cruise-control; ./gradlew clean)
+  rm -f cruise-control-metrics-reporter.jar
+  exit
+fi
+
+git submodule update --init cruise-control || exit 1
+(cd cruise-control; ./gradlew jar) || exit 1
+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 .
index 875e209..d769965 100644 (file)
@@ -28,8 +28,10 @@ services:
         -Dcom.sun.management.jmxremote=true
         -Dcom.sun.management.jmxremote.port=9101
         -Dcom.sun.management.jmxremote.authenticate=false
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
       - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro
+      - ./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
@@ -55,8 +57,10 @@ services:
         -Dcom.sun.management.jmxremote=true
         -Dcom.sun.management.jmxremote.port=9101
         -Dcom.sun.management.jmxremote.authenticate=false
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
       - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro
+      - ./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
@@ -87,8 +91,10 @@ services:
         -Dcom.sun.management.jmxremote=true
         -Dcom.sun.management.jmxremote.port=9101
         -Dcom.sun.management.jmxremote.authenticate=false
+      KAFKA_METRIC_REPORTERS: com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter
     volumes:
       - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro
+      - ./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
@@ -96,6 +102,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:
@@ -159,19 +173,31 @@ 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 \
                        --if-exists \
                        --topic test
+          kafka-topics --bootstrap-server kafka:9092 \
+                       --delete \
+                       --if-exists \
+                       --topic __CruiseControlMetrics
           kafka-topics --bootstrap-server kafka:9092 \
                        --create \
                        --topic test \
                        --partitions 2 \
                        --replication-factor 3 \
                        --config min.insync.replicas=2 \
+          kafka-topics --bootstrap-server kafka:9092 \
+                       --create \
+                       --topic __CruiseControlMetrics \
+                       --partitions 2 \
+                       --replication-factor 3 \
+                       --config min.insync.replicas=2 \
           && echo Das Topic \'test\' wurde erfolgreich angelegt: \
           && kafka-topics --bootstrap-server kafka:9092 --describe --topic test \
+          && kafka-topics --bootstrap-server kafka:9092 --describe --topic __CruiseControlMetrics \
           && date > INITIALIZED
         fi
     stop_grace_period: 0s