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

查看:28
本文介绍了Kubernetes:通过 Ingress 将非 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?

推荐答案

这不是通过 ingress 机制得到很好的支持,而是一个 未解决的问题.
有一种使用 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:通过 Ingress 将非 HTTP 请求路由到容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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