如何将部署在 Rancher k3s 上的应用程序公开到互联网

发布于 2025-01-09 07:38:41 字数 507 浏览 1 评论 0原文

我在不同的命名空间上有不同的部署,即使我没有可用的静态公共 IP,我也想将其中一些部署公开到 Internet。 不同的服务部署在 Rancher k3s 上,每个可公开访问的服务都有一个在同一命名空间中定义的 Ingress。

我试图关注 Rancher - 如何公开公开我的服务? ,但我并没有真正明白我必须做什么,而且:

  • 为什么我们需要定义一个 LoadBalancer?在我看来,k3s(Traefik?)使用的 IngressController 已经创建了一个。如果这是必须的(或者是一个好的方法),那么应该如何准确定义服务?
  • 我的环境中没有任何 Rancher UI。因此,有没有办法以声明的方式实现该链接中描述的内容?
  • 有没有办法使用 No-IP 或 FreeDNS 等服务作为最终主机名?

I've different deployments over different namespaces and I would like to expose some of them to the Internet, even if I don't have a static and public IP available.
The different services are deployed on Rancher k3s and every service which should be publicly accessible has an Ingress defined in the same namespace.

I was trying to follow Rancher - How to expose my services publicly?, but I didn't really get what I've to do and, moreover:

  • Why do we need to define a LoadBalancer? It seems to me that the IngressController used by k3s (Traefik?) already creates one. If this is a must (or a good way to go), how it should the service defined exactly?
  • I don't have any Rancher UI in my environment. Therefore, is there a way to achieve what described in that link in a declarative way?
  • Is there a way to use services like No-IP or FreeDNS for the final hostname?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄风 2025-01-16 07:38:41

如果我没猜错的话,您已经在准系统/虚拟机节点上手动部署了 Kubernetes,现在您想要在该集群内运行部署。

  • 此设置中有两个级别的负载平衡,由您的入口控制器管理的一个,听起来在您的情况下是 traefik,建议在您的工作人员之前运行第二个 L4 负载平衡器以到达以下入口 Pod通常部署在多个/所有节点上。即使您没有 L4 负载均衡器,Traefik 或其他 lb 控制器也会毫无问题地在 k8s 集群内负载均衡器流量,但不建议这样做,因为如果您失去此节点,则没有流量可以再到达 kubernetes 集群。你“只”需要让你的 dns 解析指向你的公共 IP 并路由到你的一名工作人员,或者它前面的 LB。但是,如果您没有 L4 LB,则需要让入口 Pod 侦听端口 80 和/或 443。
  • 您在 Rancher UI 中执行的大多数操作只是查看 k8s 对象的更简单方法,所有入口配置可以通过 kubectl、k9s(强烈推荐那个!)、lens 或其他方法来实现。然而 k8s 对象仍然是 k8s 对象。在这种情况下,您需要使用 ClusterIP 公开您的服务,然后入口 Pod 可以访问这些服务。
  • 我从来没有使用过 k8s 原生的这样的解决方案,但是当我也使用过互联网路由器时,它就能够完成这部分工作,一旦你在那里,它就是内部路由。

我希望这有帮助。 Ingress 绝对是一个很难掌握的东西!

If I get it right, you deployed Kubernetes manually on barebone/vms nodes and now you want to reach you deployments running inside that cluster.

  • There is two level of loadbalancing in this setup, the one managed by your ingress controller, sounds like it is traefik in your case, and it is recommanded to run a second L4 load balancer in front of your workers to reach the ingress pods that are usually deployed on multiple/all nodes. Traefik, or other lb controllers, will load balancer traffic inside the k8s cluster without issue even if you don't have a L4 load balancer, but it is not recommanded as if you loose this node, no traffic can reach the kubernetes cluster anymore. You "just" need to have your dns resolution pointing at your public ip and routed to one of your worker, or the LB in front of it. However, if you don't have a L4 LB, you'll need to have your ingress pods listening on ports 80 and/or 443.
  • Most things that you do in Rancher UI is just an easier way to see your k8s objects, all ingress configuration can be achieved via kubectl, k9s (strongly recommand thatone!), lens or other methods. However k8s objects are still k8s objects. In this case, you need to have your services exposed with ClusterIP that are then reachable by the ingress pods.
  • I've never used such a solution natively from k8s, but when I had too the internet router was able to do this part, once you're there, it is internal routing.

I hope this helps. Ingress can definitely be a tough one to grasp!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文