简体   繁体   English

将 BareMetal(Kubeadm) Kube.netes 集群中的服务暴露给外界

[英]Exposing Service from a BareMetal(Kubeadm) Kubernetes Cluster to outside world

Exposing Service from a BareMetal(Kubeadm) Build Kube.netes Cluster to the outside world.从 BareMetal(Kubeadm) 构建 Kube.netes 集群向外界公开服务。 I am trying to access my Nginx as a service outside of the cluster to get NGINX output in the web browser.我正在尝试访问我的 Nginx 作为集群外部的服务,以在 web 浏览器中获取 NGINX output。

For that, I have created a deployment and service for NGINX as shown below,为此,我为 NGINX 创建了部署和服务,如下所示, 在此处输入图像描述

As per my search, found that we have below to expose to outside world根据我的搜索,发现我们有下面可以暴露给外界

  • MetalLb金属磅
  • Ingress NGINX入口 NGINX
  • Some HELM resources一些 HELM 资源

I would like to know all these 3 or any more approaches in such way it help me to learn new things.我想知道所有这 3 种或更多方法,以帮助我学习新事物。

GOAL

  • Exposing Service from a BareMetal(Kubeadm) Built Kube.netes Cluster to the outside world.将 BareMetal(Kubeadm) 构建的 Kube.netes 集群中的服务暴露给外界。
  • How Can I make my service has its own public IP to access from the outside cluster?如何让我的服务拥有自己的公共 IP 以从外部集群访问?

You need to set up MetalLB to get an external IP address for the LoadBalancer type services.您需要设置MetalLB以获得LoadBalancer类型服务的外部 IP 地址。 It will give a local.network IP address to the service.它将为该服务提供一个 local.network IP 地址。

Then you can do port mapping (configuration in the router) of incoming traffic of port 80 and port 443 to your external service IP address.然后,您可以将端口80和端口443的传入流量进行端口映射(在路由器中配置)到您的外部服务 IP 地址。

I have done a similar setup you can check it here in detail: https://developerdiary.me/lets-build-low-budget-aws-at-home/我做了类似的设置,你可以在这里详细查看: https://developerdiary.me/lets-build-low-budget-aws-at-home/

You need to deploy an ingress controller in your cluster so that it gives you an entrypoint where your applications can be accessed.您需要在集群中部署一个入口 controller ,以便它为您提供一个可以访问您的应用程序的入口点。 Traditionally, in a cloud native environment it would automatically provision a LoadBalancer for you that will read the rules you define inside your Ingress object and route your request to the appropriate service.传统上,在云原生环境中,它会自动为您提供一个 LoadBalancer,它将读取您在Ingress object 中定义的规则,并将您的请求路由到适当的服务。

One of the most commonly used ingress controller is the Nginx Ingress Controller .最常用的入口之一 controller 是Nginx 入口 Controller There are multiple ways you can use to deploy it (mainfests, helm, operators).您可以使用多种方式来部署它(mainfests、helm、operators)。 In case of bare metal clusters, there are multiple considerations which you can read here .对于裸机集群,您可以在此处阅读多种注意事项。

MetalLB is still in beta stage so its your choice if you want to use. MetalLB 仍处于测试阶段,因此您可以选择是否使用它。 If you don't have a hard requirement to expose the ingress controller as a LoadBalancer, you can expose it as a NodePort Service that will accessible across all your nodes in the cluster.如果您没有硬性要求将入口 controller 公开为 LoadBalancer,您可以将其公开为 NodePort 服务,该服务可跨集群中的所有节点访问。 You can then map that NodePort Service in your DNS so that the ingress rules are evaluated.然后,您可以 map DNS 中的 NodePort 服务,以便评估入口规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM