istio通过Gateway和VirtualService代理tcp端口
1.新建gw和vs
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: tcp-gateway
namespace: ns
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- tcp.xx.xx.xx #域名
port:
name: gateway-tcp
number: 9099 #istio代理tcp端口的端口
protocol: TCP
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: tcp-vs
namespace: ns
spec:
gateways:
- ck-tcp-gateway
hosts:
- tcp.xx.xx.xx #域名
tcp:
- match:
- port: 9099 #istio代理tcp端口的端口
route:
- destination:
host: my-server.ns.svc.cluster.local
port:
number: 9000 #需要代理的服务的tcp端口
2.修改istio-ingressgateway的svc
新增一个监听端口和nodeport
- name: tcp-test
nodePort: 20099
port: 9099
protocol: TCP
targetPort: 9099
3.测试
#端口为上面新加的tcp端口的nodeport curl -H "Host:tcp.xx.xx.xx" http://10.10.10.10:20099

浙公网安备 33010602011771号