From f5fc72c17115cba9482b440221717ce134c62914 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 05:48:18 +0200 Subject: [PATCH 01/25] Runs the official Kafka distribution on the new Debian stable --- kafka/Dockerfile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 4d43b54..3cfc3ab 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -1,13 +1,19 @@ -FROM openjdk:8-jre-alpine +FROM debian:stable-20170620 -ARG kafka_version=0.10.2.0 -ENV kafka_bin_version=2.12-$kafka_version +ENV KAFKA_VERSION=0.11.0.0 +ENV kafka_bin_version=2.12-$KAFKA_VERSION -RUN apk add --no-cache --update-cache --virtual build-dependencies curl ca-certificates \ - && mkdir -p /opt/kafka \ - && curl -SLs "https://www-eu.apache.org/dist/kafka/$kafka_version/kafka_$kafka_bin_version.tgz" | tar -xzf - --strip-components=1 -C /opt/kafka \ - && apk del build-dependencies \ - && rm -rf /var/cache/apk/* +RUN set -ex; \ + runDeps='default-jre'; \ + buildDeps='curl ca-certificates'; \ + apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /opt/kafka; \ + curl -SLs "https://www-eu.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$kafka_bin_version.tgz" | tar -xzf - --strip-components=1 -C /opt/kafka; \ + \ + apt-get purge -y --auto-remove $buildDeps; \ + rm /var/log/dpkg.log /var/log/apt/*.log WORKDIR /opt/kafka ENTRYPOINT ["bin/kafka-server-start.sh"] From eeee33b3e3587cc6f6217b594afe9b244e37a9a1 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 05:53:11 +0200 Subject: [PATCH 02/25] https://kafka.apache.org/downloads says "2.11 is recommended" --- kafka/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 3cfc3ab..a0f08df 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -1,7 +1,7 @@ FROM debian:stable-20170620 ENV KAFKA_VERSION=0.11.0.0 -ENV kafka_bin_version=2.12-$KAFKA_VERSION +ENV kafka_bin_version=2.11-$KAFKA_VERSION RUN set -ex; \ runDeps='default-jre'; \ From 99f4d45a138c112c54941191bacff4220f900194 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 06:41:09 +0200 Subject: [PATCH 03/25] Uses Zulu jre/jdk like cp-docker-images base does --- kafka/Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index a0f08df..0ec0c2f 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -1,18 +1,22 @@ FROM debian:stable-20170620 -ENV KAFKA_VERSION=0.11.0.0 +ENV KAFKA_VERSION=0.11.0.0 ZULU_OPENJDK_VERSION="8=8.21.0.1" ENV kafka_bin_version=2.11-$KAFKA_VERSION RUN set -ex; \ - runDeps='default-jre'; \ - buildDeps='curl ca-certificates'; \ + runDeps=''; \ + buildDeps='curl ca-certificates gnupg dirmngr'; \ apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends; \ - rm -rf /var/lib/apt/lists/*; \ + \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9; \ + echo 'deb http://repos.azulsystems.com/debian stable main' > /etc/apt/sources.list.d/zulu.list; \ + apt-get update && apt-get install -y zulu-${ZULU_OPENJDK_VERSION} --no-install-recommends; \ \ mkdir -p /opt/kafka; \ curl -SLs "https://www-eu.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$kafka_bin_version.tgz" | tar -xzf - --strip-components=1 -C /opt/kafka; \ \ apt-get purge -y --auto-remove $buildDeps; \ + rm -rf /var/lib/apt/lists/*; \ rm /var/log/dpkg.log /var/log/apt/*.log WORKDIR /opt/kafka From 8bf55a15576a617f9f5513153c055a78e31b9164 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 06:59:17 +0200 Subject: [PATCH 04/25] Drops a layer --- kafka/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 0ec0c2f..ba412e4 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -1,7 +1,6 @@ FROM debian:stable-20170620 -ENV KAFKA_VERSION=0.11.0.0 ZULU_OPENJDK_VERSION="8=8.21.0.1" -ENV kafka_bin_version=2.11-$KAFKA_VERSION +ENV KAFKA_VERSION=0.11.0.0 ZULU_OPENJDK_VERSION="8=8.21.0.1" KAFKA_BIN_SCALA_VERSION=2.11 RUN set -ex; \ runDeps=''; \ @@ -13,7 +12,7 @@ RUN set -ex; \ apt-get update && apt-get install -y zulu-${ZULU_OPENJDK_VERSION} --no-install-recommends; \ \ mkdir -p /opt/kafka; \ - curl -SLs "https://www-eu.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$kafka_bin_version.tgz" | tar -xzf - --strip-components=1 -C /opt/kafka; \ + curl -SLs "https://www-eu.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$KAFKA_BIN_SCALA_VERSION-$KAFKA_VERSION.tgz" | tar -xzf - --strip-components=1 -C /opt/kafka; \ \ apt-get purge -y --auto-remove $buildDeps; \ rm -rf /var/lib/apt/lists/*; \ From c4066a75693f849e2efcf7397ca75213c69b166e Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 10:24:23 +0200 Subject: [PATCH 05/25] Starts a build-contract to smoke test and exemplify image use cases --- README.md | 12 +++++++++- build-contracts/docker-compose.yml | 38 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 build-contracts/docker-compose.yml diff --git a/README.md b/README.md index d77cfc4..ebad24b 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,14 @@ see https://github.com/solsson/dockerfiles/tree/misc-dockerfiles. # Kafka docker builds This repository maintains automated [Kafka](http://kafka.apache.org/) builds for https://hub.docker.com/r/solsson/kafka/ -and related `kafka-` images under https://hub.docker.com/u/solsson/, used with https://github.com/Yolean/kubernetes-kafka/. +and related `kafka-` images under https://hub.docker.com/u/solsson/. + +These images are tested in production with https://github.com/Yolean/kubernetes-kafka/. + +## Building + +Rudimentary compliance with kubernetes-kafka is tested using a [build-contract](https://github.com/Yolean/build-contract/). + +Build and test using: `docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/:/source solsson/build-contract test` + +To keep kafka running for local use, uncomment `ports` 9092 and run: `docker-compose -f build-contracts/docker-compose.yml`. diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml new file mode 100644 index 0000000..8ef2b65 --- /dev/null +++ b/build-contracts/docker-compose.yml @@ -0,0 +1,38 @@ +version: '2.0' +services: + + zookeeper: + build: ../kafka + entrypoint: ./bin/zookeeper-server-start.sh + command: + - config/zookeeper.properties + + kafka-1: + build: ../kafka + command: + - config/server.properties + - --override + - broker.id=1 + # unlike Kubernetes StatefulSet, compose gives containers a reandom hostname (leading to redirects to a hex name) + - --override + - advertised.listener=PLAINTEXT://kafka-1:9092 + + test-topic-create-1: + build: ../kafka + labels: + com.yolean.build-contract: "" + entrypoint: ./bin/kafka-topics.sh + command: + - --zookeeper + - zookeeper:2181 + - --create + - --topic test1 + + test-snappy-compression: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + entrypoint: /bin/sh + command: + - -exc + - sleep 5; echo "Message from $${HOSTNAME} at $$(date)" | kafkacat -z snappy -b kafka-1:9092 -t test1 -P From 028aed1c184dc537f781a25f25e81953e24c3b21 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 13:07:58 +0200 Subject: [PATCH 06/25] Fixes topic creation, but with startup timing issues because the script doesn't retry --- README.md | 9 ++++++++- build-contracts/docker-compose.yml | 21 +++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ebad24b..717622a 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,11 @@ Rudimentary compliance with kubernetes-kafka is tested using a [build-contract]( Build and test using: `docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/:/source solsson/build-contract test` -To keep kafka running for local use, uncomment `ports` 9092 and run: `docker-compose -f build-contracts/docker-compose.yml`. +To keep kafka running for local use, uncomment `ports` 9092 and run: `docker-compose -f build-contracts/docker-compose.yml up --force-recreate`. + +While timing issues remain, start services individually +```bash +compose='docker-compose -f build-contracts/docker-compose.yml' +$compose up -d zookeeper kafka-0 +$compose up test-topic-create-1 +``` diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index 8ef2b65..eaf197f 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -7,26 +7,35 @@ services: command: - config/zookeeper.properties - kafka-1: + kafka-0: build: ../kafka command: - config/server.properties - --override - - broker.id=1 - # unlike Kubernetes StatefulSet, compose gives containers a reandom hostname (leading to redirects to a hex name) + - broker.id=0 + # unlike Kubernetes StatefulSet, compose gives containers a random hostname (leading to redirects to a hex name) - --override - - advertised.listener=PLAINTEXT://kafka-1:9092 + - advertised.listener=PLAINTEXT://kafka-0:9092 + - --override + - auto.create.topics.enable=false test-topic-create-1: build: ../kafka labels: com.yolean.build-contract: "" + links: + - kafka-0 entrypoint: ./bin/kafka-topics.sh command: - --zookeeper - zookeeper:2181 - --create - - --topic test1 + - --topic + - test1 + - --partitions + - '1' + - --replication-factor + - '1' test-snappy-compression: image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 @@ -35,4 +44,4 @@ services: entrypoint: /bin/sh command: - -exc - - sleep 5; echo "Message from $${HOSTNAME} at $$(date)" | kafkacat -z snappy -b kafka-1:9092 -t test1 -P + - sleep 5; echo "Message from $${HOSTNAME} at $$(date)" | kafkacat -z snappy -b kafka-0:9092 -t test1 -P From f52bd3b4aada6fc0b1718a6fe51ee7a561439da8 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 13:16:57 +0200 Subject: [PATCH 07/25] Adds a consumer --- README.md | 1 + build-contracts/docker-compose.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 717622a..5cb548f 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,5 @@ While timing issues remain, start services individually compose='docker-compose -f build-contracts/docker-compose.yml' $compose up -d zookeeper kafka-0 $compose up test-topic-create-1 +$compose up test-snappy-compression ``` diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index eaf197f..d7187ac 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -45,3 +45,17 @@ services: command: - -exc - sleep 5; echo "Message from $${HOSTNAME} at $$(date)" | kafkacat -z snappy -b kafka-0:9092 -t test1 -P + + test-consume-all: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + command: + - -b + - kafka-0:9092 + - -t + - test1 + - -C + - -o + - beginning + - -e From bdea1ad1375506adea16f29d8f8ed66c14483409 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 14:02:37 +0200 Subject: [PATCH 08/25] For previous commit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5cb548f..5df2e64 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,5 @@ compose='docker-compose -f build-contracts/docker-compose.yml' $compose up -d zookeeper kafka-0 $compose up test-topic-create-1 $compose up test-snappy-compression +$compose up test-consume-all ``` From ea54416aa50db811387fce6f248dbcff459212c0 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 14:03:06 +0200 Subject: [PATCH 09/25] Quick attempt to verify that the image works with Connect. Class doesn't load. --- kafka-connect-jmx/Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 kafka-connect-jmx/Dockerfile diff --git a/kafka-connect-jmx/Dockerfile b/kafka-connect-jmx/Dockerfile new file mode 100644 index 0000000..771ca5d --- /dev/null +++ b/kafka-connect-jmx/Dockerfile @@ -0,0 +1,19 @@ +FROM solsson/kafka + +RUN apt-get update && apt-get install -y maven --no-install-recommends + +# TODO sort out where Zulu is, and/or tools.jar +RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends + +RUN set -ex; \ + mkdir /usr/src/kafka-connect; \ + cd /usr/src/kafka-connect; \ + curl -SLs https://github.com/srijiths/kafka-connectors/archive/dc0a7122650e697d3ae97c970a4785bbed949479.tar.gz \ + | tar -xzf - --strip-components=1 -C ./; \ + mvn clean install; + +# /usr/share/java is the recommendation from http://docs.confluent.io/current/cp-docker-images/docs/intro.html#important-notes-caveats +RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar /usr/share/java/ + +ENTRYPOINT ["./bin/connect-standalone.sh"] +CMD ["./config/connect-standalone.properties", "/usr/src/kafka-connect/kafka-connect-jmx/config/sample-jmx-configuration.properties"] From 16ef01bb3afc4675a78f1cc2fdb5d9d29014e38c Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 14:33:05 +0200 Subject: [PATCH 10/25] Allow automatic topic creation again, to simplify test setup --- build-contracts/docker-compose.yml | 21 +++++++++++++++++---- kafka-connect-jmx/Dockerfile | 7 +++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index d7187ac..0247a09 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -16,10 +16,8 @@ services: # unlike Kubernetes StatefulSet, compose gives containers a random hostname (leading to redirects to a hex name) - --override - advertised.listener=PLAINTEXT://kafka-0:9092 - - --override - - auto.create.topics.enable=false - test-topic-create-1: + test-topic-create: build: ../kafka labels: com.yolean.build-contract: "" @@ -31,7 +29,7 @@ services: - zookeeper:2181 - --create - --topic - - test1 + - test-topic-create - --partitions - '1' - --replication-factor @@ -59,3 +57,18 @@ services: - -o - beginning - -e + + test-kafka-connect: + build: ../kafka + labels: + com.yolean.build-contract: "" + links: + - kafka-0 + entrypoint: ./bin/connect-standalone.sh + command: + # TODO we need to configure bootstrap.servers=kafka-0:9092 here + - ./config/connect-standalone.properties + - ./config/connect-file-source.properties + + test-kafka-connect-build: + build: ../kafka-connect-jmx diff --git a/kafka-connect-jmx/Dockerfile b/kafka-connect-jmx/Dockerfile index 771ca5d..9c5f23c 100644 --- a/kafka-connect-jmx/Dockerfile +++ b/kafka-connect-jmx/Dockerfile @@ -1,6 +1,6 @@ -FROM solsson/kafka +FROM solsson/kafka:0.11.0.0 -RUN apt-get update && apt-get install -y maven --no-install-recommends +RUN apt-get update && apt-get install -y maven curl ca-certificates --no-install-recommends # TODO sort out where Zulu is, and/or tools.jar RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends @@ -12,8 +12,7 @@ RUN set -ex; \ | tar -xzf - --strip-components=1 -C ./; \ mvn clean install; -# /usr/share/java is the recommendation from http://docs.confluent.io/current/cp-docker-images/docs/intro.html#important-notes-caveats -RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar /usr/share/java/ +RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar ./libs/ ENTRYPOINT ["./bin/connect-standalone.sh"] CMD ["./config/connect-standalone.properties", "/usr/src/kafka-connect/kafka-connect-jmx/config/sample-jmx-configuration.properties"] From 73ea9784ccd5363dde6ba7268721704b6db9bb7b Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 22:11:22 +0200 Subject: [PATCH 11/25] Each connect setup will have to be its own docker build... as even without additional jars it needs properties files. --- build-contracts/docker-compose.yml | 16 +++---- connect-files/Dockerfile | 7 +++ .../connect-file-source.properties.template | 20 ++++++++ connect-files/connect-files.sh | 8 ++++ connect-files/worker.properties | 48 +++++++++++++++++++ 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 connect-files/Dockerfile create mode 100644 connect-files/connect-file-source.properties.template create mode 100755 connect-files/connect-files.sh create mode 100644 connect-files/worker.properties diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index 0247a09..3cd5734 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -58,17 +58,17 @@ services: - beginning - -e - test-kafka-connect: - build: ../kafka - labels: - com.yolean.build-contract: "" + connect-file-find: + build: ../connect-file-glob links: - kafka-0 - entrypoint: ./bin/connect-standalone.sh + # set up a development container + entrypoint: /bin/sh command: - # TODO we need to configure bootstrap.servers=kafka-0:9092 here - - ./config/connect-standalone.properties - - ./config/connect-file-source.properties + - -exc + - tail -f /dev/null + volumes: + - ../connect-files:/usr/src/connect-files test-kafka-connect-build: build: ../kafka-connect-jmx diff --git a/connect-files/Dockerfile b/connect-files/Dockerfile new file mode 100644 index 0000000..42d0873 --- /dev/null +++ b/connect-files/Dockerfile @@ -0,0 +1,7 @@ +FROM solsson/kafka:0.11.0.0 + +COPY worker.properties ./config/ +COPY connect-file-source.properties.template +COPY connect-files.sh ./bin/ + +ENV FILES_LIST_CMD="find /logs/ -name *.log" diff --git a/connect-files/connect-file-source.properties.template b/connect-files/connect-file-source.properties.template new file mode 100644 index 0000000..599cf4c --- /dev/null +++ b/connect-files/connect-file-source.properties.template @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name=local-file-source +connector.class=FileStreamSource +tasks.max=1 +file=test.txt +topic=connect-test \ No newline at end of file diff --git a/connect-files/connect-files.sh b/connect-files/connect-files.sh new file mode 100755 index 0000000..2563101 --- /dev/null +++ b/connect-files/connect-files.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +FILES=$($FILES_LIST_CMD) + +for F in $FILES; do + echo $F; + +done diff --git a/connect-files/worker.properties b/connect-files/worker.properties new file mode 100644 index 0000000..0039796 --- /dev/null +++ b/connect-files/worker.properties @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# These are defaults. This file just demonstrates how to override some settings. +bootstrap.servers=localhost:9092 + +# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will +# need to configure these based on the format they want their data in when loaded from or stored into Kafka +key.converter=org.apache.kafka.connect.json.JsonConverter +value.converter=org.apache.kafka.connect.json.JsonConverter +# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply +# it to +key.converter.schemas.enable=true +value.converter.schemas.enable=true + +# The internal converter used for offsets and config data is configurable and must be specified, but most users will +# always want to use the built-in default. Offset and config data is never visible outside of Kafka Connect in this format. +internal.key.converter=org.apache.kafka.connect.json.JsonConverter +internal.value.converter=org.apache.kafka.connect.json.JsonConverter +internal.key.converter.schemas.enable=false +internal.value.converter.schemas.enable=false + +offset.storage.file.filename=/tmp/connect.offsets +# Flush much faster than normal, which is useful for testing/debugging +offset.flush.interval.ms=10000 + +# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins +# (connectors, converters, transformations). The list should consist of top level directories that include +# any combination of: +# a) directories immediately containing jars with plugins and their dependencies +# b) uber-jars with plugins and their dependencies +# c) directories immediately containing the package directory structure of classes of plugins and their dependencies +# Note: symlinks will be followed to discover dependencies or plugins. +# Examples: +# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors, +#plugin.path= From 7b82d0f6d95b919dafd3c672104d6e744fa38616 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 20 Jul 2017 22:29:43 +0200 Subject: [PATCH 12/25] Quite useful log aggregation --- README.md | 2 ++ build-contracts/docker-compose.yml | 27 +++++++++++++------ connect-files/Dockerfile | 7 ++++- .../connect-file-source.properties.template | 20 -------------- connect-files/connect-files.sh | 18 +++++++++++-- connect-files/worker.properties | 2 +- 6 files changed, 44 insertions(+), 32 deletions(-) delete mode 100644 connect-files/connect-file-source.properties.template diff --git a/README.md b/README.md index 5df2e64..5dfa36a 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,6 @@ $compose up -d zookeeper kafka-0 $compose up test-topic-create-1 $compose up test-snappy-compression $compose up test-consume-all +$compose up --build -d consume-files +$compose up test-consume-files ``` diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index 3cd5734..6152ca6 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -9,6 +9,8 @@ services: kafka-0: build: ../kafka + links: + - zookeeper command: - config/server.properties - --override @@ -58,17 +60,26 @@ services: - beginning - -e - connect-file-find: - build: ../connect-file-glob + connect-files: + build: ../connect-files links: - kafka-0 - # set up a development container - entrypoint: /bin/sh - command: - - -exc - - tail -f /dev/null + # test with some real logs volumes: - - ../connect-files:/usr/src/connect-files + - /var/log:/logs + + test-consume-files: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + command: + - -b + - kafka-0:9092 + - -t + - files-000 + - -C + - -o + - beginning test-kafka-connect-build: build: ../kafka-connect-jmx diff --git a/connect-files/Dockerfile b/connect-files/Dockerfile index 42d0873..cc549b8 100644 --- a/connect-files/Dockerfile +++ b/connect-files/Dockerfile @@ -1,7 +1,12 @@ FROM solsson/kafka:0.11.0.0 COPY worker.properties ./config/ -COPY connect-file-source.properties.template COPY connect-files.sh ./bin/ ENV FILES_LIST_CMD="find /logs/ -name *.log" + +# Set up some sample logs +RUN mkdir /logs/; \ + echo "Mount /logs and/or change FILES_LIST_CMD (currently '$FILES_LIST_CMD') to read real content instead" > /logs/samplefile1.log; + +ENTRYPOINT ["./bin/connect-files.sh"] diff --git a/connect-files/connect-file-source.properties.template b/connect-files/connect-file-source.properties.template deleted file mode 100644 index 599cf4c..0000000 --- a/connect-files/connect-file-source.properties.template +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name=local-file-source -connector.class=FileStreamSource -tasks.max=1 -file=test.txt -topic=connect-test \ No newline at end of file diff --git a/connect-files/connect-files.sh b/connect-files/connect-files.sh index 2563101..cf5007b 100755 --- a/connect-files/connect-files.sh +++ b/connect-files/connect-files.sh @@ -1,8 +1,22 @@ #!/bin/bash +set -e FILES=$($FILES_LIST_CMD) -for F in $FILES; do - echo $F; +id=0 +connectors="" +for FILE in $FILES; do + ((++id)) + echo "$id: $FILE" + cat < ./config/connect-file-source-$id.properties +name=local-file-source-${id} +connector.class=FileStreamSource +tasks.max=1 +file=${FILE} +topic=files-000 +HERE + connectors="$connectors ./config/connect-file-source-$id.properties" done + +./bin/connect-standalone.sh ./config/worker.properties $connectors diff --git a/connect-files/worker.properties b/connect-files/worker.properties index 0039796..ff76cd3 100644 --- a/connect-files/worker.properties +++ b/connect-files/worker.properties @@ -14,7 +14,7 @@ # limitations under the License. # These are defaults. This file just demonstrates how to override some settings. -bootstrap.servers=localhost:9092 +bootstrap.servers=kafka-0:9092 # The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will # need to configure these based on the format they want their data in when loaded from or stored into Kafka From 845fafff77b2060589fa70ed9fa19d73e72140eb Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 21 Jul 2017 17:18:24 +0200 Subject: [PATCH 13/25] worker.properties can basically be copied among connect builds --- connect-jmx/Dockerfile | 22 ++++++++++++++++ connect-jmx/worker.properties | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 connect-jmx/Dockerfile create mode 100644 connect-jmx/worker.properties diff --git a/connect-jmx/Dockerfile b/connect-jmx/Dockerfile new file mode 100644 index 0000000..a36df75 --- /dev/null +++ b/connect-jmx/Dockerfile @@ -0,0 +1,22 @@ +FROM solsson/kafka:0.11.0.0 + +# Note: this is an experimental build that isn't at all optimized to reduce size + +RUN apt-get update && apt-get install -y maven curl ca-certificates --no-install-recommends + +# TODO sort out where Zulu is, and/or tools.jar +RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends + +RUN set -ex; \ + mkdir /usr/src/kafka-connect; \ + cd /usr/src/kafka-connect; \ + curl -SLs https://github.com/srijiths/kafka-connectors/archive/dc0a7122650e697d3ae97c970a4785bbed949479.tar.gz \ + | tar -xzf - --strip-components=1 -C ./; \ + mvn clean install; + +RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar ./libs/ + +COPY *.properties ./config/ + +ENTRYPOINT ["./bin/connect-standalone.sh"] +CMD ["./config/worker.properties", "./config/connect-jmx.properties"] diff --git a/connect-jmx/worker.properties b/connect-jmx/worker.properties new file mode 100644 index 0000000..ff76cd3 --- /dev/null +++ b/connect-jmx/worker.properties @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# These are defaults. This file just demonstrates how to override some settings. +bootstrap.servers=kafka-0:9092 + +# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will +# need to configure these based on the format they want their data in when loaded from or stored into Kafka +key.converter=org.apache.kafka.connect.json.JsonConverter +value.converter=org.apache.kafka.connect.json.JsonConverter +# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply +# it to +key.converter.schemas.enable=true +value.converter.schemas.enable=true + +# The internal converter used for offsets and config data is configurable and must be specified, but most users will +# always want to use the built-in default. Offset and config data is never visible outside of Kafka Connect in this format. +internal.key.converter=org.apache.kafka.connect.json.JsonConverter +internal.value.converter=org.apache.kafka.connect.json.JsonConverter +internal.key.converter.schemas.enable=false +internal.value.converter.schemas.enable=false + +offset.storage.file.filename=/tmp/connect.offsets +# Flush much faster than normal, which is useful for testing/debugging +offset.flush.interval.ms=10000 + +# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins +# (connectors, converters, transformations). The list should consist of top level directories that include +# any combination of: +# a) directories immediately containing jars with plugins and their dependencies +# b) uber-jars with plugins and their dependencies +# c) directories immediately containing the package directory structure of classes of plugins and their dependencies +# Note: symlinks will be followed to discover dependencies or plugins. +# Examples: +# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors, +#plugin.path= From 50e0c9a993f0701a867ceba67f93d45b0b21cb48 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 21 Jul 2017 20:56:07 +0200 Subject: [PATCH 14/25] Demonstrates JMX to HTTP /metrics --- README.md | 3 +- build-contracts/docker-compose.yml | 38 ++++++++++++++++++- connect-jmx/connect-jmx.properties | 19 ++++++++++ kafka-connect-jmx/Dockerfile | 18 --------- .../Dockerfile | 0 5 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 connect-jmx/connect-jmx.properties delete mode 100644 kafka-connect-jmx/Dockerfile rename {kafka-prometheus-jmx-exporter => prometheus-jmx-exporter}/Dockerfile (100%) diff --git a/README.md b/README.md index 5dfa36a..d0c8e30 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ $compose up -d zookeeper kafka-0 $compose up test-topic-create-1 $compose up test-snappy-compression $compose up test-consume-all -$compose up --build -d consume-files +$compose up prometheus-jmx-exporter test-metrics-export +$compose up --build -d connect-files $compose up test-consume-files ``` diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index 6152ca6..eb76bda 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -11,6 +11,10 @@ services: build: ../kafka links: - zookeeper + environment: + - JMX_PORT=5555 + expose: + - '5555' command: - config/server.properties - --override @@ -19,6 +23,34 @@ services: - --override - advertised.listener=PLAINTEXT://kafka-0:9092 + prometheus-jmx-exporter: + #build: ../prometheus-jmx-exporter + image: solsson/kafka-prometheus-jmx-exporter + labels: + com.yolean.build-target: "" + links: + - kafka-0 + # patch a config before start, as the image is designed for use with local JMX (same k8s pod) + entrypoint: /bin/bash + command: + - -c + - > + sed -i 's|127.0.0.1|kafka-0|' example_configs/kafka-prometheus-monitoring.yml; + cat example_configs/kafka-prometheus-monitoring.yml; + java -jar jmx_prometheus_httpserver.jar + 5556 example_configs/kafka-prometheus-monitoring.yml + + test-metrics-export: + image: solsson/curl@sha256:8b0927b81d10043e70f3e05e33e36fb9b3b0cbfcbccdb9f04fd53f67a270b874 + command: + - --fail-early + - --retry + - '10' + - --retry-delay + - '3' + - --retry-connrefused + - http://prometheus-jmx-exporter:5556/metrics + test-topic-create: build: ../kafka labels: @@ -81,5 +113,7 @@ services: - -o - beginning - test-kafka-connect-build: - build: ../kafka-connect-jmx + connect-jmx: + build: ../connect-jmx + links: + - kafka-0 diff --git a/connect-jmx/connect-jmx.properties b/connect-jmx/connect-jmx.properties new file mode 100644 index 0000000..23b7dd5 --- /dev/null +++ b/connect-jmx/connect-jmx.properties @@ -0,0 +1,19 @@ +# Name of the connecor +name=jmx-source +# Connector class to invoke the connector +connector.class=com.sree.kafka.connectors.jmx.JmxConnector +# Maximum number of tasks +tasks.max=1 + +# Kafka topic to push the messages +kafka.topic=jmx-test +# JMX is running for which application. +# If you want JMX metrics for Kafka , then jmx.servicename=kafka +# If you want JMX metrics for Flink , then jmx.servicename=flink etc.. +jmx.servicename=kafka +# If jmx.servicename is kafka , then you have to provide zookeeper.host +# Else zookeeper.host parameter is not required. +zookeeper.host=zookeeper:2181 +# If jmx.servicename is not kafka , then below property is mandatory +# Provide the full JMX URL separated by comma +#jmx.url=54.238.221.37:8080,54.238.237.66:8080 diff --git a/kafka-connect-jmx/Dockerfile b/kafka-connect-jmx/Dockerfile deleted file mode 100644 index 9c5f23c..0000000 --- a/kafka-connect-jmx/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM solsson/kafka:0.11.0.0 - -RUN apt-get update && apt-get install -y maven curl ca-certificates --no-install-recommends - -# TODO sort out where Zulu is, and/or tools.jar -RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends - -RUN set -ex; \ - mkdir /usr/src/kafka-connect; \ - cd /usr/src/kafka-connect; \ - curl -SLs https://github.com/srijiths/kafka-connectors/archive/dc0a7122650e697d3ae97c970a4785bbed949479.tar.gz \ - | tar -xzf - --strip-components=1 -C ./; \ - mvn clean install; - -RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar ./libs/ - -ENTRYPOINT ["./bin/connect-standalone.sh"] -CMD ["./config/connect-standalone.properties", "/usr/src/kafka-connect/kafka-connect-jmx/config/sample-jmx-configuration.properties"] diff --git a/kafka-prometheus-jmx-exporter/Dockerfile b/prometheus-jmx-exporter/Dockerfile similarity index 100% rename from kafka-prometheus-jmx-exporter/Dockerfile rename to prometheus-jmx-exporter/Dockerfile From 4b183a5b01d72b24f2cb4d88ea6d0b7a31ae86b6 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 21 Jul 2017 21:04:09 +0200 Subject: [PATCH 15/25] Demonstrates built connect jar, but messages are encoded json in outer json's payload --- README.md | 10 +++++++++- build-contracts/docker-compose.yml | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0c8e30..7c5dca9 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,22 @@ Build and test using: `docker run -v /var/run/docker.sock:/var/run/docker.sock - To keep kafka running for local use, uncomment `ports` 9092 and run: `docker-compose -f build-contracts/docker-compose.yml up --force-recreate`. -While timing issues remain, start services individually +While timing issues remain, start services individually... + ```bash compose='docker-compose -f build-contracts/docker-compose.yml' $compose up -d zookeeper kafka-0 +$compose logs zookeeper kafka-0 +# can we create topics using the image's provided script? $compose up test-topic-create-1 +# can a producer send messages using snappy (has issues before with a class missing in the image) $compose up test-snappy-compression $compose up test-consume-all +# demo the prometheus exporter image $compose up prometheus-jmx-exporter test-metrics-export +# demo the log/file aggregation image $compose up --build -d connect-files $compose up test-consume-files +# demo the JMX->kafka image +$compose up --build connect-jmx test-jmx ``` diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index eb76bda..be5a417 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -115,5 +115,20 @@ services: connect-jmx: build: ../connect-jmx + labels: + com.yolean.build-target: "" links: - kafka-0 + + test-jmx: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + command: + - -b + - kafka-0:9092 + - -t + - jmx-test + - -C + - -o + - beginning From 87d31727b7a20c71f0df326b6ca5e7581fa8f47c Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:02:37 +0200 Subject: [PATCH 16/25] Splits into separate docker-compose setups per area of interest --- README.md | 19 +++-- .../docker-compose.files-aggregation.yml | 46 +++++++++++ build-contracts/docker-compose.monitoring.yml | 74 ++++++++++++++++++ build-contracts/docker-compose.yml | 78 ++----------------- 4 files changed, 139 insertions(+), 78 deletions(-) create mode 100644 build-contracts/docker-compose.files-aggregation.yml create mode 100644 build-contracts/docker-compose.monitoring.yml diff --git a/README.md b/README.md index 7c5dca9..7d65311 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,18 @@ and related `kafka-` images under https://hub.docker.com/u/solsson/. These images are tested in production with https://github.com/Yolean/kubernetes-kafka/. +## One image to rule them all + +Official [Kafka distributions](http://kafka.apache.org/downloads) contain startup scripts and config for various services and clients. Thus `./kafka` produces a multi-purpose image for direct use and specialized docker builds. + +### Example of downstream image: Kafka Connect + +See ./connect-jmx + +### Example downstream image: Kafka Streams + +TODO + ## Building Rudimentary compliance with kubernetes-kafka is tested using a [build-contract](https://github.com/Yolean/build-contract/). @@ -31,11 +43,8 @@ $compose up test-topic-create-1 # can a producer send messages using snappy (has issues before with a class missing in the image) $compose up test-snappy-compression $compose up test-consume-all -# demo the prometheus exporter image -$compose up prometheus-jmx-exporter test-metrics-export # demo the log/file aggregation image -$compose up --build -d connect-files -$compose up test-consume-files +docker-compose -f build-contracts/docker-compose.files-aggregation.yml up # demo the JMX->kafka image -$compose up --build connect-jmx test-jmx +docker-compose -f build-contracts/docker-compose.monitoring.yml up ``` diff --git a/build-contracts/docker-compose.files-aggregation.yml b/build-contracts/docker-compose.files-aggregation.yml new file mode 100644 index 0000000..0b29e07 --- /dev/null +++ b/build-contracts/docker-compose.files-aggregation.yml @@ -0,0 +1,46 @@ +version: '2.0' +services: + + zookeeper: + build: ../kafka + entrypoint: ./bin/zookeeper-server-start.sh + command: + - config/zookeeper.properties + + kafka-0: + build: ../kafka + links: + - zookeeper + command: + - config/server.properties + - --override + - broker.id=0 + - --override + - advertised.listener=PLAINTEXT://kafka-0:9092 + + connect-files: + build: ../connect-files + labels: + com.yolean.build-target: "" + links: + - kafka-0 + + test-connect-files-real-logs: + build: ../connect-files + links: + - kafka-0 + volumes: + - /var/log:/logs + + test-consume-files: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + command: + - -b + - kafka-0:9092 + - -t + - files-000 + - -C + - -o + - beginning diff --git a/build-contracts/docker-compose.monitoring.yml b/build-contracts/docker-compose.monitoring.yml new file mode 100644 index 0000000..0668f58 --- /dev/null +++ b/build-contracts/docker-compose.monitoring.yml @@ -0,0 +1,74 @@ +version: '2.0' +services: + + zookeeper: + build: ../kafka + entrypoint: ./bin/zookeeper-server-start.sh + command: + - config/zookeeper.properties + + kafka-0: + build: ../kafka + links: + - zookeeper + environment: + - JMX_PORT=5555 + expose: + - '5555' + command: + - config/server.properties + - --override + - broker.id=0 + - --override + - advertised.listener=PLAINTEXT://kafka-0:9092 + + prometheus-jmx-exporter: + build: ../prometheus-jmx-exporter + labels: + com.yolean.build-target: "" + links: + - kafka-0 + # patch a config before start, as the image is designed for use with local JMX (same k8s pod) + entrypoint: /bin/bash + command: + - -c + - > + sed -i 's|127.0.0.1|kafka-0|' example_configs/kafka-prometheus-monitoring.yml; + cat example_configs/kafka-prometheus-monitoring.yml; + java -jar jmx_prometheus_httpserver.jar + 5556 example_configs/kafka-prometheus-monitoring.yml + + test-metrics-export: + image: solsson/curl@sha256:8b0927b81d10043e70f3e05e33e36fb9b3b0cbfcbccdb9f04fd53f67a270b874 + labels: + com.yolean.build-contract: "" + command: + - --fail-early + - --retry + - '10' + - --retry-delay + - '3' + - --retry-connrefused + - http://prometheus-jmx-exporter:5556/metrics + + connect-jmx: + build: ../connect-jmx + labels: + com.yolean.build-target: "" + links: + - kafka-0 + + # TODO starts too fast, gets % KC_ERROR: Failed to query metadata for topic jmx-test: Local: Broker transport failure + # needs to retry until kafka+topic exists + test-jmx: + image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 + labels: + com.yolean.build-contract: "" + command: + - -b + - kafka-0:9092 + - -t + - jmx-test + - -C + - -o + - beginning diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index be5a417..5e0629a 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -9,12 +9,11 @@ services: kafka-0: build: ../kafka + image: solsson/kafka + labels: + com.yolean.build-target: "" links: - zookeeper - environment: - - JMX_PORT=5555 - expose: - - '5555' command: - config/server.properties - --override @@ -23,34 +22,6 @@ services: - --override - advertised.listener=PLAINTEXT://kafka-0:9092 - prometheus-jmx-exporter: - #build: ../prometheus-jmx-exporter - image: solsson/kafka-prometheus-jmx-exporter - labels: - com.yolean.build-target: "" - links: - - kafka-0 - # patch a config before start, as the image is designed for use with local JMX (same k8s pod) - entrypoint: /bin/bash - command: - - -c - - > - sed -i 's|127.0.0.1|kafka-0|' example_configs/kafka-prometheus-monitoring.yml; - cat example_configs/kafka-prometheus-monitoring.yml; - java -jar jmx_prometheus_httpserver.jar - 5556 example_configs/kafka-prometheus-monitoring.yml - - test-metrics-export: - image: solsson/curl@sha256:8b0927b81d10043e70f3e05e33e36fb9b3b0cbfcbccdb9f04fd53f67a270b874 - command: - - --fail-early - - --retry - - '10' - - --retry-delay - - '3' - - --retry-connrefused - - http://prometheus-jmx-exporter:5556/metrics - test-topic-create: build: ../kafka labels: @@ -78,6 +49,8 @@ services: - -exc - sleep 5; echo "Message from $${HOSTNAME} at $$(date)" | kafkacat -z snappy -b kafka-0:9092 -t test1 -P + # TODO starts too fast, gets % KC_ERROR: Failed to query metadata for topic test1: Local: Broker transport failure + # needs to retry until kafka+topic exists test-consume-all: image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 labels: @@ -91,44 +64,3 @@ services: - -o - beginning - -e - - connect-files: - build: ../connect-files - links: - - kafka-0 - # test with some real logs - volumes: - - /var/log:/logs - - test-consume-files: - image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 - labels: - com.yolean.build-contract: "" - command: - - -b - - kafka-0:9092 - - -t - - files-000 - - -C - - -o - - beginning - - connect-jmx: - build: ../connect-jmx - labels: - com.yolean.build-target: "" - links: - - kafka-0 - - test-jmx: - image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 - labels: - com.yolean.build-contract: "" - command: - - -b - - kafka-0:9092 - - -t - - jmx-test - - -C - - -o - - beginning From 74ad3aac742f433d207ecd0fb6304d01007648cc Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:03:43 +0200 Subject: [PATCH 17/25] Now adds less than 6 MB to the official image --- connect-jmx/Dockerfile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/connect-jmx/Dockerfile b/connect-jmx/Dockerfile index a36df75..6e84a78 100644 --- a/connect-jmx/Dockerfile +++ b/connect-jmx/Dockerfile @@ -1,20 +1,27 @@ FROM solsson/kafka:0.11.0.0 -# Note: this is an experimental build that isn't at all optimized to reduce size - -RUN apt-get update && apt-get install -y maven curl ca-certificates --no-install-recommends - -# TODO sort out where Zulu is, and/or tools.jar -RUN apt-get update && apt-get install -y openjdk-8-jdk-headless --no-install-recommends - RUN set -ex; \ - mkdir /usr/src/kafka-connect; \ - cd /usr/src/kafka-connect; \ + buildDeps='curl ca-certificates'; \ + apt-get update && apt-get install -y $buildDeps --no-install-recommends; \ + \ + MAVEN_VERSION=3.5.0 PATH=$PATH:$(pwd)/maven/bin; \ + mkdir ./maven; \ + curl -SLs https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzf - --strip-components=1 -C ./maven; \ + mvn --version; \ + \ + mkdir ./kafka-connectors; \ + cd ./kafka-connectors; \ curl -SLs https://github.com/srijiths/kafka-connectors/archive/dc0a7122650e697d3ae97c970a4785bbed949479.tar.gz \ | tar -xzf - --strip-components=1 -C ./; \ - mvn clean install; - -RUN mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar ./libs/ + mvn clean install; \ + cd ..; \ + mv ~/.m2/repository/com/sree/kafka/kafka-connect-jmx/0.0.1/kafka-connect-jmx-0.0.1-jar-with-dependencies.jar ./libs/; \ + rm -rf ./kafka-connectors; \ + rm -rf ./maven ~/.m2; \ + \ + apt-get purge -y --auto-remove $buildDeps; \ + rm -rf /var/lib/apt/lists/*; \ + rm /var/log/dpkg.log /var/log/apt/*.log COPY *.properties ./config/ From 415bb65f7b5a1ae2b14ea85088f9a30ba7011755 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:04:47 +0200 Subject: [PATCH 18/25] Clarifies that we use 3rd party source here --- connect-jmx/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connect-jmx/Dockerfile b/connect-jmx/Dockerfile index 6e84a78..fc134a3 100644 --- a/connect-jmx/Dockerfile +++ b/connect-jmx/Dockerfile @@ -1,5 +1,7 @@ FROM solsson/kafka:0.11.0.0 +ENV srijiths-kafka-connectors-version=dc0a7122650e697d3ae97c970a4785bbed949479 + RUN set -ex; \ buildDeps='curl ca-certificates'; \ apt-get update && apt-get install -y $buildDeps --no-install-recommends; \ @@ -11,7 +13,7 @@ RUN set -ex; \ \ mkdir ./kafka-connectors; \ cd ./kafka-connectors; \ - curl -SLs https://github.com/srijiths/kafka-connectors/archive/dc0a7122650e697d3ae97c970a4785bbed949479.tar.gz \ + curl -SLs https://github.com/srijiths/kafka-connectors/archive/$srijiths-kafka-connectors-version.tar.gz \ | tar -xzf - --strip-components=1 -C ./; \ mvn clean install; \ cd ..; \ From e4de7e6f931244d15a11da74c1b6192a0c87e431 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:23:05 +0200 Subject: [PATCH 19/25] Honors the nature of Kafka distributions --- .../docker-compose.files-aggregation.yml | 3 +++ build-contracts/docker-compose.monitoring.yml | 3 +++ build-contracts/docker-compose.yml | 3 +++ kafka/Dockerfile | 5 ++--- kafka/docker-help.sh | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 kafka/docker-help.sh diff --git a/build-contracts/docker-compose.files-aggregation.yml b/build-contracts/docker-compose.files-aggregation.yml index 0b29e07..685de9c 100644 --- a/build-contracts/docker-compose.files-aggregation.yml +++ b/build-contracts/docker-compose.files-aggregation.yml @@ -11,9 +11,12 @@ services: build: ../kafka links: - zookeeper + entrypoint: ./bin/bin/kafka-server-start.sh command: - config/server.properties - --override + - zookeeper.connect=zookeeper:2181 + - --override - broker.id=0 - --override - advertised.listener=PLAINTEXT://kafka-0:9092 diff --git a/build-contracts/docker-compose.monitoring.yml b/build-contracts/docker-compose.monitoring.yml index 0668f58..5656880 100644 --- a/build-contracts/docker-compose.monitoring.yml +++ b/build-contracts/docker-compose.monitoring.yml @@ -15,9 +15,12 @@ services: - JMX_PORT=5555 expose: - '5555' + entrypoint: ./bin/bin/kafka-server-start.sh command: - config/server.properties - --override + - zookeeper.connect=zookeeper:2181 + - --override - broker.id=0 - --override - advertised.listener=PLAINTEXT://kafka-0:9092 diff --git a/build-contracts/docker-compose.yml b/build-contracts/docker-compose.yml index 5e0629a..e1ec794 100644 --- a/build-contracts/docker-compose.yml +++ b/build-contracts/docker-compose.yml @@ -14,9 +14,12 @@ services: com.yolean.build-target: "" links: - zookeeper + entrypoint: ./bin/kafka-server-start.sh command: - config/server.properties - --override + - zookeeper.connect=zookeeper:2181 + - --override - broker.id=0 # unlike Kubernetes StatefulSet, compose gives containers a random hostname (leading to redirects to a hex name) - --override diff --git a/kafka/Dockerfile b/kafka/Dockerfile index ba412e4..6cc4b6d 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -19,7 +19,6 @@ RUN set -ex; \ rm /var/log/dpkg.log /var/log/apt/*.log WORKDIR /opt/kafka -ENTRYPOINT ["bin/kafka-server-start.sh"] -RUN sed -i 's/zookeeper.connect=localhost:2181/zookeeper.connect=zookeeper:2181/' config/server.properties -CMD ["config/server.properties"] +COPY docker-help.sh /usr/local/bin/docker-help +ENTRYPOINT ["docker-help"] diff --git a/kafka/docker-help.sh b/kafka/docker-help.sh new file mode 100755 index 0000000..8c82eb7 --- /dev/null +++ b/kafka/docker-help.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "Hi," +echo "" +echo "This image is basically just the official Kafka distribution," +echo "containing both servers and utils, each with its own help output." +echo "" +echo "Select as entrypoint one of these scripts:" +find ./bin/ -name *.sh +echo "" +echo "You might find one of the sample config files useful:" +find ./config/ -name *.properties +echo "" +echo "Add more using volumes, or downstream images." +echo "Enjoy Kafka!" +echo "" From 385eff8821a735518a55dbad5d7e4caa978c1066 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:32:03 +0200 Subject: [PATCH 20/25] Tries to replace the old image behavior with instructions --- README.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7d65311..e70bdde 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,37 @@ -# dockerfiles +# Kafka docker builds + +Automated [Kafka](http://kafka.apache.org/) builds for https://hub.docker.com/r/solsson/kafka/ +and related `kafka-` images under https://hub.docker.com/u/solsson/. -Nowadays we're using separate repositories for dockerization projects. +--- + +This repo used to contain misc dockerfiles, but they've moved to separate repositories for dockerization projects. +We've kept the repository name to avoid breaking the automated build of solsson/kafka in Docker Hub. For legacy Dockerfiles from this repo (if you navigated to here from a Docker Hub [solsson](https://hub.docker.com/u/solsson/) image), see https://github.com/solsson/dockerfiles/tree/misc-dockerfiles. -# Kafka docker builds +--- -This repository maintains automated [Kafka](http://kafka.apache.org/) builds for https://hub.docker.com/r/solsson/kafka/ -and related `kafka-` images under https://hub.docker.com/u/solsson/. +Our kafka images are tested in production with https://github.com/Yolean/kubernetes-kafka/. -These images are tested in production with https://github.com/Yolean/kubernetes-kafka/. +You most likely need to mount your own config files, or for `./bin/kafka-server-start.sh` use overrides like: +``` + --override zookeeper.connect=zookeeper:2181 + --override log.dirs=/var/lib/kafka/data/topics + --override log.retention.hours=-1 + --override broker.id=0 + --override advertised.listener=PLAINTEXT://kafka-0:9092 +``` ## One image to rule them all Official [Kafka distributions](http://kafka.apache.org/downloads) contain startup scripts and config for various services and clients. Thus `./kafka` produces a multi-purpose image for direct use and specialized docker builds. +We could build specialized images like `kafka-server` but we have two reasons not to: + * Won't be as transparent in Docker Hub because you can't use Automated Build without scripting. + * In reality you'll need to control your own config anyway. + ### Example of downstream image: Kafka Connect See ./connect-jmx From e21ae32f0bbcaff8ac499376ce14e7eaaf60f490 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 22 Jul 2017 13:40:04 +0200 Subject: [PATCH 21/25] Slightly shorter --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e70bdde..50f8bf5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kafka docker builds -Automated [Kafka](http://kafka.apache.org/) builds for https://hub.docker.com/r/solsson/kafka/ +Automated [Kafka](http://kafka.apache.org/) builds for [solsson/kafka](https://hub.docker.com/r/solsson/kafka/) and related `kafka-` images under https://hub.docker.com/u/solsson/. --- @@ -44,11 +44,7 @@ TODO Rudimentary compliance with kubernetes-kafka is tested using a [build-contract](https://github.com/Yolean/build-contract/). -Build and test using: `docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/:/source solsson/build-contract test` - -To keep kafka running for local use, uncomment `ports` 9092 and run: `docker-compose -f build-contracts/docker-compose.yml up --force-recreate`. - -While timing issues remain, start services individually... +Build and test using: `docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/:/source solsson/build-contract test`. However... while timing issues remain you need some manual intervention: ```bash compose='docker-compose -f build-contracts/docker-compose.yml' From 9978188a69cf4b04bfe2f4f3659fce1d92027ddb Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sun, 23 Jul 2017 06:23:29 +0200 Subject: [PATCH 22/25] Adds the nc command as it's useful for liveness probes --- kafka/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 6cc4b6d..71f5a5e 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -3,7 +3,7 @@ FROM debian:stable-20170620 ENV KAFKA_VERSION=0.11.0.0 ZULU_OPENJDK_VERSION="8=8.21.0.1" KAFKA_BIN_SCALA_VERSION=2.11 RUN set -ex; \ - runDeps=''; \ + runDeps='netcat-openbsd'; \ buildDeps='curl ca-certificates gnupg dirmngr'; \ apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends; \ \ From 9fecc16e2c2a2e646d2a4a5f06734f3f504933aa Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sun, 23 Jul 2017 14:05:53 +0200 Subject: [PATCH 23/25] Current https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration --- config-kafka/BUILD | 27 +++++++++++++++++ config-kafka/Dockerfile | 17 +++++++++++ config-kafka/README.md | 50 ++++++++++++++++++++++++++++++++ config-kafka/main.go | 64 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 config-kafka/BUILD create mode 100644 config-kafka/Dockerfile create mode 100644 config-kafka/README.md create mode 100644 config-kafka/main.go diff --git a/config-kafka/BUILD b/config-kafka/BUILD new file mode 100644 index 0000000..c6a83a8 --- /dev/null +++ b/config-kafka/BUILD @@ -0,0 +1,27 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "in-cluster-client-configuration", + library = ":go_default_library", + tags = ["automanaged"], +) + +go_library( + name = "go_default_library", + srcs = ["main.go"], + tags = ["automanaged"], + deps = [ + "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/client-go/kubernetes:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + ], +) diff --git a/config-kafka/Dockerfile b/config-kafka/Dockerfile new file mode 100644 index 0000000..d0cc281 --- /dev/null +++ b/config-kafka/Dockerfile @@ -0,0 +1,17 @@ +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian +COPY ./app /app +ENTRYPOINT /app diff --git a/config-kafka/README.md b/config-kafka/README.md new file mode 100644 index 0000000..811b750 --- /dev/null +++ b/config-kafka/README.md @@ -0,0 +1,50 @@ +# Authenticating inside the cluster + +This example shows you how to configure a client with client-go to authenticate +to the Kubernetes API from an application running inside the Kubernetes cluster. + +client-go uses the [Service Account token][sa] mounted inside the Pod at the +`/var/run/secrets/kubernetes.io/serviceaccount` path when the +`rest.InClusterConfig()` is used. + +## Running this example + +First compile the application for Linux: + + cd in-cluster-client-configuration + GOOS=linux go build -o ./app . + +Then package it to a docker image using the provided Dockerfile to run it on +Kubernetes. + +If you are running a [Minikube][mk] cluster, you can build this image directly +on the Docker engine of the Minikube node without pushing it to a registry. To +build the image on Minikube: + + eval $(minikube docker-env) + docker build -t in-cluster . + +If you are not using Minikube, you should build this image and push it to a registry +that your Kubernetes cluster can pull from. + +Then, run the image in a Pod with a single instance Deployment: + + $ kubectl run --rm -i demo --image=in-cluster --image-pull-policy=Never + + There are 4 pods in the cluster + There are 4 pods in the cluster + There are 4 pods in the cluster + ... + +The example now runs on Kubernetes API and successfully queries the number of +pods in the cluster every 10 seconds. + +### Clean up + +To stop this example and clean up the pod, press Ctrl+C on +the `kubectl run` command and then run: + + kubectl delete deployment demo + +[sa]: https://kubernetes.io/docs/admin/authentication/#service-account-tokens +[mk]: https://kubernetes.io/docs/getting-started-guides/minikube/ diff --git a/config-kafka/main.go b/config-kafka/main.go new file mode 100644 index 0000000..f715068 --- /dev/null +++ b/config-kafka/main.go @@ -0,0 +1,64 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Note: the example only works with the code within the same release/branch. +package main + +import ( + "fmt" + "time" + + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" +) + +func main() { + // creates the in-cluster config + config, err := rest.InClusterConfig() + if err != nil { + panic(err.Error()) + } + // creates the clientset + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + panic(err.Error()) + } + for { + pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{}) + if err != nil { + panic(err.Error()) + } + fmt.Printf("There are %d pods in the cluster\n", len(pods.Items)) + + // Examples for error handling: + // - Use helper functions like e.g. errors.IsNotFound() + // - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message + _, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{}) + if errors.IsNotFound(err) { + fmt.Printf("Pod not found\n") + } else if statusError, isStatus := err.(*errors.StatusError); isStatus { + fmt.Printf("Error getting pod %v\n", statusError.ErrStatus.Message) + } else if err != nil { + panic(err.Error()) + } else { + fmt.Printf("Found pod\n") + } + + time.Sleep(10 * time.Second) + } +} From a1671872311f796a39e1e146603c2b2f969e347b Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sun, 23 Jul 2017 14:07:00 +0200 Subject: [PATCH 24/25] I guess image name will be kafka-init-broker --- {config-kafka => init-broker}/BUILD | 0 {config-kafka => init-broker}/Dockerfile | 0 {config-kafka => init-broker}/README.md | 0 {config-kafka => init-broker}/main.go | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {config-kafka => init-broker}/BUILD (100%) rename {config-kafka => init-broker}/Dockerfile (100%) rename {config-kafka => init-broker}/README.md (100%) rename {config-kafka => init-broker}/main.go (100%) diff --git a/config-kafka/BUILD b/init-broker/BUILD similarity index 100% rename from config-kafka/BUILD rename to init-broker/BUILD diff --git a/config-kafka/Dockerfile b/init-broker/Dockerfile similarity index 100% rename from config-kafka/Dockerfile rename to init-broker/Dockerfile diff --git a/config-kafka/README.md b/init-broker/README.md similarity index 100% rename from config-kafka/README.md rename to init-broker/README.md diff --git a/config-kafka/main.go b/init-broker/main.go similarity index 100% rename from config-kafka/main.go rename to init-broker/main.go From 73d3c7c20176d1bba8f2bdd0a1f150eafb964f0c Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sun, 23 Jul 2017 14:12:41 +0200 Subject: [PATCH 25/25] This dockerfile had it all backwards, building outside the docker build --- init-broker/Dockerfile | 17 -------------- init-broker/README.md | 50 ------------------------------------------ 2 files changed, 67 deletions(-) delete mode 100644 init-broker/Dockerfile delete mode 100644 init-broker/README.md diff --git a/init-broker/Dockerfile b/init-broker/Dockerfile deleted file mode 100644 index d0cc281..0000000 --- a/init-broker/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2017 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM debian -COPY ./app /app -ENTRYPOINT /app diff --git a/init-broker/README.md b/init-broker/README.md deleted file mode 100644 index 811b750..0000000 --- a/init-broker/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Authenticating inside the cluster - -This example shows you how to configure a client with client-go to authenticate -to the Kubernetes API from an application running inside the Kubernetes cluster. - -client-go uses the [Service Account token][sa] mounted inside the Pod at the -`/var/run/secrets/kubernetes.io/serviceaccount` path when the -`rest.InClusterConfig()` is used. - -## Running this example - -First compile the application for Linux: - - cd in-cluster-client-configuration - GOOS=linux go build -o ./app . - -Then package it to a docker image using the provided Dockerfile to run it on -Kubernetes. - -If you are running a [Minikube][mk] cluster, you can build this image directly -on the Docker engine of the Minikube node without pushing it to a registry. To -build the image on Minikube: - - eval $(minikube docker-env) - docker build -t in-cluster . - -If you are not using Minikube, you should build this image and push it to a registry -that your Kubernetes cluster can pull from. - -Then, run the image in a Pod with a single instance Deployment: - - $ kubectl run --rm -i demo --image=in-cluster --image-pull-policy=Never - - There are 4 pods in the cluster - There are 4 pods in the cluster - There are 4 pods in the cluster - ... - -The example now runs on Kubernetes API and successfully queries the number of -pods in the cluster every 10 seconds. - -### Clean up - -To stop this example and clean up the pod, press Ctrl+C on -the `kubectl run` command and then run: - - kubectl delete deployment demo - -[sa]: https://kubernetes.io/docs/admin/authentication/#service-account-tokens -[mk]: https://kubernetes.io/docs/getting-started-guides/minikube/