如何配置 Kubernetes 以接收 TCP 连接
How to configure Kubernetes to receive TCP connections
我是 运行 Azure 上 AKS 中的一个非常基本的集群。
我需要在端口 6879 上公开一个 TCP 服务器。
我已将 TCP 端口添加到 Loadbalancer 规范中:
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
此配置会暴露 public IP 上的端口 6879 或 31197 吗?
我在想我需要向 Ingress 添加规则以将该流量路由到 TCP 服务器主机。但我的阅读表明 Kubernetes Ingress 不支持路由 TCP 流量。我缺少文档的哪一部分。
TCP\UDP is supported 在 nginx 入口上
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
6879: "default/example-go:8080"
31197: "namespace/service:port"
上面的示例显示了如何使用端口 9000(从链接文章中复制粘贴)在端口 8080 的命名空间 default 中公开服务 example-go 运行。
我是 运行 Azure 上 AKS 中的一个非常基本的集群。
我需要在端口 6879 上公开一个 TCP 服务器。
我已将 TCP 端口添加到 Loadbalancer 规范中:
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
此配置会暴露 public IP 上的端口 6879 或 31197 吗?
我在想我需要向 Ingress 添加规则以将该流量路由到 TCP 服务器主机。但我的阅读表明 Kubernetes Ingress 不支持路由 TCP 流量。我缺少文档的哪一部分。
TCP\UDP is supported 在 nginx 入口上
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
6879: "default/example-go:8080"
31197: "namespace/service:port"
上面的示例显示了如何使用端口 9000(从链接文章中复制粘贴)在端口 8080 的命名空间 default 中公开服务 example-go 运行。