diff --git a/scripts/services.yml b/scripts/services.yml new file mode 100644 index 0000000..6c344aa --- /dev/null +++ b/scripts/services.yml @@ -0,0 +1,26 @@ +version: "3" + +services: + kafka: + image: bitnami/kafka:3.5.0 + container_name: bitnami_kafka + ports: + - "9092:9092" + environment: + KAFKA_ENABLE_KRAFT: "true" + KAFKA_CFG_NODE_ID: "1" + KAFKA_CFG_PROCESS_ROLES: "broker,controller" + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER" + KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093" + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT" + KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://127.0.0.1:9092" + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true" + KAFKA_BROKER_ID: "1" + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "1@kafka:9093" + ALLOW_PLAINTEXT_LISTENER: "true" + healthcheck: + test: ["CMD-SHELL", "kafka-topics.sh --bootstrap-server kafka:9092 --list"] + start_period: 10s + interval: 5s + timeout: 10s + retries: 5 diff --git a/scripts/start_kafka_broker_locally.sh b/scripts/start_kafka_broker_locally.sh new file mode 100755 index 0000000..80ccb58 --- /dev/null +++ b/scripts/start_kafka_broker_locally.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker-compose -f ./scripts/services.yml up -d --no-recreate diff --git a/scripts/stop_kafka_broker_locally.sh b/scripts/stop_kafka_broker_locally.sh new file mode 100755 index 0000000..25ee199 --- /dev/null +++ b/scripts/stop_kafka_broker_locally.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker-compose -f ./scripts/services.yml down diff --git a/scripts/subscribe_to_kafka_broker_locally.sh b/scripts/subscribe_to_kafka_broker_locally.sh new file mode 100755 index 0000000..3efcb84 --- /dev/null +++ b/scripts/subscribe_to_kafka_broker_locally.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +topic="$1" + +docker exec -it bitnami_kafka /opt/bitnami/kafka/bin/kafka-console-consumer.sh --consumer.config /opt/bitnami/kafka/config/consumer.properties --bootstrap-server kafka:9092 --topic "$topic"