title: Exposing Kafka cluster in Kubernetes using LoadBalancer service
body: <p>Suppose if I have 3 node Kafka cluster setup. Then how do I expose it outside a cloud using Load Balancer service? I have read reference material but have a few doubts.</p>
  
  <p>Say for example below is a service for a broker</p>
  
  <pre><code>apiVersion: v1 
    kind: Service metadata: 
    name: kafka-0 
    annotations: dns.alpha.kubernetes.io/external: kafka-0.kafka.my.company.com 
    spec: 
      externalTrafficPolicy: Local 
      type: LoadBalancer 
      ports: 
        - port: 9092 
        name: outside 
        targetPort: 9092 
      selector: app: kafka kafka-pod-id: "0"
  </code></pre>
  
  <ol>
  <li>What is port and targetPort?</li>
  <li>Do I setup LoadBalancer service for each of the brokers?</li>
  <li>Do these multiple brokers get mapped to single public IP address of cloud LB?</li>
  <li>How does a service outside k8s/cloud access individual broker? By using <code>public-ip:port</code>? or by using <code>kafka-&lt;pod-id&gt;.kafka.my.company.com:port</code>?. Also which port is used here? <code>port</code> or <code>targetPort</code>?</li>
  <li>How do I specify this configuration in Kafka broker's <code>Advertised.listeners</code> property? As port can be different for services inside k8s cluster and outside it.</li>
  </ol>
  
  <p>Please help.</p>