docker engine swarm mode需要服务发现 [英] Need for service discovery for docker engine swarm mode

查看:31
本文介绍了docker engine swarm mode需要服务发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 docker swarm 感到困惑.据我所知,运行 swarm 的旧方法是在 docker 引擎提供对 swarm 模式的本机支持之前,在容器中运行 manager 和 workers.旧的容器化 swarm 的文档解释了如何使用 consul、etcd 或 zookeeper 设置服务发现.服务发现是必要的,因为服务在随机端口运行以避免冲突,对吧?

I'm confused about docker swarm. As far as I know, the old way to run a swarm was to run manager and workers in containers, before docker engine provided native support for swarm mode. Documentation for the old, containerized swarm explained how to setup service discovery using consul, etcd or zookeeper. Service discovery is necessary, as services are ran at random ports to avoid collisions, right?

docker engine swarm mode 的文档没有解释如何设置服务发现.现在我很困惑,如果该机制包含在 swarm 模式中,或者文档不完整.

Documentation for the docker engine swarm mode doesn't explain how to setup service discovery. Now I'm confused, if the mechanism is included in swarm mode, or is the documentation incomplete.

我在哪里可以找到关于 swarm 模式的清晰、最新的解释,以及它与服务发现等概念的关系?

Where I can find clear, up-to-date explanation of swarm mode, and how it relates to concepts like service discovery?

推荐答案

虽然@MagicMicky 给出的答案是正确的,但我将尝试添加更多关于 Swarm Legacy 和 Swarm Mode 在服务发现方面的区别的上下文:

While the answer given by @MagicMicky is correct, I'll try to add more context on the difference between Swarm Legacy and Swarm Mode regarding Service Discovery:

注意:我将 Swarm 的第一个版本称为 Swarm legacy,将新版本称为 Swarm mode.

Note: I'll refer to the first version of Swarm as Swarm legacy and the new version as Swarm mode.

使用 Swarm Legacy 发现服务

使用 Swarm Legacy,您必须部署自己的 ZookeeperConsulEtcd 来管理集群拓扑意味着节点被分配为集群中的代理.这些分布式键/值存储用于健康监控和分布式锁定目的.Swarm 不使用这些来管理服务发现,而只是集群节点发现和监控.

Service discovery with Swarm Legacy

Using Swarm Legacy, you had to deploy your own Zookeeper, Consul or Etcd to manage the cluster topology meaning nodes being assigned as Agents in the cluster. These distributed Key/Value stores were used for health monitoring and distributed locking purposes. Those were not used by Swarm to manage service discovery but only cluster node discovery and monitoring.

如果您希望通过 Swarm 为您的容器部署服务发现,例如,您必须设置一个外部 Consul/Registrator/DNS 并在这些解决方案上注册您的服务.Wagl 是我想到的一个专门为 Swarm 构建的系统的例子.

If you wanted Service Discovery for your containers deployed through Swarm, you had to setup an external Consul/Registrator/DNS for example and register your services on those solutions. An example on top of my mind of such a system built specifically for Swarm was Wagl.

使用更高版本的 docker 引擎 (1.11),您还可以在创建覆盖网络并将容器分配给覆盖网络时访问内置 DNS.在 1.11 之前,服务发现的(有争议的)机制是通过 /etc/hosts 附加服务条目.

With later versions of the docker engine (1.11), you also had access to an in-built DNS when creating overlay networks and assigning containers to an overlay network. Before 1.11, the (controversial) mechanism for service discovery was to append service entries through /etc/hosts.

在任何情况下,覆盖网络都没有直接包含在 Swarm 中,这是一个需要自己设置的单独组件.它更像是一个附加组件".

In any case, overlay networking was not directly included with Swarm and this was a separate component requiring its own setup. It was more of an "add-on".

一般来说,第一版 Swarm 背后的理念"是提供一些简单可靠的东西来跨主机管理容器,如果您需要添加更多功能,例如服务发现或负载平衡,您必须自行开发.

Generally the "philosophy" behind the first version of Swarm was to provide something simple and reliable to manage containers across hosts, if you needed more capabilities added to it, for example Service Discovery or Load Balancing, you had to roll your own.

从 Docker 1.12 开始,服务发现通过 Swarm 模式 直接包含在 docker 中,并带有一个嵌入式 DNS 和负载均衡器.这意味着不再需要外部组件来管理服务发现和负载平衡.

As of Docker 1.12 service discovery is directly included in docker through the Swarm mode with an embedded DNS and Load Balancer. Meaning there is no need for an external component to manage Service Discovery and Load Balancing anymore.

当您创建服务并将其分配给覆盖时,其 DNS 名称将被注册,并且覆盖中的其他服务部分可以通过其服务名称访问它.使用内置 LB 对服务运行的任务进行适当的负载平衡.

When you create a service and assign it to an overlay, its DNS name is registered and other services part of the overlay can access it through its service name. Tasks running for a service are properly Load Balanced using the built-in LB.

对于 Swarm 模式,理念"更多的是包括开箱即用的所有内容(证书管理和轮换、服务发现、负载平衡、通过内置数据存储的集群元数据、网络、调度),以确保您拥有从第一天开始就可能是最完整的系统.如果需要,您仍然可以交换和更换一些组件.

For Swarm mode, the "philosophy" is more about including everything out of the box (Certificate management and rotation, service discovery, load balancing, cluster metadata through an in-built datastore, networking, scheduling) to ensure that you have the most complete system possible from day one. You are still able to swap and replace some of the components if needs be.

这篇关于docker engine swarm mode需要服务发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆