问题描述
让我们说:
apiVersion: v1
kind: ConfigMap
Metadata:
name: tcp-services
namespace: ingress-Nginx-private
data:
3389: “demo/rdp:3389”`
将公开一个“rdp”服务。如果我们有 10 个需要以相同方式公开的服务,我们该如何实现?
解决方法
您需要使用新端口动态编辑此配置映射。
您也可以使用 Traefik V2,他们通过 CRD 使 TCP/UDP 服务民主化。
但这两种情况,您都需要在 kube 上编辑清单。
,正如此处的 nginx 入口文档所述:user-guide/exposing-tcp-udp-services
您需要编辑配置映射:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
9000: "default/example-0:8080" ?
9001: "default/example-1:8080" ?
9002: "default/example-2:8080" ?
和 nginx 入口服务:
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
- name: proxied-tcp-9001 ?
port: 9001
targetPort: 9001
protocol: TCP
- name: proxied-tcp-9002 ?
port: 9002
targetPort: 9002
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
您可以添加任意数量的端口。请记住,一个端口只能使用一次。