【问题标题】:How to configure Kubernetes to receive TCP connections如何配置 Kubernetes 以接收 TCP 连接
【发布时间】:2019-12-06 04:44:46
【问题描述】:

我正在 Azure 上的 AKS 中运行一个非常基本的集群。
我需要在端口 6879 上公开 TCP 服务器。
我已将 TCP 端口添加到负载均衡器规范中:

kind: Service
metadata:
  name: ingress-nginx
  selfLink: /api/v1/namespaces/ingress-nginx/services/ingress-nginx
spec:
  externalTrafficPolicy: Local
  healthCheckNodePort: 32557
  ports:
  - name: http
    nodePort: 30731
    port: 80
    protocol: TCP
    targetPort: http
  - name: https
    nodePort: 31187
    port: 443
    protocol: TCP
    targetPort: https
  - name: tcp
    nodePort: 31197
    port: 6879
    protocol: TCP
    targetPort: 6879
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  sessionAffinity: None
  type: LoadBalancer

此配置是否会暴露公共 IP 上的端口 6879 或 31197?
我在想我需要向 Ingress 添加一条规则,以将该流量路由到 TCP 服务器主机。但我的阅读表明 Kubernetes Ingress 不支持路由 TCP 流量。我缺少文档的哪一部分。

【问题讨论】:

    标签: kubernetes kubernetes-ingress azure-aks


    【解决方案1】:

    在 nginx 入口上的 TCP\UDP is supported

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: tcp-services
      namespace: ingress-nginx
    data:
      6879: "default/example-go:8080"
      31197: "namespace/service:port"
    

    上面的例子展示了如何使用端口 9000(从链接文章复制粘贴)公开服务 example-go 在默认命名空间中运行在端口 8080 中。

    【讨论】:

      猜你喜欢
      • 2015-12-02
      • 1970-01-01
      • 2019-10-11
      • 2018-08-07
      • 2017-11-08
      • 1970-01-01
      • 2020-02-05
      • 2020-02-24
      • 2021-06-11
      相关资源
      最近更新 更多