And i attempted to create kafka in dockerized environment, but not the part of kubernetes cluster
i have a trouble in accessing kafka bootstrap server inside of the kubernetes pod.
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- "29092:29092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: EXTERNAL_SAME_HOST://:29092,INTERNAL://:9092
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,EXTERNAL_SAME_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL_SAME_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
volumes:
- /var/run/docker.sock:/var/run/docker.sock
above code is docker-compose file of the kafka that i collected in google.
well, it works well in my Mac Environment by using consume tools, Python and Java
But the problem occurs in kubernetes cluster and dockerized environment(not the same with kafka container).
when i run kafkacat test on kubernetes pod with linux, like
kafkacat -P -b host.docker.internal:29092 -t test
but
%3|1681306449.415|FAIL|rdkafka#producer-1| [thrd:localhost:29092/1001]: localhost:29092/1001: Connect to ipv4#127.0.0.1:29092 failed: Connection refused (after 1ms in state CONNECT)
%3|1681306449.511|FAIL|rdkafka#producer-1| [thrd:localhost:29092/1001]: localhost:29092/1001: Connect to ipv4#127.0.0.1:29092 failed: Connection refused (after 0ms in state CONNECT, 1 identical error(s) suppressed)
occurs. or when i tried to connect with docker, Using port 9092
%3|1681307275.048|FAIL|rdkafka#producer-1| [thrd:172.17.0.1:9092/bootstrap]: 172.17.0.1:9092/bootstrap: Connect to ipv4#172.17.0.1:9092 failed: Connection refused (after 0ms in state CONNECT)
Or 29092
org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node 1001 (localhost/127.0.0.1:29092) could not be established. Broker may not be available.
I tried many things that i can like setting advertised.listeners to localhost, external ip