kubernetes服务无法访问多端口服务上的端口

时间:2019-12-31 02:24:23

标签: docker kubernetes apache-kafka

我无法在端口9092上访问kubernetes服务。同一服务也公开了端口29092,因此我可以访问它。麻烦的是,我在Kube内部运行Kafka。我使用docker stack将docker-compose文件中的资源部署到kube上。这样就创建了如下服务:

NAME                        TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
broker                      ClusterIP      None             <none>        55555/TCP                        65m
broker-published            LoadBalancer   10.109.34.43     localhost     9092:30229/TCP,29092:32557/TCP   65m

我现在正尝试通过localhost:9092访问Kafka代理,但无法这样做。我可以轻松访问29092。 如果我移植了kubectl port-forward service /经纪人发布的9092:9092,我只能访问9092

当我将服务描述为Yaml时,得到以下信息:

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2019-12-31T01:14:18Z"
  labels:
    com.docker.service.id: local-kafka-broker
    com.docker.service.name: broker
    com.docker.stack.namespace: local-kafka
  name: broker-published
  namespace: payments
  ownerReferences:
  - apiVersion: compose.docker.com/v1alpha3
    blockOwnerDeletion: true
    controller: true
    kind: Stack
    name: local-kafka
    uid: dd6045a4-2b6a-11ea-9dab-025000000001
  resourceVersion: "428377"
  selfLink: /api/v1/namespaces/payments/services/broker-published
  uid: de1b9498-2b6a-11ea-898e-025000000001
spec:
  clusterIP: 10.109.34.43
  externalTrafficPolicy: Cluster
  ports:
  - name: 9092-tcp
    nodePort: 30229
    port: 9092
    protocol: TCP
    targetPort: 9092
  - name: 29092-tcp
    nodePort: 32557
    port: 29092
    protocol: TCP
    targetPort: 29092
  selector:
    com.docker.service.id: local-kafka-broker
    com.docker.service.name: broker
    com.docker.stack.namespace: local-kafka
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - hostname: localhost

我做错了什么?

0 个答案:

没有答案