I have setup a kafka cluster using strimzi on minikube. And the minikube running on an ec2 machine. I have created a nodeport type service to expose the kafka cluster. But I can not access the kafka cluster outside of the ec2.
I used kubectl port-forward to access the kafka cluster on ec2 ip-address. But could not connect to the broker.
You cannot easily use
kubectl port-forward
because of how the Kafka protocol works and how clients need to connect directly to each of the brokers (depending on what partition replicas it hosts etc.). You would need to:Kafka
custom resource to your localhost and the port you exposed it on for each brokerUsing the
type: nodeport
listener might be easier. But a lot depends on how your Kubernetes cluster is configured and how you run Kubernetes. To make it work, you would need to make sure that:kubectl get node -o yaml
command. The advertised host in the broker will be based on this address.Strimzi lets you customize all of these if needed. But without knowing the exact environment, it is not easy to provide the exact YAML. So you would need to try it. This blog post series might help you understand how Kafka does this and how to configure it in Strimzi: https://strimzi.io/blog/2019/04/17/accessing-kafka-part-1/