Kubernetes:通过入口将非HTTP请求路由到容器 [英] Kubernetes: Routing non HTTP Request via Ingress to Container

查看:108
本文介绍了Kubernetes:通过入口将非HTTP请求路由到容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我在Mac OS上使用与docker捆绑在一起的本地kubernetes.
  2. 我已经安装了 nginx-ingress-controller .
  3. 我设法通过入口发送外部http 请求到我的kubernetes托管容器(例如从本地浏览器).所有请求都是通过nginx端口80或443发送的.
  1. I use a local kubernetes bundled with docker on Mac OS.
  2. I've installed the nginx-ingress-controller.
  3. I manged to send external http request via ingress to my kubernetes managed containers (e.g. from my local browser). All request are sent via the nginx ports 80 or 443.

问题是,我只能通过我的ngnix控制器路由http或https请求. 如何通过入口向容器发送非HTTP请求(例如数据库或corba)?

The problem is, that I can only route http or https requests via my ngnix controller. How can I send non HTTP Requests (e.g. database or corba) via ingress to my containers?

推荐答案

通过入口机制不能很好地支持它,它是未解决问题.
有一种使用nginx-ingress的tcp或udp流量的解决方法,它将使用configmap将暴露的端口映射到kubernetes服务.
参见此文档.

This is not well supported via the ingress mechanism and is an open issue.
There is a work around for tcp or udp traffic using nginx-ingress which will map an exposed port to a kubernetes service using a configmap.
See this doc.

使用tcp-services-configmap(和/或udp-services-configmap)参数启动入口控制器.

Start the ingress controller with the tcp-services-configmap (and/or udp-services-configmap) argument.

args: 
- "/nginx-ingress-controller"
- "--tcp-services-configmap=default/nginx-tcp-configmap"
- "--v=2"

部署配置图:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-tcp-configmap
data:
  9000: "default/example-service:8080"

其中9000是裸露的端口,8080是服务端口

where 9000 is the exposed port and 8080 is the service port

这篇关于Kubernetes:通过入口将非HTTP请求路由到容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆