0

嘿,我正在使用 Kafka Strimzi。我使用以下 yml 文件创建了我的 kafkaTopic 和 KafkaUser:

apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaUser
metadata:
  name: my-user
  labels:
    strimzi.io/cluster: my-cluster
spec:
  authentication:
    type: tls
  authorization:
    type: simple
    acls:
      # Example consumer Acls for topic my-topic using consumer group my-group
      - resource:
          type: topic
          name: my-topic
          patternType: literal
        operation: Read
        host: "*"
      - resource:
          type: topic
          name: my-topic
          patternType: literal
        operation: Describe
        host: "*"
      - resource:
          type: group
          name: my-group
          patternType: literal
        operation: Read
        host: "*"
      # Example Producer Acls for topic my-topic
      - resource:
          type: topic
          name: my-topic
          patternType: literal
        operation: Write
        host: "*"
      - resource:
          type: topic
          name: my-topic
          patternType: literal
        operation: Create
        host: "*"
      - resource:
          type: topic
          name: my-topic
          patternType: literal
        operation: Describe
        host: "*"

apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaTopic
metadata:
  name: my-topic
  labels:
    strimzi.io/cluster: my-cluster
spec:
  partitions: 1
  replicas: 1
  config:
    retention.ms: 7200000
    segment.bytes: 1073741824
 

[kafka@my-cluster-zookeeper-0 kafka]$ bin/kafka-topics.sh --list --zookeeper 10.101.97.123:2181

当我使用这个命令时,我收到了这个错误,不知道如何解决这个问题。

Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
    at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:262)
    at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:258)
    at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:119)
    at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1865)
    at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:360)
    at kafka.admin.TopicCommand$.main(TopicCommand.scala:55)
    at kafka.admin.TopicCommand.main(TopicCommand.scala)

列出我的 kafkaTopics 时遇到此问题。请帮助我。

4

2 回答 2

2

你不能这样做,因为 Zookeeper 连接是加密的,但你可以这样做,例如:

kubectl exec -it my-cluster-kafka-0 -c kafka -- bin/kafka-topics.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --list

使用 Kafka 服务器引导连接,而不是 ZooKeeper 连接。

当然,这是在 Kafka 上正确检查的方式,但您也可以通过以下方式检查相应创建的 KafkaTopic 资源:

kubectl get kafkatopic

于 2020-11-17T11:43:47.777 回答
0

如果您的所有主题都是通过 CRD 创建的,那么最快的方法是

kubectl get kt -n <your-namespace> 

你可以在这里看到更多关于它的信息

于 2021-09-28T01:54:02.267 回答