We are trying to consume from a Kafka Cluster using the Java Client. The Cluster is a behind a Jump host and hence the only way to access is through a SSH Tunnel. But we are not able read because once the consumer fetches metadata it uses the original hosts to connect to brokers. Can this behaviour be overridden? Can we ask Kafka Client to not use the metadata?
Not as far as I know.
The trick I used when I needed to do something similar was:
/etc/hosts
file so that the advertised hostname of broker n is resolved to the ip of the virtual interface n.Es.
Kafka brokers:
Virtual interfaces:
Tunnels:
ssh -L 192.168.1.1:9092:broker1.mykafkacluster:9092 jumphost
ssh -L 192.168.1.2:9092:broker1.mykafkacluster:9092 jumphost
/etc/hosts
:
If you configure your system like this you should be able reach all the brokers in your Kafka cluster.
Note: if you configured your Kafka brokers to advertise an ip address instead of a hostname the procedure can still work but you need to configure the virtual interfaces with the same ip address that the broker advertises.