<p>I have a landoop kafka image running on a Pod on minikube k8 cluster on my mac. I have 2 different services to expose the port 8081 for schema registry  and 9092 for broker. I have mapped the ports 8081 -> 30081 and 9092 -> 30092 in my NodePort services so that I can access it from outside the cluster. 
But when I try to run a console consumer or my consumer app, Kafka never consumes messages.
To verify broker 9092 port is reachable outside k8 cluster:</p>

<pre><code>nc &lt;exposed-ip&gt; 30092, it says the port is open.
</code></pre>

<p>To verify Schema registry 8081 is reachable:</p>

<pre><code>curl -X GET http://192.168.99.100:30081/subjects
</code></pre>

<p>It returns the schemas that are available.</p>

<p>I had a couple of questions.
1) Can we not access Kafka out of k8 cluster in an above-mentioned way outside of k8 cluster?If so am I doing it wrong in some way?
2) If the port is open, doesn't that mean that broker is available?</p>

<p>Any help is appreciated.Thanks</p>

<p>Accessing a Kafka cluster from outside a container network is rather complicated if you cannot route directly from the outside to the pod.</p>

<p>When you first connect to a Kafka cluster you connect to a single broker and the broker returns the list of all brokers and partitions inside the Kafka cluster. The Kafka client then uses the list to interact with the brokers where the specific topic lays. </p>

<p>The problem is that the broker lists contains by default the internal IP of the Kafka broker. Which would be in your case the container network ip. You can overwrite this value by setting <code>advertised.listeners</code> inside each broker's configuration. </p>

<p>To make a Kafka cluster available from outside Kubernetes you need to configure a nodeport service per each of your brokers and set the <code>advertised.listeners</code> setting of each broker to the external ip of the corresponding nodeport service. But note that this adds additional latency and failure points when you try to use Kafka from inside your Kubernetes cluster. </p>
