单一服务,适用于多个吊舱 [英] Single service for multiple pods

查看:63
本文介绍了单一服务,适用于多个吊舱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有9个Pod正在运行,它们基本上是9种不同的应用程序.

I have 9 pods running which are basically 9 different applications.

是否可以为多个Pod提供相同的k8s服务(LB |公共IP),以便我可以通过不同的端口访问它们,但是具有相同的服务IP(LB)?

Is it possible to have same k8s service (LB | Public IP) for multiple pods such that I can access them by different ports, but the same IP of service (LB)?

例如像这样:
LB-IP:80-在后端运行的应用程序可以访问.
LB-IP:8080(与先前的IP相同)-我将在后端运行另一个Pod.

E.g. like so:
LB-IP:80 -- In the backend an application is running, which I can access.
LB-IP:8080 (Same IP as previous) -- I will run another pod in the backend.

****每个吊舱的选择器都不同.**

**** Selectors will be different for each pod.**

推荐答案

对于纯服务方法,不可能.服务仅与一个选择器相关,所以您不能.

As for the pure service approach, no it is not possible. Service relates to only one selector so you can't.

现在,当您在这里谈论LB时,您可能正在谈论在外部公开该东西,为此,您可以拥有一个Ingress/IngressController.如果需要,您也可以只部署将为您完成任务的网关"服务(即HA代理配置为公开所需的这些不同端口)

Now, as you talk about LB here, you might be talking about exposing the thing externally, and for that you can have an Ingress/IngressController. If you want, you can also just deploy a "gateway" service that will do the thing for you (ie. HA proxy configured to expose these different ports you want)

如果您的环境不支持入口,则可能需要部署ie. Nginx入口控制器在为您的服务进入点方面做得很好

If your environment does not support ingress, you might want to deploy ie. Nginx Ingress Controller which does a great job for the point of entry to your services

这篇关于单一服务,适用于多个吊舱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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