docker - 如何通过公共(public) IP 将整个 docker swarm 集群暴露给外部世界?

标签 docker docker-swarm docker-swarm-mode

我正在尝试在 swarm 模式下使用 docker 在生产环境中实现一个容器化应用程序集群。
让我描述一个非常简约的场景。
我只有 5 aws-ec2 实例。
这些节点都没有分配公共(public) IP,并且所有节点都分配了子网的一部分的私有(private) IP。
例如,
管理器节点

  • 172.16.50.1
  • 172.16.50.2

  • 工作节点
  • 172.16.50.3
  • 172.16.50.4
  • 172.16.50.5

  • 使用上述基础设施,创建了一个 docker swarm,其中第一个节点的 IP (172.16.50.1) 作为 --advertise-addr,以便其他 4 个节点作为管理器或工作人员使用它们各自的 token 加入 swarm。

    I didn't want to overload the Manager Nodes by making them doing the role of worker nodes too. (Is this a good idea or resource under-utilization?).


    由于每个节点都是 4 个核心,因此我托管了我的 Web 应用程序的 9 个副本,这些副本分布在 3 个工作节点中,每个节点运行 3 个容器来托管我的 Web 应用程序。

    Now with this setup in hand, how should i go about exposing the entire docker swarm cluster with a VIP (virtual IP) to the external world for consumption?


    请验证我的以下想法:

    1. Should I have a classic load-balancer setup like keeping a httpd or nginx or haproxy based reverse proxy which has a public IP assigned and make it balance the load to the above 5 nodes where our docker-swarm is deployed?


    我在这里看到的一个缺点是上述反向代理将是单点故障?有什么想法可以使其容错/高度可用吗?我应该尝试 AnyCast 解决方案吗?

    2. Going for a AWS ALB/ELB which would route the traffic to the above 5 nodes where our swarm is.

    3. If keeping a separate Load Balancer is the way to go, then what does really docker-swarm load-balancing and service discovery is all about?


    docker swarm 向外部客户端公开 1 个虚拟 IP 或主机名以访问 swarm 集群中的服务的答案是什么?

    Docker-swarm touts a lot about overlay networks but not sure how it relates to my issue of exposing the cluster via VIP to clients in the internet. Should we always keep the load balancer aware of the IP addresses of the nodes that join the docker swarm later?


    请阐明一下!

    最佳答案

    在进一步阅读中,我了解到我们在 swarm manager 节点中创建的 Overlay Network 仅服务于容器间通信。

    与桥接、主机、macvlan 等其他网络模式的唯一区别在于,其他网络模式支持单个主机中的容器之间的通信,而 Overlay 网络也促进了部署在不同子网中的容器之间的通信。即多主机容器通信。

    以这些知识作为提示,通过分配给负载均衡器的单个公共(public) IP 将 swarm 暴露给世界,负载均衡器会将请求分发到所有 swarm 节点。这只是我在高层次上的理解。

    这是我需要您的意见和想法的地方...请解释如何处理的行业标准?

    关于docker - 如何通过公共(public) IP 将整个 docker swarm 集群暴露给外部世界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56986785/

    相关文章:

    docker - 从swarm中删除终止的实例(管理器),并恢复swarm状态

    performance - 进程在 ubuntu 18.04 上的 docker 容器中运行缓慢

    docker - 在 Docker Swarm 中安装 SSL 证书

    docker - RabbitMQ集群如何识别Docker的容器重启?

    docker - 在docker容器中运行时,nodejs应用程序未连接到本地主机

    Docker swarm 无法从 Dockerfile 正确构建

    docker - Docker服务创建需要更多时间

    docker - 在 docker 容器的文本编辑器中无法正确显示特殊字符

    docker - 从gitlab ci使用docker发布镜像

    docker - 如何安全地将可能包含特殊字符的变量传递给 Ansible 中的 docker-compose 文件