emmm,学习consul啦,它的工作方式,一直没弄懂,非得好好研究下不可。以官方的文档作为学习材料,毕竟没有发现系统性讲解的书。https://www.consul.io/intro/
本文是针对 introduction to consul 的摘录。
What is Consul?
Consul is a service mesh solution providing a full featured control plane with service discovery, configuration, and segmentation functionality. Each of these features can be used individually as needed, or they can be used together to build a full service mesh. Consul requires a data plane and supports both a proxy and native integration model. Consul ships with a simple built-in proxy so that everything works out of the box, but also supports 3rd party proxy integrations such as Envoy.
- service mesh: 服务网格,一个很重要的概念,可参考 https://www.jianshu.com/p/27a742e349f7
- control plane: 控制面板,SDN专用术语,用来集中配置和管理数据面板,也可以对接各种服务发现机制(如K8S服务发现)。
- service discovery: 服务发现
- configuration: 配置
- segmentation functionality: 不太懂,没查到意思
- data plane: 数据平面,代指业务逻辑代码
the key feature of Consul are:
- Service discovery: Clients of Consul can register a service, such as api or mysql, and other clients can use Consul to discover providers of a given service. Using either DNS or HTTP, applications can easily find the services they depend upon.
- Health Checking: Consul clients can provide any number of health checks, either associated with a given service (“is the webserver returning 200 OK”), or with the local node (“is memory utilization below 90%”). This information can be used by an operator to monitor cluster health, and it is used by the service discovery components to route traffic away from unhealthy hosts.
- KV Store: Applications can make use of Consul’s hierarchical key/value store for any number of purposes, including dynamic configuration, feature flagging, coordination, leader election, and more. The simple HTTP API makes it easy to use.
- Secure Service Communication: Consul can generate and distribute TLS certificates for services to establish mutual TLS connections. Intentions can be used to define which services are allowed to communicate. Service segmentation can be easily managed with intentions that can be changed in real time instead of using complex network topologies and static firewall rules.
- Multi Datacenter: Consul supports multiple datacenters out of the box. This means users of Consul do not have to worry about building additional layers of abstraction to grow to multiple regions.
Consul is designed to be friendly to both the DevOps community and application developers, making it perfect for modern, elastic infrastructures.
Consul 基本架构 Basic Architecture
- Consul is a distributed, highly available system. 分布式,高可用性系统。
- Every node that provides services to Consul runs a Consul agent. Running an agent is not required for discovering other services or getting/setting key/value data. The agent is responsible for health checking the services on the node as well as the node itself. 每个为consul提供服务的节点都会运行一个consul客户端。运行一个客户端并不是为了发现其他服务或者获取/设置键值对数据。客户端是为了对节点上的服务以及节点本身进行健康检查。
- The agents talk to one or more Consul servers. The Consul servers are where data is stored and replicated. The servers themselves elect a leader. While Consul can function with one server, 3 to 5 is recommended to avoid failure scenarios leading to data loss. A cluster of Consul servers is recommended for each datacenter. 这些客户端和一个或者多个consul服务端通信。数据的存储以及复制正是在conful服务端进行。
- Components of your infrastructure that need to discover other services or nodes can query any of the Consul servers or any of the Consul agents. The agents forward queries to the servers automatically. 一些基础设施的组件如果需要去发现其他一些服务或者节点,可以对任意一个consul服务端或者客户端发起请求。这些客户端会自动进一步地对服务端进行请求。
- Each datacenter runs a cluster of Consul servers. When a cross-datacenter service discovery or configuration request is made, the local Consul servers forward the request to the remote datacenter and return the result. 这里对数据中心还不是很理解。
小结
introduction 就到此为止吧,下一篇介绍consul的getting started。