1

I am new to Containerisation. I am trying to set up my local env where my java application want to connect to Kafka. Can't use Docker so decided to use Podman. I have three containers running on same network each for Kafka, Zookeeper and kafka UI. I am using macos.

Here are the Podman commands i am using :-

Creating network:

podman network create kafka-network --driver bridge

Spinning up Zookeper: podman run --name zookeeper-server -p 2181:2181 --network kafka-network -e ALLOW_ANONYMOUS_LOGIN=yes docker.io/bitnami/zookeeper:3.8

spinning up Kafka: podman run --name kafka-server --network kafka-network -e ALLOW_PLAINTEXT_LISTENER=yes -e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181 -e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR:1 -p 9092:9092 docker.io/bitnami/kafka:3.4

Spinning up Kafka-ui: podman run -it --name kafka-ui -p 9090:8080 --network kafka-network -e KAFKA_CLUSTERS_0_NAME=local -e KAFKA_CLUSTERS_0_ZOOKEEPER=zookeeper-server:2181 -e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka-server:9092 -e DYNAMIC_CONFIG_ENABLED=true docker.io/provectuslabs/kafka-ui:latest

Url used by java Application: PLAINTEXT://localhost:9092

Java Application is able to connect as partitions are getting assigned but kafka ui log says "Connection to node 1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available."

If I change localhost to kafka-server in podman command where I am spinning up kafka then Kafka UI is working but consumers are not subscribing to partitions in java App.

Not sure why I am seeing this strange behaviour. Extra explanation is welcome as I am trying to understand the purpose of environment variables here. Thanks

0 Answers0