Kubernetes 与云提供商 - 如何使用负载均衡器将 SSH 流量路由到服务
我正在尝试构建一个 Kubernetes 集群以允许多网站测试,具有多个数据库引擎、多个 php 版本、多个依赖项、多个前端堆栈......
所以,我的目标是构建与此类似的东西:
< a href="https://i.sstatic.net/erpz7.png" rel="nofollow noreferrer">基础架构架构
使用 ingress-nginx 时,我的云提供商会为我提供一个 LoadBalancer IP。
我能够部署 ingress-nginx 使用 ingress 主机规则将我的 http/https 流量路由到正确的服务。
现在,我希望能够通过 SSH 在端口 2022 上使用负载均衡器 ip 连接到 project1_ssh 服务,并在端口 2023 上使用相同的负载均衡器 ip 连接到 project2_ssh 服务。
我可以实现吗? 我注意到 ingress-nginx 肯定允许我这样做。
我成功地能够连接到我的 ssh 服务,声明这种服务:
kind: Service
apiVersion: v1
metadata:
name: ssh-service
spec:
selector:
app: project1
ports:
- port: 2300
targetPort: 23
type: LoadBalancer
但是这样做会在云提供商上创建一个新的 loadbalancerIp 和一个新的账单。
我只想拥有一项 LoadBalancer 服务。
有什么建议吗?
这个想法是运行大约 50 个网站,每个网站都在一个 Pod 中。
I'm trying to build a Kubernetes cluster to allow multi-website testing, with multiple databases engine, multiple php versions, multiple dependancies, multiple front-end stacks, ...
So, my goal is to build something similar to this :
When using ingress-nginx, my cloud provider gives me a LoadBalancer IP.
I was able to deploy ingress-nginx to route my http/https trafic to the right service using ingress host rules.
Now, i want to be able to connect via SSH to the project1_ssh service with the loadbalancer ip, on port 2022, and to project2_ssh service with the same loadbalancer ip, on port 2023.
Can i achieve that ?
I'm note sure ingress-nginx will allow me to do that.
I successfully was able to connect to my ssh service declaring this kind of service :
kind: Service
apiVersion: v1
metadata:
name: ssh-service
spec:
selector:
app: project1
ports:
- port: 2300
targetPort: 23
type: LoadBalancer
But doing this, creates a new loadbalancerIp, and a new bill on the cloud provider.
I want to have only one LoadBalancer service.
Any suggestions ?
The idea is to run ~50 websites, each one in a pod.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我终于删除了 ingress-nginx,并切换到 Traefik-V2,我实现了我想要的。
现在我将尝试弄清楚 SNI 是否可以使其变得更加简单(我的所有 ssh 服务使用一个相同的端口,但我的 ssh 请求中调用的主机将用于将连接路由到集群内的正确服务。
https://kupczynski.info/2019/05/21/traefik-sni.html
会让你知道它是否最终有效
Ok, i finally removed ingress-nginx, and switched to Traefik-V2, and i achieved what i wanted.
Now i will try to figure out if SNI can make it even more simple (one same port for all my ssh services, but the host called in my ssh request would be used to route the connection to the right service inside the cluster.
https://kupczynski.info/2019/05/21/traefik-sni.html
Will let you know if it finally works