From: Kai Moritz Date: Fri, 10 Nov 2023 11:01:20 +0000 (+0100) Subject: Eigenes Kafka-Image von `cp-kafka` mit cruis-control-JAR abgeleitet X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=655137a99eedd0bbf3576d1ec0c1eafbf909967e;p=demos%2Fkafka%2Ftraining Eigenes Kafka-Image von `cp-kafka` mit cruis-control-JAR abgeleitet --- diff --git a/README.sh b/README.sh index 6ebd03f..c4290b6 100755 --- a/README.sh +++ b/README.sh @@ -1,6 +1,7 @@ #!/bin/bash -IMAGE=juplo/cruise-control +IMAGE_CRUISECONTROL=juplo/cruise-control +IMAGE_KAFKA=juplo/kafka if [ "$1" = "cleanup" ] then @@ -9,17 +10,26 @@ then exit fi -docker-compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3 - if [[ - $(docker image ls -q $IMAGE) == "" || + $(docker image ls -q $IMAGE_CRUISECONTROL) == "" || "$1" = "build" ]] then DOCKER_BUILDKIT=0 docker build -t juplo/cruise-control cruise-control || exit 1 else echo "Using image existing images:" - docker image ls $IMAGE + docker image ls $IMAGE_CRUISECONTROL +fi + +if [[ + $(docker image ls -q $IMAGE_KAFKA) == "" || + "$1" = "build" +]] +then + DOCKER_BUILDKIT=0 docker build -t juplo/kafka kafka || exit 1 +else + echo "Using image existing images:" + docker image ls $IMAGE_KAFKA fi docker-compose -f docker/docker-compose.yml up --remove-orphans setup || exit 1 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f126ce3..b375cbb 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -11,7 +11,7 @@ services: - zookeeper-log:/var/lib/zookeeper/log kafka-1: - image: confluentinc/cp-kafka:7.5.1 + image: juplo/kafka environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9081 @@ -21,6 +21,8 @@ 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 + KAFKA_CRUISE_CONTROL_METRICS_REPORTER_BOOTSTRAP_SERVERS: localhost:9092 volumes: - kafka-1-data:/var/lib/kafka/data ports: @@ -30,7 +32,7 @@ services: - zookeeper kafka-2: - image: confluentinc/cp-kafka:7.5.1 + image: juplo/kafka environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9082 @@ -40,6 +42,8 @@ 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 + KAFKA_CRUISE_CONTROL_METRICS_REPORTER_BOOTSTRAP_SERVERS: localhost:9092 volumes: - kafka-2-data:/var/lib/kafka/data ports: @@ -54,7 +58,7 @@ services: - zookeeper kafka-3: - image: confluentinc/cp-kafka:7.5.1 + image: juplo/kafka environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9083 @@ -64,6 +68,8 @@ 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 + KAFKA_CRUISE_CONTROL_METRICS_REPORTER_BOOTSTRAP_SERVERS: localhost:9092 volumes: - kafka-3-data:/var/lib/kafka/data ports: @@ -73,7 +79,7 @@ services: - zookeeper kafka-4: - image: confluentinc/cp-kafka:7.5.1 + image: juplo/kafka environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9084 @@ -83,6 +89,8 @@ 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 + KAFKA_CRUISE_CONTROL_METRICS_REPORTER_BOOTSTRAP_SERVERS: localhost:9092 volumes: - kafka-4-data:/var/lib/kafka/data ports: diff --git a/kafka/Dockerfile b/kafka/Dockerfile index bd2fe30..2d178c7 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -9,15 +9,7 @@ RUN git clone -b migrate_to_kafka_2_5 https://github.com/linkedin/cruise-control WORKDIR cruise-control RUN ./gradlew jar -FROM confluentinc/cp-kafka-connect:${VERSION} -USER root -COPY --from=0 /tmp/cruise-control/config /opt/cruise-control/config/ -COPY --from=0 /tmp/cruise-control/cruise-control/build /opt/cruise-control/cruise-control/build/ -COPY --from=0 /tmp/cruise-control/kafka-cruise-control-start.sh /opt/cruise-control/ -WORKDIR /opt/cruise-control -RUN wget -O - https://github.com/linkedin/cruise-control-ui/releases/download/v0.4.0/cruise-control-ui-0.4.0.tar.gz | tar -xzv -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" ] +FROM confluentinc/cp-kafka:${VERSION} +COPY --from=0 \ + /tmp/cruise-control/cruise-control-metrics-reporter/build/libs/cruise-control-metrics-reporter-*.jar \ + /usr/share/java/kafka/cruise-control-metrics-reporter.jar