<p>I am trying to configure a Kafka cluster behind Traefik but my producers and client (that are outside kubernetes) don't connect to the bootstrap-servers. They keep saying: </p>

<blockquote>
  <p>"no resolvable boostrap servers in the given url"</p>
</blockquote>

<p>Actually here is the Traefik ingress:</p>

<pre><code>{
    "apiVersion": "extensions/v1beta1",
    "kind": "Ingress",
    "metadata": {
        "name": "nppl-ingress",
        "annotations": {
            "kubernetes.io/ingress.class": "traefik",
            "traefik.frontend.rule.type": "PathPrefixStrip"
        }
    },
    "spec": {
        "rules": [
            {
                "host": "" ,
                "http": {
                    "paths": [
                        {
                            "path": "/zuul-gateway",
                            "backend": {
                                "serviceName": "zuul-gateway",
                                "servicePort": "zuul-port"
                            }
                        },                      
                        {
                            "path": "/kafka",
                            "backend": {
                                "serviceName": "kafka-broker",
                                "servicePort": "kafka-port"
                            }

[..]
    }
</code></pre>

<p>What I give to the kafka consumers/producers is the public IP of Traefik.
Here is the flow: [Kafka producers/consumers] -> Traefik(exposed as Load Balancer) -> [Kafka-Cluster]</p>

<p>Is there any solution? Otherwise I was thinking to add a kafka-rest proxy (<a href="https://docs.confluent.io/current/kafka-rest/docs/index.html" rel="nofollow noreferrer">https://docs.confluent.io/current/kafka-rest/docs/index.html</a>) between Traefik and the kafka brokers but I think isn't the ideal solution.</p>

<p>I did. You can refer to it, in kubernetes ,deployment kafka.yaml</p>

<pre><code>   env:
    - name: KAFKA_BROKER_ID
      value: "1"
    - name: KAFKA_CREATE_TOPICS
      value: "test:1:1"
    - name: KAFKA_ZOOKEEPER_CONNECT
      value: "zookeeper:2181"
    - name: KAFKA_ADVERTISED_LISTENERS
      value: "INSIDE://:9092,OUTSIDE://kafka-com:30322"
    - name: KAFKA_LISTENERS
      value: "INSIDE://:9092,OUTSIDE://:30322"
    - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
      value: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
    - name: KAFKA_INTER_BROKER_LISTENER_NAME
      value: "INSIDE" 
</code></pre>

<p>kafka service,the external service invocation address, or traefik proxy address</p>

<pre><code>---
kind: Service
apiVersion: v1
metadata:
  name: kafka-com
  namespace: dev
  labels:
    k8s-app: kafka
spec:
  selector:
    k8s-app: kafka
  ports:
  - port: 9092
    name: innerport
    targetPort: 9092
    protocol: TCP
  - port: 30322
    name: outport 
    targetPort: 30322
    protocol: TCP
    nodePort: 30322
  type: NodePort
</code></pre>

<p>Ensure that Kafka external port and nodePort port are consistent,Other services call kafka-com:30322, my blog write this <a href="https://bbotte.github.io/virtualization/config_kafka_in_kubernetes" rel="nofollow noreferrer">config_kafka_in_kubernetes</a>, hope to help U !</p>
