consul

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Consul

Consul

HashiCorp Consul is a multi-cloud service networking platform. It handles Service Discovery, Mesh, and Key/Value storage. 2025 v1.18 focuses on Enterprise reliability.
HashiCorp Consul是一个多云服务网络平台,它负责处理Service Discovery(服务发现)、Mesh(服务网格)以及Key/Value(键值对)存储。2025年的v1.18版本重点关注企业级可靠性。

When to Use

使用场景

  • Service Discovery: Tracking dynamic IPs of microservices (common in Nomad/VM setups).
  • Service Mesh: mTLS and Traffic split across VMs and K8s.
  • KV Store: Storing dynamic configuration distributed across regions.
  • Service Discovery(服务发现):追踪微服务的动态IP(在Nomad/VM环境中较为常见)。
  • Service Mesh(服务网格):在VM和K8s之间实现mTLS和流量拆分。
  • KV Store(键值存储):存储跨区域分布的动态配置。

Core Concepts

核心概念

Agent

Agent

Runs on every node (client mode) or dedicated servers (server mode). Handles health checks.
在每个节点(客户端模式)或专用服务器(服务器模式)上运行,负责健康检查。

Service Definition

服务定义

Register services via Config file or API.
{"service": {"name": "web", "port": 80}}
通过配置文件或API注册服务。
{"service": {"name": "web", "port": 80}}

Connect (Mesh)

Connect(Mesh)

Uses Envoy to secure traffic between services.
使用Envoy来保障服务间的通信安全。

Best Practices (2025)

2025年最佳实践

Do:
  • Use DNS Interface: Apps can find DBs via
    db.service.consul
    .
  • Use Template:
    consul-template
    renders config files from KV data and reloads apps automatically.
  • Separate Data Centers: Federation allows global service discovery.
Don't:
  • Don't expose API publicly: Consul has no default auth in dev mode. Lock it down.
建议
  • 使用DNS接口:应用可通过
    db.service.consul
    找到数据库。
  • 使用Template工具
    consul-template
    可根据KV数据渲染配置文件,并自动重新加载应用。
  • 分离数据中心:联邦机制支持全局服务发现。
不建议
  • 不要公开暴露API:Consul在开发模式下没有默认认证,需做好安全防护。

References

参考资料