'partitions have leader brokers without a matching listener' on kubernetes after kafka restart

9/12/2019

i have several spring boot apps communicating via kafka running inside a kubernetes cluster. Using the bitnami/kafka helm chart for deploying kafka.

Everything works fine until the kafka broker (i only have a single instance) is restarting. After that i get for producer 'X partitions have leader brokers without a matching listener' ... to fix that i must setup the whole cluster again to make it working means kill all apps, remove kafka and the volumes and put everything back.

Found some stuff regarding "advertised.listeners" but nothing worked yet. For example that one: https://medium.com/@tsuyoshiushio/configuring-kafka-on-kubernetes-makes-available-from-an-external-client-with-helm-96e9308ee9f4

The question for me is, why is it working in the beginning and only after crashing it stops ....

Thx Oliver

-- IEE1394
apache-kafka
azure-aks
kubernetes
spring-boot

1 Answer

9/12/2019

The question for me is, why is it working in the beginning and only after crashing it stops ....

When your Kafka broker restarts, it gets a new IP address. You must make sure that the new IP address is reflected in your broker properties i.e. it must be included in the advertised listeners.

You can have a Kubernetes service on top of your Kafka deployment and include that in your advertised listeners as a workaround.

The other way is to have stateful set so that your broker pod always gets the same IP address. Bring down your broker add the advertised.listeners and set it to the broker pod IP and start it.

One rule of thumb, is that your kafkacat topic metadata must not return an unreachable address.

-- JavaTechnical
Source: StackOverflow