consul/website/content/docs/architecture/index.mdx

115 lines
8.9 KiB
Plaintext
Raw Normal View History

---
2020-04-07 18:55:19 +00:00
layout: docs
page_title: Consul Architecture
2020-04-07 18:55:19 +00:00
description: >-
Backport of docs: Consul Dataplane updates for v.1.14.0 into release/1.14.x (#15448) * backport of commit 2393183b8b3df4e519298be12468ca97e96e7959 * backport of commit 078037ba89d382ed90eb469a23910c7bd8615b40 * backport of commit b12295a915ef2fc40226481d1db786e8d9bcca8b * backport of commit 1cfeefe7c19371f15ef3366d3c05e14a222ed9d0 * backport of commit a796b1b28d792aec8a804058fae73e6e646b2cee * backport of commit 311bab5546d7030f79e138e535d3d8c57ac8d900 * backport of commit 8f995aa0004076e9d56cf04e8699d5b7422850c8 * backport of commit c77c1fce448eef3039ae2504437d54a8782f955a * backport of commit d45f5c0ab576e7af92b3fd79f8420f7fe9e0f6f0 * backport of commit 795a134e941853968d4f8a514713e7b658acef3a * backport of commit b0475b4f53588de0ce761399293aaf78235aa72e * backport of commit 92b5b4202aede6a6f9940dad2399bc8d9e000d03 * backport of commit fb1c932e4424dbca4c3241848a2cbfd1995a6bbe * backport of commit d24dd81cd04eb0b7bfb6c8ed0353eecffe5362a4 * backport of commit 41a6e193cc9a34425c41959813a46732b5b38b05 * docs: Consul Dataplane updates for v.1.14.0 (#15384) * Consul Architecture update * Consul on Kubernetes architecture * Install Consul on Kubernetes with Helm updates * Vault as the Secrets Backend Data Integration * Kubernetes Service Mesh Overview * Terminating Gateways * Fully updated * Join external service to k8s * Consul on Kubernetes * Configure metrics for Consul on Kubernetes * Service Sync for Consul on Kubernetes * Custom Resource Definitions for Consul on k8s * Upgrading Consul on Kubernetes Components * Rolling Updates to TLS * Dataplanes diagram * Upgrade instructions * k8s architecture page updates * Update website/content/docs/k8s/connect/observability/metrics.mdx Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> * Update website/content/docs/architecture/index.mdx * Update website/content/docs/k8s/connect/terminating-gateways.mdx * CRDs * updating version numbers * Updated example config * Image clean up * Apply suggestions from code review Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Update website/content/docs/k8s/architecture.mdx Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * pic fix Co-authored-by: boruszak <jeffrey.boruszak@hashicorp.com> Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2022-11-17 23:23:00 +00:00
Consul datacenters consist of clusters of server agents (control plane) and client agents deployed alongside service instances (data plane). Learn how these components and their different communication methods make Consul possible.
---
# Consul Architecture
This topic provides an overview of the Consul architecture. We recommend reviewing the Consul [glossary](/docs/install/glossary) as a companion to this topic to help you become familiar with HashiCorp terms.
> Refer to the [Reference Architecture tutorial](https://learn.hashicorp.com/tutorials/consul/reference-architecture) for hands-on guidance about deploying Consul in production.
## Introduction
Consul provides a control plane that enables you to register, access, and secure services deployed across your network. The _control plane_ is the part of the network infrastructure that maintains a central registry to track services and their respective IP addresses.
When using Consuls service mesh capabilities, Consul dynamically configures sidecar and gateway proxies in the request path, which enables you to authorize service-to-service connections, route requests to healthy service instances, and enforce mTLS encryption without modifying your services code. This ensures that communication remains performant and reliable. Refer to [Service Mesh Proxy Overview](/docs/connect/proxies) for an overview of sidecar proxies.
![Diagram of the Consul control plane](/img/consul-arch/consul-arch-overview-control-plane.svg)
## Datacenters
The Consul control plane contains one or more _datacenters_. A datacenter is the smallest unit of Consul infrastructure that can perform basic Consul operations. A datacenter contains at least one [Consul server agent](#server-agents), but a real-world deployment contains three or five server agents and several [Consul client agents](#client-agents). You can create multiple datacenters and allow nodes in different datacenters to interact with each other. Refer to [Bootstrap a Datacenter](/docs/install/bootstrapping) for information about how to create a datacenter.
### Clusters
2022-10-11 14:58:52 +00:00
A collection of Consul agents that are aware of each other is called a _cluster_. The terms _datacenter_ and _cluster_ are often used interchangeably. In some cases, however, _cluster_ refers only to Consul server agents, such as in [HCP Consul](https://cloud.hashicorp.com/products/consul). In other contexts, such as the [_admin partitions_](/docs/enterprise/admin-partitions) feature included with Consul Enterprise, a cluster may refer to collection of client agents.
## Agents
You can run the Consul binary to start Consul _agents_, which are daemons that implement Consul control plane functionality. You can start agents as servers or clients. Refer to [Consul Agent](/docs/agent) for additional information.
### Server agents
Consul server agents store all state information, including service and node IP addresses, health checks, and configuration. We recommend deploying three or five servers in a cluster. The more servers you deploy, the greater the resilience and availability in the event of a failure. More servers, however, slow down [consensus](#consensus-protocol), which is a critical server function that enables Consul to efficiently and effectively process information.
#### Consensus protocol
Consul clusters elect a single server to be the _leader_ through a process called _consensus_. The leader processes all queries and transactions, which prevents conflicting updates in clusters containing multiple servers.
Servers that are not currently acting as the cluster leader are called _followers_. Followers forward requests from client agents to the cluster leader. The leader replicates the requests to all other servers in the cluster. Replication ensures that if the leader is unavailable, other servers in the cluster can elect another leader without losing any data.
Consul servers establish consensus using the Raft algorithm on port `8300`. Refer to [Consensus Protocol](/docs/architecture/consensus) for additional information.
![Diagram of the Consul control plane consensus traffic](/img/consul-arch/consul-arch-overview-consensus.svg)
### Client agents
Backport of docs: Consul Dataplane updates for v.1.14.0 into release/1.14.x (#15448) * backport of commit 2393183b8b3df4e519298be12468ca97e96e7959 * backport of commit 078037ba89d382ed90eb469a23910c7bd8615b40 * backport of commit b12295a915ef2fc40226481d1db786e8d9bcca8b * backport of commit 1cfeefe7c19371f15ef3366d3c05e14a222ed9d0 * backport of commit a796b1b28d792aec8a804058fae73e6e646b2cee * backport of commit 311bab5546d7030f79e138e535d3d8c57ac8d900 * backport of commit 8f995aa0004076e9d56cf04e8699d5b7422850c8 * backport of commit c77c1fce448eef3039ae2504437d54a8782f955a * backport of commit d45f5c0ab576e7af92b3fd79f8420f7fe9e0f6f0 * backport of commit 795a134e941853968d4f8a514713e7b658acef3a * backport of commit b0475b4f53588de0ce761399293aaf78235aa72e * backport of commit 92b5b4202aede6a6f9940dad2399bc8d9e000d03 * backport of commit fb1c932e4424dbca4c3241848a2cbfd1995a6bbe * backport of commit d24dd81cd04eb0b7bfb6c8ed0353eecffe5362a4 * backport of commit 41a6e193cc9a34425c41959813a46732b5b38b05 * docs: Consul Dataplane updates for v.1.14.0 (#15384) * Consul Architecture update * Consul on Kubernetes architecture * Install Consul on Kubernetes with Helm updates * Vault as the Secrets Backend Data Integration * Kubernetes Service Mesh Overview * Terminating Gateways * Fully updated * Join external service to k8s * Consul on Kubernetes * Configure metrics for Consul on Kubernetes * Service Sync for Consul on Kubernetes * Custom Resource Definitions for Consul on k8s * Upgrading Consul on Kubernetes Components * Rolling Updates to TLS * Dataplanes diagram * Upgrade instructions * k8s architecture page updates * Update website/content/docs/k8s/connect/observability/metrics.mdx Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> * Update website/content/docs/architecture/index.mdx * Update website/content/docs/k8s/connect/terminating-gateways.mdx * CRDs * updating version numbers * Updated example config * Image clean up * Apply suggestions from code review Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Update website/content/docs/k8s/architecture.mdx Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * pic fix Co-authored-by: boruszak <jeffrey.boruszak@hashicorp.com> Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2022-11-17 23:23:00 +00:00
Consul clients report node and service health status to the Consul cluster. In a typical deployment, you must run client agents on every compute node in your datacenter. Clients use remote procedure calls (RPC) to interact with servers. By default, clients send RPC requests to the servers on port `8300`.
There are no limits to the number of client agents or services you can use with Consul, but production deployments should distribute services across multiple Consul datacenters. Using a multi-datacenter deployment enhances infrastructure resilience and limits control plane issues. We recommend deploying a maximum of 5,000 client agents per datacenter. Some large organizations have deployed tens of thousands of client agents and hundreds of thousands of service instances across a multi-datacenter deployment. Refer to [Cross-datacenter requests](#cross-datacenter-requests) for additional information.
Backport of docs: Consul Dataplane updates for v.1.14.0 into release/1.14.x (#15448) * backport of commit 2393183b8b3df4e519298be12468ca97e96e7959 * backport of commit 078037ba89d382ed90eb469a23910c7bd8615b40 * backport of commit b12295a915ef2fc40226481d1db786e8d9bcca8b * backport of commit 1cfeefe7c19371f15ef3366d3c05e14a222ed9d0 * backport of commit a796b1b28d792aec8a804058fae73e6e646b2cee * backport of commit 311bab5546d7030f79e138e535d3d8c57ac8d900 * backport of commit 8f995aa0004076e9d56cf04e8699d5b7422850c8 * backport of commit c77c1fce448eef3039ae2504437d54a8782f955a * backport of commit d45f5c0ab576e7af92b3fd79f8420f7fe9e0f6f0 * backport of commit 795a134e941853968d4f8a514713e7b658acef3a * backport of commit b0475b4f53588de0ce761399293aaf78235aa72e * backport of commit 92b5b4202aede6a6f9940dad2399bc8d9e000d03 * backport of commit fb1c932e4424dbca4c3241848a2cbfd1995a6bbe * backport of commit d24dd81cd04eb0b7bfb6c8ed0353eecffe5362a4 * backport of commit 41a6e193cc9a34425c41959813a46732b5b38b05 * docs: Consul Dataplane updates for v.1.14.0 (#15384) * Consul Architecture update * Consul on Kubernetes architecture * Install Consul on Kubernetes with Helm updates * Vault as the Secrets Backend Data Integration * Kubernetes Service Mesh Overview * Terminating Gateways * Fully updated * Join external service to k8s * Consul on Kubernetes * Configure metrics for Consul on Kubernetes * Service Sync for Consul on Kubernetes * Custom Resource Definitions for Consul on k8s * Upgrading Consul on Kubernetes Components * Rolling Updates to TLS * Dataplanes diagram * Upgrade instructions * k8s architecture page updates * Update website/content/docs/k8s/connect/observability/metrics.mdx Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> * Update website/content/docs/architecture/index.mdx * Update website/content/docs/k8s/connect/terminating-gateways.mdx * CRDs * updating version numbers * Updated example config * Image clean up * Apply suggestions from code review Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Update website/content/docs/k8s/architecture.mdx Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> * pic fix Co-authored-by: boruszak <jeffrey.boruszak@hashicorp.com> Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> Co-authored-by: Riddhi Shah <riddhi@hashicorp.com> Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2022-11-17 23:23:00 +00:00
You can also run Consul with an alternate service mesh configuration that deploys Envoy proxies but not client agents. Refer to [Simplified Service Mesh with Consul Dataplanes](/docs/connect/dataplane) for more information.
## LAN gossip pool
Client and server agents participate in a LAN gossip pool so that they can distribute and perform node [health checks](/docs/discovery/checks). Agents in the pool propagate the health check information across the cluster. Agent gossip communication occurs on port `8301` using UDP. Agent gossip falls back to TCP if UDP is not available. Refer to [Gossip Protocol](/docs/architecture/gossip) for additional information.
The following simplified diagram shows the interactions between servers and clients.
<Tabs>
<Tab heading="LAN gossip pool">
![Diagram of the Consul LAN gossip pool](/img/consul-arch/consul-arch-overview-lan-gossip-pool.svg)
</Tab>
<Tab heading="RPC">
![Diagram of RPC communication between Consul agents](/img/consul-arch/consul-arch-overview-rpc.svg)
</Tab>
</Tabs>
## Cross-datacenter requests
Each Consul datacenter maintains its own catalog of services and their health. By default, the information is not replicated across datacenters. WAN federation and cluster peering are two multi-datacenter deployment models that enable service connectivity across datacenters.
### WAN federation
WAN federation is an approach for connecting multiple Consul datacenters. It requires you to designate a _primary datacenter_ that contains authoritative information about all datacenters, including service mesh configurations and access control list (ACL) resources.
In this model, when a client agent requests a resource in a remote secondary datacenter, a local Consul server forwards the RPC request to a remote Consul server that has access to the resource. A remote server sends the results to the local server. If the remote datacenter is unavailable, its resources are also unavailable. By default, WAN-federated servers send cross-datacenter requests over TCP on port `8300`.
You can configure control plane and data plane traffic to go through mesh gateways, which simplifies networking requirements.
> **Hands-on**: To enable services to communicate across datacenters when the ACL system is enabled, refer to the [ACL Replication for Multiple Datacenters](https://learn.hashicorp.com/tutorials/consul/access-control-replication-multiple-datacenters) tutorial.
#### WAN gossip pool
Servers may also participate in a WAN gossip pool, which is optimized for greater latency imposed by the Internet. The pool enables servers to exchange information, such as their addresses and health, and gracefully handle loss of connectivity in the event of a failure.
In the following diagram, the servers in each data center participate in a WAN gossip pool by sending data over TCP/UDP on port `8302`. Refer to [Gossip Protocol](/docs/architecture/gossip) for additional information.
<Tabs>
<Tab heading="WAN gossip pool">
![Diagram of the Consul LAN gossip pool](/img/consul-arch/consul-arch-overview-wan-gossip-cross-cluster.svg)
</Tab>
<Tab heading="Remote datacenter forwarding">
![Diagram of RPC communication between Consul agents](/img/consul-arch/consul-arch-overview-remote-dc-forwarding-cross-cluster.svg)
</Tab>
</Tabs>
### Cluster peering
You can create peering connections between two or more independent clusters so that services deployed to different datacenters or admin partitions can communicate. An [admin partition](/docs/enterprise/admin-partitions) is a feature in Consul Enterprise that enables you to define isolated network regions that use the same Consul servers. In the cluster peering model, you create a token in one of the datacenters or partitions and configure another datacenter or partition to present the token to establish the connection.
Refer to [What is Cluster Peering?](/docs/connect/cluster-peering) for additional information.