kubernetesapache-kafkastrimzi

Apache Kafka local development


I am wondering - how do you develop applications that produce/consume messages with Apache Kafka? I have been looking into the Strimzi operator for Kubernetes and actually deployed it on the cloud provider. I have tested it with the provided commands - running two pods (1 producer, 1 consumer) works fine and the messages get delivered.

However, I want to consume Apache Kafka with the applications I am developing. I have been trying to port-forward into the Kafka service, however, was not successful - requests doesn't seem to pass. I have been trying to setup a minikube cluster with the same operator - I am not able to connect to the cluster through any applications, just the testing setup with consumer/producer pods.

So, eventually, my question is - what is your setup in developing applications with Apache Kafka on Kubernetes? How do you test your code, write the code, check if business logic works correctly with Kafka?


Solution

  • You cannot use port forwarding with Kafka easily (this blog post series explains why: https://strimzi.io/blog/2019/04/17/accessing-kafka-part-1/). I think you have several options to use Strimzi for lcoal development:

    You should also consider what does running Kafka on Kubernetes for local development really give you. If you just want to send / receive messages from the app you develop, the easiest way to run Kafka might be actually to just download the Kafka ZIP and run it locally. But this might not be that useful if you also need to run some other Kubernetes applications you integrate with through Kafka. So it depends how suitable it is for you.