{"id":1165,"date":"2022-08-12T18:25:01","date_gmt":"2022-08-12T10:25:01","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1165"},"modified":"2023-04-07T09:54:01","modified_gmt":"2023-04-07T01:54:01","slug":"nginx-ingress-proxy-tcp-and-udp-services","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2022\/08\/nginx-ingress-proxy-tcp-and-udp-services\/","title":{"rendered":"nginx-ingress \u4ee3\u7406 TCP \u548c UDP \u670d\u52a1"},"content":{"rendered":"
\u81ea\u5efanginx-ingress \u6216\u8005 \u4e91\u670d\u52a1\u5546\u7684nginx-ingress \u63d2\u4ef6\u90e8\u7f72\u597d\u540e \u9ed8\u8ba4\u4f1a\u5728 namespace \u4e0b\u751f\u6210tcp\/udp \u8f6c\u53d1 configmap \u914d\u7f6e\u8d44\u6e90,\u6211\u4eec\u8981\u505a\u662f\u4fee\u6539\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u548c\u5728nginx-ingress\u7684svc\u6dfb\u52a0\u8f6c\u53d1\u7aef\u53e3\u3002<\/p>\n<\/li>\n
cm\u540d\u79f0\u4e00\u822c\u662f\uff1axxxx-ingress-nginx-tcp \u6216\u8005 xxx-tcp-services<\/p>\n<\/li>\n<\/ul>\n
\u793a\u4f8b: nginx-ingress \u4ee3\u7406MongoDB 27017 \u7aef\u53e3\u3002<\/p>\n
1\u3001\u4fee\u6539tcp-services configmap\uff0c\u6dfb\u52a0\u6211\u4eec\u9700\u8981\u914d\u7f6e\u7684TCP\u8f6c\u53d1\u89c4\u5219<\/p>\n
apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: tcp-services\n namespace: ingress-nginx\ndata:\n 27017: "default\/mongodb:27017" ##\u5c0627017\u7aef\u53e3\u6d41\u91cf\u8f6c\u53d1\u5230default namespace \u4e0b\u7684mongodb:27017<\/code><\/pre>\n2\u3001\u5728nginx-ingress\u7684 service \u5185\u914d\u7f6e\u6dfb\u52a0\u6211\u4eec\u66b4\u9732\u7684TCP\u7aef\u53e3<\/p>\n
apiVersion: v1\nkind: Service\nmetadata:\n name: ingress-nginx\n namespace: ingress-nginx\n labels:\n app.kubernetes.io\/name: ingress-nginx\n app.kubernetes.io\/part-of: ingress-nginx\nspec:\n type: LoadBalancer\n ports:\n - name: http\n port: 80\n targetPort: 80\n protocol: TCP\n - name: https\n port: 443\n targetPort: 443\n protocol: TCP\n - name: 27017-mongodb ##\u6dfb\u52a0\u4e0b\u9762\u7684\u914d\u7f6e\u5373\u53ef\n port: 27017\n targetPort: 27017\n protocol: TCP\n selector:\n app.kubernetes.io\/name: ingress-nginx\n app.kubernetes.io\/part-of: ingress-nginx<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"\u81ea\u5efanginx-ingress \u6216\u8005 \u4e91\u670d\u52a1\u5546\u7684nginx-ingress \u63d2\u4ef6\u90e8\u7f72\u597d\u540e \u9ed8\u8ba4\u4f1a\u5728 names<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"yoast_head":"\n
nginx-ingress \u4ee3\u7406 TCP \u548c UDP \u670d\u52a1 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n