Skip to content

Commit

Permalink
Run create-topics.sh from tools, reuse get_kafka_cluster_id_from_cont…
Browse files Browse the repository at this point in the history
…ainer.
  • Loading branch information
javabrett committed Dec 20, 2020
1 parent 09b4b11 commit 6d4bb44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
21 changes: 10 additions & 11 deletions scripts/helper/create-topics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/functions.sh

KAFKA_CLUSTER_ID=$(curl -s --insecure --location --request GET 'https://localhost:8091/kafka/v3/clusters' --header 'Authorization: Basic c3VwZXJVc2VyOnN1cGVyVXNlcg==' | jq -r '.data[0].cluster_id')

echo "cluster_id: ${KAFKA_CLUSTER_ID}"
KAFKA_CLUSTER_ID=$(get_kafka_cluster_id_from_container)
echo "KAFKA_CLUSTER_ID: ${KAFKA_CLUSTER_ID}"

auth="superUser:superUser"

create_topic localhost:8091 ${KAFKA_CLUSTER_ID} users true ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} wikipedia.parsed true ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} wikipedia.parsed.count-by-domain false ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} wikipedia.failed false ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} WIKIPEDIABOT false ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} WIKIPEDIANOBOT false ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} EN_WIKIPEDIA_GT_1 false ${auth}
create_topic localhost:8091 ${KAFKA_CLUSTER_ID} EN_WIKIPEDIA_GT_1_COUNTS false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} users true ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} wikipedia.parsed true ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} wikipedia.parsed.count-by-domain false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} wikipedia.failed false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} WIKIPEDIABOT false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} WIKIPEDIANOBOT false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} EN_WIKIPEDIA_GT_1 false ${auth}
create_topic kafka1:8091 ${KAFKA_CLUSTER_ID} EN_WIKIPEDIA_GT_1_COUNTS false ${auth}
5 changes: 4 additions & 1 deletion scripts/helper/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ END
}

create_topic() {

local DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

broker_host_port=$1
cluster_id=$2
topic_name=$3
Expand All @@ -267,7 +270,7 @@ create_topic() {

RESULT=$(curl -sS -X POST \
-u ${auth} \
--cacert ${DIR}/../security/snakeoil-ca-1.crt \
--cacert /etc/kafka/secrets/snakeoil-ca-1.crt \
--header 'Content-Type: application/json' \
--data-binary @<(jq -n --arg topic_name "${topic_name}" --arg confluent_value_schema_validation "${confluent_value_schema_validation}" -f ${DIR}/topic.jq) \
"https://${broker_host_port}/kafka/v3/clusters/${cluster_id}/topics") && RC=$? || RC=$?
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ docker-compose up -d schemaregistry connect control-center

echo
echo -e "Create topics in Kafka cluster:"
${DIR}/helper/create-topics.sh || exit 1
docker-compose exec tools bash -c "/tmp/helper/create-topics.sh" || exit 1

# Verify Confluent Control Center has started
MAX_WAIT=300
Expand Down

0 comments on commit 6d4bb44

Please sign in to comment.