简体   繁体   English

使用Strimzi外部访问Kafka

[英]External access to Kafka using Strimzi

I'm attempting to provide bi-direction external access to Kafka using Strimzi by following this guide: Red Hat Developer - Kafka in Kubernetes我正在尝试按照本指南使用 Strimzi 提供对 Kafka 的双向外部访问: Red Hat Developer - Kafka in Kubernetes

My YAML taken from the Strimizi examples on GitHub , is as follows:我的 YAML 取自GitHub 上Strimizi 示例,如下所示:

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    version: 3.0.0
    replicas: 1 #3
    listeners:
      - name: plain
        port: 9092
        type: internal
        tls: false
      - name: tls
        port: 9093
        type: internal
        tls: true
      - name: external
        port: 9094
        type: loadbalancer
        tls: false
        configuration:
          #externalTrafficPolicy: Local
          #loadBalancerSourceRanges:
          #  - 10.0.0.200/32
          brokers:
          - broker: 0
            advertisedHost: 10.0.0.200
            advertisedPort: 30123
    config:
      offsets.topic.replication.factor: 1 #3
      transaction.state.log.replication.factor: 1 #3
      transaction.state.log.min.isr: 1 #2
      log.message.format.version: "3.0"
      inter.broker.protocol.version: "3.0"
    storage:
      type: ephemeral
  zookeeper:
    replicas: 1 #3
    storage:
      type: ephemeral
  entityOperator:
    topicOperator: {}
    userOperator: {}

When running kubectl get services I'm presented with the following:运行kubectl get services我会看到以下内容:

NAME                                  TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                               AGE
kubernetes                            ClusterIP      10.96.0.1       <none>        443/TCP                               48m
my-cluster-kafka-0                    LoadBalancer   10.107.190.96   <pending>     9094:31964/TCP                        29m
my-cluster-kafka-bootstrap            ClusterIP      10.99.34.246    <none>        9091/TCP,9092/TCP,9093/TCP            43m
my-cluster-kafka-brokers              ClusterIP      None            <none>        9090/TCP,9091/TCP,9092/TCP,9093/TCP   43m
my-cluster-kafka-external-bootstrap   LoadBalancer   10.99.91.68     <pending>     9094:31442/TCP                        29m
my-cluster-zookeeper-client           ClusterIP      10.101.216.35   <none>        2181/TCP                              45m
my-cluster-zookeeper-nodes            ClusterIP      None            <none>        2181/TCP,2888/TCP,3888/TCP            45m

Note the my-cluster-kafka-0 and my-cluster-kafka-external-bootstrap has a <pending> EXTERNAL-IP .注意my-cluster-kafka-0my-cluster-kafka-external-bootstrap有一个<pending> EXTERNAL-IP What am I missing within my YAML file to provide bi-direction external access to my-cluster-kafka-0 ?我在 YAML 文件中缺少什么以提供对my-cluster-kafka-0双向外部访问?

Strimzi just created the Kubernetes Service of type Loadbalancer . Strimzi 刚刚创建了Loadbalancer类型的 Kubernetes 服务。 It is up to your Kubernetes cluster to provision the load balancer and set its external address which Strimzi can use.由您的 Kubernetes 集群来配置负载均衡器并设置它的外部地址以供 Strimzi 使用。 When the external address is listed as pending it means the load balancer is not (yet) created.当外部地址被列为pending这意味着负载均衡器尚未(尚未)创建。 In some public clouds that can take few minutes, so it might be just about waiting for it.在某些公共云中,这可能需要几分钟时间,因此可能只是等待。 But keep in mind that the load balancers are not supported in all environments => and when they are not supported, you cannot really use them.但请记住,并非所有环境都支持负载均衡器 => 并且当它们不受支持时,您就无法真正使用它们。 So you really need to double check whether your environment supports them or not.所以你真的需要仔细检查你的环境是否支持它们。 Typically, different clouds would support load balancers while some local or bare-metal environments might not (but it really depends).通常,不同的云会支持负载平衡器,而某些本地或裸机环境可能不支持(但这确实取决于)。

I'm also not really sure why did you configured the advertised host and port:我也不太确定你为什么要配置公布的主机和端口:

            advertisedHost: 10.0.0.200
            advertisedPort: 30123

When using load balancers (assuming they would be supported in your environments), you would normally want to use the loadbalancer address which will be automatically set as the advertised host / port.使用负载均衡器时(假设它们在您的环境中受支持),您通常希望使用负载均衡器地址,该地址将自动设置为广告主机/端口。 Apart from that, your YAML looks good, but the loadbalancer support might be missing.除此之外,您的 YAML 看起来不错,但可能缺少负载均衡器支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM