From 98f39b3048787884693b683567a29e2ee07ff948 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:26:13 -0400 Subject: [PATCH 1/8] touch, don't rm, KAFKA_PROPERTIES_FILE This change gives users the option to put their _own_ `KAFKA_PROPERTIES_FILE` into an image _without_ specifying `KAFKA_PROPERTIES`. This is particularly useful in cases where a user does not want to store `KAFKA_PROPERTIES` in version control such as Git. (Even though it is base64-encoded, it is not encrypted.) --- src/main/docker/kafdrop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index 47536cd5..4c24eae3 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -40,7 +40,7 @@ if [ "$KAFKA_PROPERTIES" != "" ]; then echo Writing Kafka properties into $KAFKA_PROPERTIES_FILE echo "$KAFKA_PROPERTIES" | base64 --decode --ignore-garbage > $KAFKA_PROPERTIES_FILE else - rm $KAFKA_PROPERTIES_FILE |& > /dev/null | true + touch $KAFKA_PROPERTIES_FILE fi KAFKA_TRUSTSTORE_FILE=${KAFKA_TRUSTSTORE_FILE:-kafka.truststore.jks} From 69ac5bffa5e0e5538207c1b363d8c8acac684cd9 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:43:53 -0400 Subject: [PATCH 2/8] Update kafdrop.sh --- src/main/docker/kafdrop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index 4c24eae3..8d3a91a3 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -40,7 +40,7 @@ if [ "$KAFKA_PROPERTIES" != "" ]; then echo Writing Kafka properties into $KAFKA_PROPERTIES_FILE echo "$KAFKA_PROPERTIES" | base64 --decode --ignore-garbage > $KAFKA_PROPERTIES_FILE else - touch $KAFKA_PROPERTIES_FILE + if [ -f $KAFKA_PROPERTIES_FILE ]; then touch $KAFKA_PROPERTIES_FILE; else rm -f $KAFKA_PROPERTIES_FILE; fi fi KAFKA_TRUSTSTORE_FILE=${KAFKA_TRUSTSTORE_FILE:-kafka.truststore.jks} From 9f62b6bcdbc4655b4c951e36df024d5d9ff41027 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 09:01:49 -0400 Subject: [PATCH 3/8] Update kafdrop.sh --- src/main/docker/kafdrop.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index 8d3a91a3..4e1a9e72 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -39,8 +39,6 @@ KAFKA_PROPERTIES_FILE=${KAFKA_PROPERTIES_FILE:-kafka.properties} if [ "$KAFKA_PROPERTIES" != "" ]; then echo Writing Kafka properties into $KAFKA_PROPERTIES_FILE echo "$KAFKA_PROPERTIES" | base64 --decode --ignore-garbage > $KAFKA_PROPERTIES_FILE -else - if [ -f $KAFKA_PROPERTIES_FILE ]; then touch $KAFKA_PROPERTIES_FILE; else rm -f $KAFKA_PROPERTIES_FILE; fi fi KAFKA_TRUSTSTORE_FILE=${KAFKA_TRUSTSTORE_FILE:-kafka.truststore.jks} From e1c819ac7ae2af985b7402329f0536057003b436 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 09:05:54 -0400 Subject: [PATCH 4/8] Update kafdrop.sh --- src/main/docker/kafdrop.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index 4e1a9e72..c7aaeb74 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -39,6 +39,8 @@ KAFKA_PROPERTIES_FILE=${KAFKA_PROPERTIES_FILE:-kafka.properties} if [ "$KAFKA_PROPERTIES" != "" ]; then echo Writing Kafka properties into $KAFKA_PROPERTIES_FILE echo "$KAFKA_PROPERTIES" | base64 --decode --ignore-garbage > $KAFKA_PROPERTIES_FILE +else + if [ ! -f $KAFKA_PROPERTIES_FILE ]; then touch $KAFKA_PROPERTIES_FILE; fi fi KAFKA_TRUSTSTORE_FILE=${KAFKA_TRUSTSTORE_FILE:-kafka.truststore.jks} From 4e6ffe035b856839ad403e2a91686124b71cbfd8 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 09:08:57 -0400 Subject: [PATCH 5/8] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index fc37e416..fd702958 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,19 @@ docker run -d --rm -p 9000:9000 \ -e KAFKA_KEYSTORE="$(cat kafka.keystore.jks | base64)" \ # optional obsidiandynamics/kafdrop ``` + +Rather than passing `KAFKA_PROPERTIES` as a base64-encoded string, you can also place a pre-populated `KAFKA_PROPERTIES_FILE` into the container: + +```sh +docker run -d --rm -p 9000:9000 \ + -v $(pwd)/kafka.properties:/tmp/kafka.properties:ro \ + -e KAFKA_BROKERCONNECT= \ + -e KAFKA_PROPERTIES_FILE=/tmp/kafka.properties \ + -e KAFKA_TRUSTSTORE="$(cat kafka.truststore.jks | base64)" \ # optional + -e KAFKA_KEYSTORE="$(cat kafka.keystore.jks | base64)" \ # optional + obsidiandynamics/kafdrop +``` + #### Environment Variables ##### Basic configuration |Name |Description From 4a9a6f09f1928ee5d8f5629a914ff3bcf4d5d8e4 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 09:11:39 -0400 Subject: [PATCH 6/8] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fd702958..fd666ad3 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,12 @@ docker run -d --rm -p 9000:9000 \ Rather than passing `KAFKA_PROPERTIES` as a base64-encoded string, you can also place a pre-populated `KAFKA_PROPERTIES_FILE` into the container: ```sh +cat << EOF > kafka.properties +security.protocol=SASL_SSL +sasl.mechanism=SCRAM-SHA-512 +sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="foo" password="bar" +EOF + docker run -d --rm -p 9000:9000 \ -v $(pwd)/kafka.properties:/tmp/kafka.properties:ro \ -e KAFKA_BROKERCONNECT= \ From 5ffb777f027c78fd23450908941da5d2fbeecee9 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:04:05 -0400 Subject: [PATCH 7/8] Use elif->touch pattern for all _FILE vars --- src/main/docker/kafdrop.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index c7aaeb74..e0cef057 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -39,24 +39,24 @@ KAFKA_PROPERTIES_FILE=${KAFKA_PROPERTIES_FILE:-kafka.properties} if [ "$KAFKA_PROPERTIES" != "" ]; then echo Writing Kafka properties into $KAFKA_PROPERTIES_FILE echo "$KAFKA_PROPERTIES" | base64 --decode --ignore-garbage > $KAFKA_PROPERTIES_FILE -else - if [ ! -f $KAFKA_PROPERTIES_FILE ]; then touch $KAFKA_PROPERTIES_FILE; fi +elif [ ! -f $KAFKA_PROPERTIES_FILE ]; then + touch $KAFKA_PROPERTIES_FILE fi KAFKA_TRUSTSTORE_FILE=${KAFKA_TRUSTSTORE_FILE:-kafka.truststore.jks} if [ "$KAFKA_TRUSTSTORE" != "" ]; then echo Writing Kafka truststore into $KAFKA_TRUSTSTORE_FILE echo "$KAFKA_TRUSTSTORE" | base64 --decode --ignore-garbage > $KAFKA_TRUSTSTORE_FILE -else - rm $KAFKA_TRUSTSTORE_FILE |& > /dev/null | true +elif [ ! -f $KAFKA_TRUSTSTORE_FILE ]; then + touch $KAFKA_TRUSTSTORE_FILE fi KAFKA_KEYSTORE_FILE=${KAFKA_KEYSTORE_FILE:-kafka.keystore.jks} if [ "$KAFKA_KEYSTORE" != "" ]; then echo Writing Kafka keystore into $KAFKA_KEYSTORE_FILE echo "$KAFKA_KEYSTORE" | base64 --decode --ignore-garbage > $KAFKA_KEYSTORE_FILE -else - rm $KAFKA_KEYSTORE_FILE |& > /dev/null | true +elif [ ! -f $KAFKA_KEYSTORE_FILE ]; then + touch $KAFKA_KEYSTORE_FILE fi ARGS="--add-opens=java.base/sun.nio.ch=ALL-UNNAMED -Xss256K \ From bdd0d2bc3a11d22de4936da61900de35c4b05b02 Mon Sep 17 00:00:00 2001 From: Brad Solomon <81818815+brsolomon-deloitte@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:16:21 -0400 Subject: [PATCH 8/8] Update README.md Co-authored-by: Bert Roos --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd666ad3..8894776c 100644 --- a/README.md +++ b/README.md @@ -268,10 +268,12 @@ EOF docker run -d --rm -p 9000:9000 \ -v $(pwd)/kafka.properties:/tmp/kafka.properties:ro \ + -v $(pwd)/kafka.truststore.jks:/tmp/kafka.truststore.jks:ro \ + -v $(pwd)/kafka.keystore.jks:/tmp/kafka.keystore.jks:ro \ -e KAFKA_BROKERCONNECT= \ -e KAFKA_PROPERTIES_FILE=/tmp/kafka.properties \ - -e KAFKA_TRUSTSTORE="$(cat kafka.truststore.jks | base64)" \ # optional - -e KAFKA_KEYSTORE="$(cat kafka.keystore.jks | base64)" \ # optional + -e KAFKA_TRUSTSTORE_FILE=/tmp/kafka.truststore.jks \ # optional + -e KAFKA_KEYSTORE_FILE=/tmp/kafka.keystore.jks \ # optional obsidiandynamics/kafdrop ```