I’m playing around with a Kafka pod (the incubator/kafka
chart) I have running in a kubernetes cluster, trying to send and receive some test data. I have a consumer running that I kicked off using:
kubectl exec kafka-0 \
-n kafka-namespace \
-- kafka-console-consumer \
--bootstrap-server localhost:9092 \
--topic test
I was able to successfully send data to the consumer using:
kubectl exec -i kafka-0 \
-n kafka-namespace \
-- kafka-console-producer \
--broker-list localhost:9092 \
--topic test < testdata.jsonl
I’d like to send data using port-forwarding, as that will make it easier for me to do some partitioning stuff. However, it keeps failing for me. I set up port forwarding by running:
kubectl port-forward \
-n kafka-namespace \
svc/kafka 9092:9092
I’m trying to send data to Kafka by running from my local machine:
kafka-console-producer \
--broker-list localhost:9092 \
--topic test < testdata.jsonl
In my port-forwarding terminal, I see Handling connection for 9092
appear. However, this fails with error:
[2022-07-27 15:48:44,227] ERROR Error when sending message to topic test with key: null, value: 139 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 12 record(s) for test-0:120000 ms has passed since batch creation
If I’m doing port-forwarding, then I should just be able to use the kafka-console-producer
command as if it’s running on localhost, right?