Login to the Kafka Broker

kubectl exec -it ckaf-kafka-0 -c ckaf-kafka-broker bash


Commands

From the broker's shell you can execute the following commands:


Topic Commands

List Topics

kubectl exec -it ckaf-kafka-0 -- /bin/kafka-topics.sh --bootstrap-server ckaf-kafka-headless:9092



Create Topic

kubectl exec -it ckaf-kafka-0 -- /bin/kafka-topics.sh --bootstrap-server ckaf-kafka-headless:9092 --create --topic test


Publish Message

kubectl exec -it ckaf-kafka-0 -- /bin/kafka-console-producer.sh --bootstrap-server ckaf-kafka-headless:9092 --topic test
>{"log":"value"}


Publish Message from File

vi input.json

{
  "log":"value",
  "two": "value2"
}


kubectl exec -it ckaf-kafka-0 -- /bin/kafka-console-producer.sh --bootstrap-server ckaf-kafka-headless:9092 --topic test < input.json



Consume Messages

kubectl exec -it ckaf-kafka-0 -- /bin/kafka-console-consumer.sh --bootstrap-server ckaf-kafka-headless:9092 --topic test
{"log":"value"}


  • No labels