Kafta Commands

If you have not used Kafka before, there are some CLI commands that may be useful to know. To execute any of these, you will first need to get a shell inside the Kafka pod.

Copy
Copied!
            

kubectl exec -it deploy/broker -c broker -- /bin/bash

Once inside of the pod, here are some useful commands.

Copy
Copied!
            

# list all available topics kafka-topics.sh --list --zookeeper zookeeper:2181 # create a new topic kafka-topics.sh --create \ --bootstrap-server broker:9092 \ --replication-factor 1 \ --partitions 1 \ --topic <YOUR_TOPIC_NAME> # data a topic kafka-topics.sh --delete \ --zookeeper zookeeper:2181 \ --topic <YOUR_TOPIC_NAME>

Copy
Copied!
            

# produce data into a topic from a file in the shell kafka-console-producer.sh --broker-list broker:9092 \ --topic <YOUR_TOPIC_NAME> \ <YOOUR_DATA_FILE> # consume data from a topic in the shell kafka-console-consumer.sh --bootstrap-server broker:9092 \ --topic <YOUR_TOPIC_NAME> \ --group some_group_name

These commands are generally meant for development and debugging purposes only and should not be used for production systems.

© Copyright 2022-2023, NVIDIA. Last updated on Jan 10, 2023.