Kafka经纪人pod无法连接到Zookeeper

gfttwv5a  于 2023-03-01  发布在  Apache
关注(0)|答案(1)|浏览(156)

我正在使用WSL中的cli在本地运行一个Zookeeper:

zookeeper-server-start.sh config/zookeeper.properties

我已经使用Kubernetes StatefullSet资源类型创建了一个Kafka代理pod,使用的是.yaml文件,如下所示:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: kafka
spec:
  serviceName: kafka
  replicas: 1
  selector:
    matchLabels:
      app: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      containers:
      - name: kafka
        image: debezium/kafka
        ports:
        - containerPort: 9092
          name: kafka
        env:
        - name: KAFKA_BROKER_ID
          value: '0'
        - name: ZOOKEEPER_CONNECT
          value: 'host.docker.internal:2181'

pod卡在crashloopbackoff阶段,日志如下所示:

2023-02-21 07:14:29,741 - INFO  [main-SendThread(host.docker.internal:2181):ClientCnxn$SendThread@1181] - Opening socket  connection to server host.docker.internal/192.168.65.2:2181.
2023-02-21 07:14:29,747 - WARN  [main-SendThread(host.docker.internal:2181):ClientCnxn$SendThread@1300] - Session 0x0 fo r sever host.docker.internal/192.168.65.2:2181, Closing socket connection. Attempting reconnect except it is a SessionEx piredException.
java.net.ConnectException: Connection refused
        at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
        at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1290)
2023-02-21 07:14:29,949 - INFO  [main:Logging@66] - [ZooKeeperClient Kafka server] Closing.

我已经尝试更改.yaml配置文件,但没有成功。

qvtsj1bj

qvtsj1bj1#

只有Docker Desktop为其管理的container配置host.docker.internal网络地址。Kubernetes pod可能无法访问该地址

相关问题