需要针对Docker引擎群模式进行服务发现 [英] Need for service discovery for docker engine swarm mode

查看:109
本文介绍了需要针对Docker引擎群模式进行服务发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对docker swarm感到困惑。据我所知,运行集群的旧方法是在容器引擎为集群模式提供本机支持之前,在容器中运行管理器和工作器。旧的,有容器的群集的文档介绍了如何使用领事,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?

泊坞窗引擎群模式的文档没有说明如何设置服务发现。现在我很困惑,如果该机制包含在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 Legacy与关于服务发现的Swarm模式:

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旧版,新版本为Swarm 模式

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



具有Swarm Legacy的服务发现



使用 Swarm Legacy ,您必须部署自己的 Zookeeper 领事 Etcd 来管理集群拓扑,这意味着将节点分配为集群中的代理。这些分布式键/值存储用于运行状况监视和分布式锁定目的。 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.

如果您希望通过以下方式部署容器的服务发现蜂拥而至,您必须设置一个外部Consul / Registrator / DNS例如,并在这些解决方案上注册您的服务。在我看来,专门为Swarm构建的这种系统的一个示例是 Wagl

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 起,服务发现通过直接包含在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引擎群模式进行服务发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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