我有多个部署,它们运行着运行 TCP 服务器的 pod。这些 TCP 服务器都在端口 9999 上侦听
目前每个部署都有自己的负载均衡器服务,这导致每个部署都有不同的 IP。
但是我希望有一个 IP 地址来公开部署并且仅通过端口进行区分。
例如:
<public-ip>:9001 -> deployment 1
<public-ip>:9002 -> deployment 2
<public-ip>:9003 -> deployment 3
我已阅读有关 Ingress 的内容,但 docs 声明
<块引用>Ingress 不会公开任意端口或协议。向互联网公开 HTTP 和 HTTPS 以外的服务通常使用 Service.Type=NodePort 或 Service.Type=LoadBalancer 类型的服务。
所以这似乎不是一个选项。
对于上下文,kubernetes 托管在 vnet 中的 azure 中,只需从该 vnet 中访问。
答案 0 :(得分:2)
功能入口取决于您使用的控制器实现。例如,nginx 入口控制器支持 TCP/UDP 代理,如记录 here
下一个示例显示如何使用端口 8080
公开在端口 9000
中默认命名空间中运行的服务 example-go
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
9000: "default/example-go:8080"
如果使用 TCP/UDP 代理支持,则需要在为 Ingress 定义的服务中公开这些端口。
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
- name: https
port: 443
targetPort: 443
protocol: TCP
- name: proxied-tcp-9000
port: 9000
targetPort: 9000
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
答案 1 :(得分:0)
解决方案:
现在,您可以使用