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.
kubectl exec -it deploy/broker -c broker -- /bin/bash
Once inside of the pod, here are some useful commands.
# 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>
# 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.