第14章 Setting up client access to a Kafka cluster
After you have deployed Streams for Apache Kafka, you can set up client access to your Kafka cluster. To verify the deployment, you can deploy example producer and consumer clients. Otherwise, create listeners that provide client access within or outside the OpenShift cluster.
14.1. Deploying example clients リンクのコピーリンクがクリップボードにコピーされました!
Send and receive messages from a Kafka cluster installed on OpenShift.
This procedure describes how to deploy Kafka clients to the OpenShift cluster, then produce and consume messages to test your installation. The clients are deployed using the Kafka container image.
Prerequisites
- The Kafka cluster is available for the clients.
Procedure
Deploy a Kafka producer.
This example deploys a Kafka producer that connects to the Kafka cluster
my-cluster.A topic named
my-topicis created.Deploying a Kafka producer to OpenShift
oc run kafka-producer -ti --image=registry.redhat.io/amq-streams/kafka-38-rhel9:2.8.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic- Type a message into the console where the producer is running.
- Press Enter to send the message.
Deploy a Kafka consumer.
The consumer should consume messages produced to
my-topicin the Kafka clustermy-cluster.Deploying a Kafka consumer to OpenShift
oc run kafka-consumer -ti --image=registry.redhat.io/amq-streams/kafka-38-rhel9:2.8.0 --rm=true --restart=Never -- bin/kafka-console-consumer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic --from-beginning- Confirm that you see the incoming messages in the consumer console.