<p>I have a Kubernetes cluster with an app that produces message to the service, the connection is able to happen, but no messages are being produced.</p>
<p>Here is my deployment and service config for Kafka:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka
spec:
  selector:
    matchLabels:
      app: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      containers:
        - name: kafka
          image: bitnami/kafka
          resources:
            requests:
              memory: &quot;1Gi&quot;
              cpu: &quot;1000m&quot;
            limits:
              memory: &quot;2Gi&quot;
              cpu: &quot;1500m&quot;
          env:
            - name: KAFKA_CFG_NODE_ID
              value: &quot;0&quot;
            - name: KAFKA_CFG_PROCESS_ROLES
              value: controller,broker
            - name: KAFKA_CFG_LISTENERS
              value: PLAINTEXT://:9092,CONTROLLER://:9093
            - name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
              value: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
            - name: KAFKA_CFG_CONTROLLER_QUORUM_VOTERS
              value: 0@kafka-service:9093
            - name: KAFKA_CFG_CONTROLLER_LISTENER_NAMES
              value: CONTROLLER
            - name: KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE
              value: &quot;true&quot;
            - name: KAFKA_CFG_NUM_PARTITIONS
              value: &quot;1&quot;
          ports:
            - containerPort: 9092
            - containerPort: 9093
---
apiVersion: v1
kind: Service
metadata:
  name: kafka-service
spec:
  selector:
    app: kafka
  ports:
    - protocol: TCP
      name: broker-port
      port: 9092
      targetPort: 9092
    - protocol: TCP
      name: controller-port
      port: 9093
      targetPort: 9093

</code></pre>
<p>In all my code (golang with sarama), I am accessing Kafka via <code>kafka-service:9092</code> to connect and try producing messages, this setup worked with docker-compose and am trying to mimic it with Kubernetes.</p>
<p>My Kafka service itself is up and running, from the logs it says its ready to accept connections on 0.0.0.0:9092. Like I mentioned, the connection is working, but the producer logs this:</p>
<pre><code>failed to produce message: dial tcp: lookup kafka-557b768ffc-78wjm on 10.96.0.10:53: no such host
</code></pre>
<p>kafka-557b768ffc-78wjm is the pod that's running Kafka right now.</p>

Papaya
<p>You're missing <code>KAFKA_CFG_ADVERTISED_LISTENERS</code>, so it'll default to connect with the pod hostname name <strong>after</strong> the initial bootstrapping. <a href="https://www.confluent.io/blog/kafka-listeners-explained/" rel="nofollow noreferrer">https://www.confluent.io/blog/kafka-listeners-explained/</a></p>
<p>Strimzi sets this up for you, and uses a StatefulSet rather than a Deployment to actually persist the Kafka data when the pod restarts</p>
