简体   繁体   English

群集Docker Swarm主机

[英]Cluster Docker Swarm Hosts

This is probably a simple question but I am wondering how others do this. 这可能是一个简单的问题,但我想知道其他人是如何做到的。

I have a Docker Swarm Mode cluster with 3 managers. 我有一个Docker Swarm模式集群,有3个管理器。 Lets say they have the IP's 让我们说他们有IP

  • 192.168.1.10 192.168.1.10
  • 192.168.1.20 192.168.1.20
  • 192.168.1.30 192.168.1.30

I can access my web container through any of the IP's, through the internal routing mesh etc. But incase the host goes down with the IP I access my web container with I obviously won't get routed to the container any more. 我可以通过任何IP访问我的网络容器,通过内部路由网格等。但是当主机关闭IP我访问我的网络容器时我显然不会再被路由到容器。 So I need some kind of single DNS record or something that points me to an active address in my cluster. 所以我需要某种单一的DNS记录或者指向我的群集中的活动地址的东西。

How do you guys do this? 你们是怎么做到的? Should I add all three IP's as A records to the DNS? 我应该将所有三个IP作为A记录添加到DNS吗? Or have a load balancer / reverse proxy infront of the cluster? 或者在集群面前有负载均衡器/反向代理?

I suppose there is more than one solution, would be nice to hear how others solved this :-) 我想有不止一个解决方案,很高兴听到其他人如何解决这个问题:-)

Thanks a lot 非常感谢

Assuming your web server was started something like this: 假设您的Web服务器启动了这样的事情:

docker service create --replicas=1 -p 80:80 nginx:alpine

The cluster will attempt to reschedule that one replica should the replica go down for any reason. 如果副本因任何原因而关闭,群集将尝试重新安排该副本。 With only 1 replica, you may experience some downtime between the old task going away, in the new task coming up somewhere else. 只有1个副本,您可能会遇到旧任务消失之间的一些停机时间,在其他地方出现的新任务中。

Part of the design goal of the routing mesh feature was indeed to simplify load-balancing configuration. 路由网格功能的部分设计目标确实是为了简化负载平衡配置。 Because all members of the cluster listen on port 80 in my example, your load balancer can simply be configured to listen to all three ips. 由于群集中的所有成员都在我的示例中侦听端口80,因此可以简单地将负载均衡器配置为侦听所有三个ips。 Assuming the load balancer can properly detect the one node going down, the task will get rescheduled somewhere in the cluster, and any of the two remaining nodes will be able to route traffic via the routing mesh. 假设负载均衡器可以正确检测到一个节点发生故障,任务将重新安排在集群中的某个位置,其余两个节点中的任何一个都能够通过路由网络路由流量。

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

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