<p>I have deployed Kafka using Helm and Minikube. I need to build a producer in Scala for that broker IP-address and host are required. I have defined NodePort service to expose Kafka to the outside world. I set up broker as minkube-ip:service-node-port, however, I get connection exception.
What is wrong with the configuration I defined?
With a docker-compose file, the application works fine.</p>

<p>Error stack trace:</p>

<pre><code>Exception in thread "main" org.apache.kafka.common.errors.SerializationException: Error serializing Avro message
Caused by: java.net.ConnectException: Connection refused (Connection refused)
</code></pre>

<p>Kafka configurations look like this:</p>

<pre><code>  val brokers = "192.168.99.100:32400"
  val props = new Properties()
  props.put("bootstrap.servers", brokers)
  props.put("client.id", "AvroKafkaProducer")
  props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
  props.put("value.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer")
  props.put("schema.registry.url", "http://0.0.0.0:8081")
</code></pre>

<p>Kafka NodePort service definition where labels match Kafka pods labeled produced by Helm:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: kafka-service
spec:
  selector:
    app: cp-kafka
    release: my-confluent-oss
  ports:
    - protocol: TCP
      targetPort: 9092
      port: 32400
      nodePort: 32400
  type: NodePort
</code></pre>

<p>This is the list of all the created services:</p>

<pre><code>NAME                                     TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
my-confluent-oss-cp-kafka                ClusterIP      10.96.241.37     &lt;none&gt;        9092/TCP            6h25m
my-confluent-oss-cp-kafka-connect        ClusterIP      10.105.148.181   &lt;none&gt;        8083/TCP            6h25m
my-confluent-oss-cp-kafka-headless       ClusterIP      None             &lt;none&gt;        9092/TCP            6h25m
my-confluent-oss-cp-kafka-rest           ClusterIP      10.99.154.76     &lt;none&gt;        8082/TCP            6h25m
my-confluent-oss-cp-ksql-server          ClusterIP      10.108.41.220    &lt;none&gt;        8088/TCP            6h25m
my-confluent-oss-cp-schema-registry      ClusterIP      10.108.182.212   &lt;none&gt;        8081/TCP            6h25m
my-confluent-oss-cp-zookeeper            ClusterIP      10.97.148.103    &lt;none&gt;        2181/TCP            6h25m
my-confluent-oss-cp-zookeeper-headless   ClusterIP      None             &lt;none&gt;        2888/TCP,3888/TCP   6h25m
</code></pre>

<p>The error is from the deserialiser trying to connect to the Schema Registry</p>

<p><code>props.put("schema.registry.url", "http://0.0.0.0:8081")</code></p>

<p>should read</p>

<p><code>props.put("schema.registry.url", "http://&lt;hostname of Schema Registry resolvable from Connect node&gt;:8081")</code></p>
