大网数据广告活动
服务器运维问答

What's the common practice of managing the external IP of a docker swarm?

· 52CE 我爱测

I am creating a docker swarm with 3 managers and 2 workers. A service is running in the swarm and exposes port 80. So we can hit the service with any node's ip. But what if the node goes down? Expecting a user always to try anoth…

问题原文

原帖链接 · wei · CC BY-SA 3.0

I am creating a docker swarm with 3 managers and 2 workers. A service is running in the swarm and exposes port 80. So we can hit the service with any node's ip. But what if the node goes down? Expecting a user always to try another node's ip would be very cumbersome.

So what's the common practice of managing this external access point? I can think of setting up a DNS record to return multiple nodes' IPs. Setting up another load balancer in front seems to be an overkill.

已采纳解答

原帖链接 · whites11 · CC BY-SA 3.0

I see a few options here:

1) an external load balancer.

If you are running on AWS, GCE or other cloud providers you can use the load balancer as a service those companies provide. Your DNS names will point to the load balancer's IP and your load balancer forwards traffic to your nodes.

PROS: you always have high availability (load balancer is redundant, you need at least 2 nodes and you're good to go). You also get automatic failover (if a node fails, requests are forwarded to the other nodes of your cluster).

CONS: load balancers cost money

2) a "DIY" load balancer.

You can run another server with haproxy, nginx or whatever proxy service that runs a load balancer service for you. The DNS will point to the proxy server (which is only one at this point) and it forwards to your nodes.

PROS: limited additional cost (the proxy could even be one of your cluster's nodes).

CONS: you have to setup the whole infrastructure (failover, node discovery just to name two things you should care about). You lose high availability (as long as you don't make your proxy redundant, but I'm keeping things simple)

3) multiple DNS records.

You can set, as you suggested, multiple IP addresses in your DNS records. In this case, the client will connect to a random node in your cluster.

PROS: free of charge

CONS: if a node goes down, clients will still try to connect to it as long as you don't remove it from your DNS (and it takes time, due to TTL).

If somebody has other ideas I'm glad to hear

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。