diff --git a/README.md b/README.md index 9d7befc..cd0c252 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,20 @@ To start the MySQL-backed configuration, run: $ docker-compose -f docker-compose.yml -f docker-compose-mysql.yml up +### Kafka + +The docker-compose configuration can be extended to host a test Kafka broker +using the `docker-compose-kafka.yml` file. That file employs +[docker-compose overrides](https://docs.docker.com/compose/extends/#multiple-compose-files) +to add a Kafka+ZooKeeper container and relevant settings. + +To start the Cassandra+Kafka configuration, run: + + $ docker-compose -f docker-compose.yml -f docker-compose-kafka.yml up + +By default, this assumes your Docker host IP is 192.168.99.100, which is what +you would use for the broker IP when configuring application instrumentation. + ### Legacy The Cassandra and MySQL docker-compose files described above use version 2 of diff --git a/docker-compose-kafka.yml b/docker-compose-kafka.yml new file mode 100644 index 0000000..98d0d54 --- /dev/null +++ b/docker-compose-kafka.yml @@ -0,0 +1,25 @@ +# This file uses the version 2 docker-compose file format, described here: +# https://docs.docker.com/compose/compose-file/#version-2 +# +# It extends the default configuration from docker-compose.yml to run the +# zipkin-mysql container instead of the zipkin-cassandra container. + +version: '2' + +services: + kafka-zookeeper: + build: kafka + image: openzipkin/zipkin-kafka:1.4.3 + container_name: kafka-zookeeper + environment: + # corresponds to your docker machine and your producer's broker list + - KAFKA_ADVERTISED_HOST_NAME=192.168.99.100 + ports: + - 2181:2181 + - 9092:9092 + + zipkin: + environment: + - KAFKA_ZOOKEEPER=kafka-zookeeper + depends_on: + - kafka-zookeeper diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 607b26e..953d326 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -3,7 +3,7 @@ FROM openzipkin/jre-full:1.8.0_72 MAINTAINER OpenZipkin "http://zipkin.io/" ENV SCALA_VERSION 2.11 -ENV KAFKA_VERSION 0.9.0.0 +ENV KAFKA_VERSION 0.9.0.1 ENV ZOOKEEPER_VERSION 3.4.6 WORKDIR /kafka diff --git a/kafka/install.sh b/kafka/install.sh index d02c466..78173fc 100755 --- a/kafka/install.sh +++ b/kafka/install.sh @@ -36,10 +36,14 @@ EOF # create runit config, dependent on zookeeper, that advertises the container ip mkdir -p /etc/service/kafka -cat > /etc/service/kafka/run <<-EOF +cat > /etc/service/kafka/run <<-"EOF" #!/bin/sh sv start zookeeper || exit 1 -echo advertised.host.name=$(route -n | awk '/UG[ \t]/{print $2}') >> /kafka/config/server.properties +if [[ -z "$KAFKA_ADVERTISED_HOST_NAME" ]]; then + echo advertised.host.name=$(route -n | awk '/UG[ \t]/{print $2}') >> /kafka/config/server.properties +else + echo advertised.host.name=$KAFKA_ADVERTISED_HOST_NAME >> /kafka/config/server.properties +fi exec sh /kafka/bin/kafka-run-class.sh -name kafkaServer -loggc kafka.Kafka /kafka/config/server.properties EOF chmod +x /etc/service/kafka/run