如何连接到Kubernetes集群中的Kafka实例?

时间:2019-03-09 13:34:22

标签: kubernetes apache-kafka rancher

我只是使用rancher来部署kubernetes集群,并使用rancher的云应用程序来部署kafka(如果我没错,那是使用头盔图表来完成此操作)。不幸的是,我无法从外部连接到它。我刚刚在端口9092上创建了一个指向kafka-dtxkf-kafka服务的入口。但是,它仍然无法连接。

我的集群如下:

NAME                                               READY     STATUS    RESTARTS   AGE
pod/kafka-dtxkf-kafka-0                            1/1       Running   0          13m
pod/kafka-dtxkf-kafka-1                            1/1       Running   0          13m
pod/kafka-dtxkf-kafka-2                            1/1       Running   1          13m
pod/kafka-dtxkf-kafka-rest-85d899545f-jzq4g        1/1       Running   1          13m
pod/kafka-dtxkf-kafka-topics-ui-654d9c455d-pw74m   1/1       Running   0          13m
pod/kafka-dtxkf-schema-registry-6c54bdf8c4-ktjkg   1/1       Running   5          13m
pod/kafka-dtxkf-zookeeper-0                        1/1       Running   0          13m
pod/kafka-dtxkf-zookeeper-1                        1/1       Running   0          13m
pod/kafka-dtxkf-zookeeper-2                        1/1       Running   0          13m

NAME                                               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/ingress-aef7dfa8ffc7dc6099c8c10a74d8e962   ClusterIP   10.43.219.128   <none>        9092/TCP                     3m
service/kafka-dtxkf-kafka                          ClusterIP   10.43.241.160   <none>        9092/TCP                     13m
service/kafka-dtxkf-kafka-headless                 ClusterIP   None            <none>        9092/TCP                     13m
service/kafka-dtxkf-kafka-rest                     ClusterIP   10.43.134.186   <none>        8082/TCP                     13m
service/kafka-dtxkf-kafka-topics-ui                NodePort    10.43.210.62    <none>        8000:31547/TCP               13m
service/kafka-dtxkf-schema-registry                ClusterIP   10.43.101.213   <none>        8081/TCP                     13m
service/kafka-dtxkf-zookeeper                      ClusterIP   10.43.242.136   <none>        2181/TCP                     13m
service/kafka-dtxkf-zookeeper-headless             ClusterIP   None            <none>        2181/TCP,2888/TCP,3888/TCP   13m
service/kubernetes                                 ClusterIP   10.43.0.1       <none>        443/TCP                      1d

NAME                                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/kafka-dtxkf-kafka-rest        1         1         1            1           13m
deployment.apps/kafka-dtxkf-kafka-topics-ui   1         1         1            1           13m
deployment.apps/kafka-dtxkf-schema-registry   1         1         1            1           13m

NAME                                                     DESIRED   CURRENT   READY     AGE
replicaset.apps/kafka-dtxkf-kafka-rest-85d899545f        1         1         1         13m
replicaset.apps/kafka-dtxkf-kafka-topics-ui-654d9c455d   1         1         1         13m
replicaset.apps/kafka-dtxkf-schema-registry-6c54bdf8c4   1         1         1         13m

NAME                                     DESIRED   CURRENT   AGE
statefulset.apps/kafka-dtxkf-kafka       3         3         13m
statefulset.apps/kafka-dtxkf-zookeeper   3         3         13m

我的入口配置:

enter image description here

kubectl描述服务/ ingress-aef7dfa8ffc7dc6099c8c10a74d8e962:

    Name:              ingress-aef7dfa8ffc7dc6099c8c10a74d8e962
    Namespace:         default
    Labels:            cattle.io/creator=norman
    Annotations:       field.cattle.io/targetWorkloadIds=["statefulset:default:kafka-dtxkf-kafka"]
    Selector:          workloadID_ingress-aef7dfa8ffc7dc6099c8c10a74d8e962=true
    Type:              ClusterIP
    IP:                10.43.219.128
    Port:              <unset>  9092/TCP
    TargetPort:        9092/TCP
    Endpoints:         10.42.0.111:9092,10.42.1.83:9092,10.42.1.84:9092
    Session Affinity:  None
    Events:            <none>

1 个答案:

答案 0 :(得分:0)

我认为负载均衡器仅导出http / https流量,对于kafka,您可以使用tcp-service https://github.com/rancher/rancher/issues/14744