简体   繁体   English

多个入口控制器不同区域裸机

[英]Multiple ingress controller different zone bare-metal

I have two-zone, each has to master node.我有两个区域,每个区域都必须主节点。 Today I created a simple ingress-nginx controller and successfully pointed a DNS test.example.com to one of the public IP in zone-1.今天我创建了一个简单的 ingress-nginx 控制器,并成功地将 DNS test.example.com 指向了 zone-1 中的公共 IP 之一。 But now I want to create another nginx-controller in zone-2 and point test.example.com to the public IP address of that zone with cloud DNS.但是现在我想在 zone-2 中创建另一个 nginx-controller 并将 test.example.com 指向具有云 DNS 的该区域的公共 IP 地址。 What approach should I take?我应该采取什么方法? Is there any best practice?有什么最佳实践吗?

Your question is unclear and needs to be improved with any minimal reproducible example.您的问题不清楚,需要通过任何最小的可重现示例进行改进。 You can find the manual here .您可以在此处找到手册

According to your subject, you're using Kubernetes cluster in bare-metal, however you mentioned using cloud DNS.根据您的主题,您在裸机中使用 Kubernetes 集群,但是您提到使用云 DNS。 Where did you get cloud DNS?您从哪里获得云 DNS?

If you're using pure bare metal, then consider using MetalLB .如果您使用纯裸机,请考虑使用MetalLB

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster. MetalLB 为不在受支持的云提供商上运行的 Kubernetes 集群提供网络负载均衡器实现,有效地允许在任何集群中使用 LoadBalancer 服务。

But this approach has a few other limitations one ought to be aware of, one of them is about Ingress status:但是这种方法还有一些其他的限制,我们应该注意,其中之一是关于 Ingress 状态的:

  • Because NodePort Services do not get a LoadBalancerIP assigned by definition, the NGINX Ingress controller does not update the status of Ingress objects it manages因为 NodePort 服务没有得到定义分配的 LoadBalancerIP,NGINX Ingress 控制器不会更新它管理的 Ingress 对象的状态
$ kubectl get ingress
NAME           HOSTS               ADDRESS   PORTS
test-ingress   myapp.example.com             80

Despite the fact there is no load balancer providing a public IP address to the NGINX Ingress controller, it is possible to force the status update of all managed Ingress objects by setting the externalIPs field of the ingress-nginx Service.尽管没有负载均衡器为 NGINX Ingress 控制器提供公共 IP 地址,但可以通过设置 ingress-nginx 服务的 externalIPs 字段来强制所有托管 Ingress 对象的状态更新。

Please see the example below:请看下面的例子:

Given the following 3-node Kubernetes cluster (the external IP is added as an example, in most bare-metal environments this value is )给定以下 3 节点 Kubernetes 集群(以添加外部 IP 为例,在大多数裸机环境中该值为 )

$ kubectl get node
NAME     STATUS   ROLES    EXTERNAL-IP
host-1   Ready    master   203.0.113.1
host-2   Ready    node     203.0.113.2
host-3   Ready    node     203.0.113.3

one could edit the ingress-nginx Service and add the following field to the object spec可以编辑ingress-nginx服务并将以下字段添加到对象规范中

spec:
  externalIPs:
  - 203.0.113.1
  - 203.0.113.2
  - 203.0.113.3

which would in turn be reflected on Ingress objects as follows:这将依次反映在 Ingress 对象上,如下所示:

$ kubectl get ingress -o wide
NAME           HOSTS               ADDRESS                               PORTS
test-ingress   myapp.example.com   203.0.113.1,203.0.113.2,203.0.113.3   80

See more detailed info here在此处查看更多详细信息

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

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