[英]Kubernetes - Controller 0's connection to broker was unsuccessful
I'm trying to set up Kafka on Kubernetes, but I keep getting the error mentioned in the title.我正在尝试在 Kubernetes 上设置 Kafka,但我不断收到标题中提到的错误。
The full error is:完整的错误是:
[2022-06-29 12:17:11,732] WARN [RequestSendThread controllerId=0]
Controller 0's connection to broker kafka-service:29092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread) java.net.SocketTimeoutException: Failed to connect within 30000 ms
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:293)
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:246)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96)
Pod Definition:吊舱定义:
kind: Pod
apiVersion: v1
metadata:
name: kafka
labels:
app: kafka
spec:
containers:
- name: kafka
image: confluentinc/cp-kafka:6.2.0
ports:
- containerPort: 9092
env:
- name: KAFKA_ZOOKEEPER_CONNECT
value: zoo1:2181
- name: KAFKA_BROKER_ID
value: "0"
- name: KAFKA_LISTENERS
value: "LISTENER_INTERNAL://0.0.0.0:29092,LISTENER_EXTERNAL://0.0.0.0:9092"
- name: KAFKA_ADVERTISED_LISTENERS
value: "LISTENER_INTERNAL://kafka-service:29092,LISTENER_EXTERNAL://kafka-service:9092"
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
value: "LISTENER_EXTERNAL:PLAINTEXT,LISTENER_INTERNAL:PLAINTEXT"
- name: KAFKA_INTER_BROKER_LISTENER_NAME
value: "LISTENER_INTERNAL"
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_MAX_REQUEST_SIZE
value: "10485760"
- name: KAFKA_MAX_MESSAGE_BYTES
value: "10485760"
- name: KAFKA_MAX_PARTITION_FETCH_BYTES
value: "10485760"
Service - I've also tried using ClusterIP but the error stays:服务 - 我也尝试过使用 ClusterIP,但错误仍然存在:
apiVersion: v1
kind: Service
metadata:
name: kafka-service
spec:
type: NodePort
selector:
app: kafka
ports:
- name: kafka1
port: 9092
targetPort: 9092
- name: kafka2
port: 29092
targetPort: 29092
Any idea what i might be doing wrong?知道我可能做错了什么吗?
Given that your advertised listeners are the exact same service name, then you do not need both of them on different ports.鉴于您宣传的侦听器是完全相同的服务名称,那么您不需要将它们都放在不同的端口上。 Instead, you could have "internal" within the pod, and "external" across namespaces相反,您可以在 pod 中拥有“内部”,并在命名空间中拥有“外部”
eg when using default
namespace.例如,当使用default
命名空间时。
- name: KAFKA_ADVERTISED_LISTENERS
value: "LISTENER_INTERNAL://kafka-service:29092,LISTENER_EXTERNAL://kafka-service.default.svc.cluster.local:9092"
Also will want to add both ports也将要添加两个端口
ports:
- containerPort: 9092
- containerPort: 29092
Unclear what your error is being logged from, but seems like you should be using an address closer to kafka-service.svc.cluster.local:9092
- ref Kubernetes DNS docs不清楚您的错误是从什么记录下来的,但似乎您应该使用更接近kafka-service.svc.cluster.local:9092
的地址 - 参考Kubernetes DNS 文档
Alternatively, https://strimzi.io has very in-depth documentation about running and using Kafka on Kubernetes.或者, https: //strimzi.io 有关于在 Kubernetes 上运行和使用 Kafka 的非常深入的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.