<p>I use istio-ingress gateway and virtualservice to expose different microservices. So far all of them have been http services, so it was straight-forward to follow istio's documentation.</p>
<p>But with kafka I am facing some issues. I am using <a href="https://github.com/bitnami/charts/tree/master/bitnami/kafka" rel="nofollow noreferrer">bitnami/kafka</a> helm chart for kafka installation. Here's the values.yaml used for it:</p>
<pre><code>global:
  storageClass: &quot;kafka-sc&quot;

replicaCount: 3
deleteTopicEnable: true

resources:
  requests:
    memory: 1024Mi
    cpu: 500m
  limits:
    memory: 2048Mi
    cpu: 1000m

zookeeper:
  replicaCount: 3
  resources:
    requests:
      memory: 1024Mi
      cpu: 500m
    limits:
      memory: 2048Mi
      cpu: 1000m
</code></pre>
<p>This deployment exposes kafka on this endpoint:  <code>my-kafka.kafka.svc.cluster.local:9092</code></p>
<p>I want this endpoint to be accessible via internet using ingress controller. Therefore, I applied following kubernetes manifests --&gt;</p>
<p>A. kafka-ingress-gateway.yaml</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: kafka-ingress-gateway
  namespace: kafka
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 9092
      name: tcp
      protocol: TCP
    hosts:
    - &quot;kafka.&lt;public_domain&gt;&quot;
</code></pre>
<p>B. kafka-ingress-virtualservice.yaml</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: kafka-ingress-virtualservice
  namespace: kafka
spec:
  hosts:
  - &quot;kafka.&lt;public_domain&gt;&quot;
  gateways:
  - kafka/kafka-ingress-gateway
  tcp:
  - match:
    - port: 9092
    route:
    - destination:
        host: my-kafka.kafka.svc.cluster.local
        port:
          number: 9092
</code></pre>
<p>To verify whether this works, I am using following approach:</p>
<ol>
<li>Create a kafka-client pod and login to it in two different terminals</li>
<li>In first terminal, I produce in a topic called <code>test</code> using this command: <code>kafka-console-producer.sh --broker-list my-kafka-0.my-kafka-headless.kafka.svc.cluster.local:9092 --topic test</code></li>
<li>In second terminal, I consume in <code>test</code> topic using this command.</li>
</ol>
<p>In here, this works: <code>kafka-console-consumer.sh --bootstrap-server my-kafka.kafka.svc.cluster.local:9092 --topic test --from-beginning</code></p>
<p>This does not work: <code>kafka-console-consumer.sh --bootstrap-server kafka.&lt;public_domain&gt;:9092 --topic test --from-beginning</code></p>
<p>I am getting this error: <code>WARN [Consumer clientId=consumer-console-consumer-89304-1, groupId=console-consumer-89304] Bootstrap broker kafka.&lt;public_domain&gt;:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)</code></p>
<p>I am new to kafka, so not sure what else is required to expose the consumer endpoint. From similar questions on stackoverflow, I noticed we are supposed to <a href="https://github.com/bitnami/charts/blob/master/bitnami/kafka/values.yaml#L403" rel="nofollow noreferrer">define &quot;advertisedListeners&quot; in kafka config</a>, but not sure what value to put there.</p>
<p>Please let me know if I am missing any details here.</p>

Grimlock
<p>edit your istio-ingressgateway and add 9092 for tcp port</p>
<pre><code>kubectl edit svc -nistio-system istio-ingressgateway
</code></pre>
<p>add</p>
<pre><code>- name: kafka-broker
  port: 9092
  protocol: TCP
  targetPort: 9092
</code></pre>
