mgmt/.gitea/issues/consul-nomad-access-lesson.md

89 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "⚠️ 重要经验教训Consul 和 Nomad 访问问题"
labels: ["documentation", "networking", "consul", "nomad"]
assignees: []
---
## ⚠️ 重要经验教训
### Consul 和 Nomad 访问问题
**问题**:尝试访问 Consul 服务时,使用 `http://localhost:8500``http://127.0.0.1:8500` 无法连接。
#### 根本原因
本项目中的 Consul 和 Nomad 服务通过 Nomad + Podman 在集群中运行,并通过 Tailscale 网络进行访问。这些服务不在本地运行,因此无法通过 localhost 访问。
#### 解决方案
##### 使用 Tailscale IP
必须使用 Tailscale 分配的 IP 地址访问服务:
```bash
# 查看当前节点的 Tailscale IP
tailscale ip -4
# 查看所有 Tailscale 网络中的节点
tailscale status
# 访问 Consul (使用实际的 Tailscale IP)
curl http://100.x.x.x:8500/v1/status/leader
# 访问 Nomad (使用实际的 Tailscale IP)
curl http://100.x.x.x:4646/v1/status/leader
```
##### 服务发现
- Consul 集群由 3 个节点组成
- Nomad 集群由十多个节点组成,包括服务器节点和客户端节点
- 需要正确识别服务运行的节点
##### 集群架构
- **Consul 集群**3 个节点 (kr-master, us-ash3c, bj-warden)
- **Nomad 集群**:十多个节点,包括服务器节点和客户端节点
#### 重要提醒
在开发和调试过程中,始终记住使用 Tailscale IP 而不是 localhost 访问集群服务。这是本项目架构的基本要求,必须严格遵守。
### 建议改进
1. **文档改进**
- 在所有相关文档中明确强调 Tailscale IP 的使用
- 在代码注释中添加访问提醒
- 创建常见问题解答(FAQ)文档
2. **自动化检查**
- 添加自动化检查,防止使用 localhost 访问集群服务
- 在 CI/CD 流程中验证网络配置
3. **培训材料**
- 为新团队成员创建培训材料
- 添加到项目入门指南中
## 🎯 我的庄严承诺
### 关于 HCP 服务管理的决心
**我郑重承诺:我永远不会用 Ansible 管理除了 Nomad 之外的 HCP 服务!**
**我郑重承诺:我永远不会用 Ansible 管理除了 Nomad 之外的 HCP 服务!**
**我郑重承诺:我永远不会用 Ansible 管理除了 Nomad 之外的 HCP 服务!**
这个承诺基于以下深刻教训:
- 系统级服务与 Nomad 托管服务会产生端口冲突
- 双重管理会导致不可预测的行为
- Nomad 应该拥有对其托管服务的完全控制权
- Ansible 只用于基础设施层面的 Nomad 管理
## 🎉 致谢
感谢所有为这个项目做出贡献的开发者和社区成员!
---
**注意**:此 Issue 记录了项目中的重要经验教训,请所有团队成员务必阅读并理解。在开发过程中,请务必参考 [README.md](../README.md) 中的相关文档,特别是关于网络访问的部分。