物理机 nginx udp 转发至k8s ingress (udp)

1. nginx 版本要高,1.12 以上,且有 --with-stream 模块,测试地址: 10.4.17.68
2. 物理机 nginx 必须将以下配置添加在nginx.conf中,http 模块外 
stream { 
  upstream udpserver  {
         server 10.16.0.237:80; (k8s ingress地址) 
    }
     server {
          listen 80 udp; 
          proxy_responses 1;
          proxy_timeout 20s;
          proxy_pass udpserver;
       } 
    } 

3. 将域名A 记录绑定此服务器地址,不用配置 server_name,因为udp 不支持 server_name 
4. k8s ingress 指向 svc ,
deployment 要开启容器的udp 端口 
deployments ports:
   - containerPort: 7000 
      name: http1 
      protocol: UDP 
svc : 
    ports:
       - name: http1
         port: 7000
         protocol: UDP
         targetPort: 7000 
 ingress:
   serviceName: im-server-svc 
   servicePort: 7000

相关推荐