更新README文件以反映当前项目结构和GitOps原则

This commit is contained in:
Houzhong Xu 2025-09-28 05:53:01 +00:00
parent 8d45dec614
commit 90f9fac6a9
No known key found for this signature in database
GPG Key ID: B44BEB1438F1B46F
1 changed files with 46 additions and 19 deletions

View File

@ -25,17 +25,43 @@ mgmt/
├── configuration/ # Ansible 配置管理 ├── configuration/ # Ansible 配置管理
│ ├── inventories/ # 主机清单 │ ├── inventories/ # 主机清单
│ ├── playbooks/ # 剧本 │ ├── playbooks/ # 剧本
│ ├── roles/ # 角色 │ ├── templates/ # 模板文件
│ └── group_vars/ # 组变量 │ └── group_vars/ # 组变量
├── monitoring/ # 监控配置 ├── jobs/ # Nomad 作业定义
├── scripts/ # 自动化脚本 │ ├── consul/ # Consul 集群配置
│ ├── setup/ # 环境设置脚本 │ └── podman/ # Podman 相关作业
│ └── utilities/ # 实用工具脚本 ├── configs/ # 配置文件
├── mgmt.sh # 项目管理主脚本 │ ├── nomad-master.hcl # Nomad 主节点配置
└── Makefile # 项目管理命令 │ └── nomad-ash3c.hcl # Nomad 客户端配置
├── docs/ # 文档
├── security/ # 安全配置
│ ├── certificates/ # 证书文件
│ └── policies/ # 安全策略
├── tools/ # 工具和实用程序
├── playbooks/ # 核心Ansible剧本
└── Makefile # 项目管理命令
``` ```
**注意:** 项目已从 Docker Swarm 迁移到 Nomad + Podman原有的 swarm 目录已不再使用。 **注意:** 项目已从 Docker Swarm 迁移到 Nomad + Podman原有的 swarm 目录已不再使用。所有中间过程脚本和测试文件已清理保留核心配置文件以符合GitOps原则。
## 🔄 GitOps 原则
本项目遵循 GitOps 工作流,确保基础设施状态与 Git 仓库中的代码保持一致:
- **声明式配置**: 所有基础设施和应用程序配置都以声明式方式存储在 Git 中
- **版本控制和审计**: 所有变更都通过 Git 提交,提供完整的变更历史和审计跟踪
- **自动化同步**: 通过 CI/CD 流水线自动将 Git 中的变更应用到实际环境
- **状态收敛**: 系统会持续监控实际状态,并自动修复任何与期望状态的偏差
### GitOps 工作流程
1. **声明期望状态**: 在 Git 中定义基础设施和应用程序的期望状态
2. **提交变更**: 通过 Git 提交来应用变更
3. **自动同步**: CI/CD 系统检测到变更并自动应用到环境
4. **状态验证**: 系统验证实际状态与期望状态一致
5. **监控和告警**: 持续监控状态并在出现偏差时发出告警
这种工作流确保了环境的一致性、可重复性和可靠性,同时提供了完整的变更历史和回滚能力。
## 🚀 快速开始 ## 🚀 快速开始
@ -80,7 +106,7 @@ cd tofu/environments/dev && tofu apply
```bash ```bash
# 部署 Consul 集群 # 部署 Consul 集群
nomad run /root/mgmt/consul-cluster-nomad.nomad nomad run /root/mgmt/jobs/consul/consul-cluster.nomad
# 查看 Nomad 任务 # 查看 Nomad 任务
nomad job status nomad job status
@ -93,14 +119,14 @@ nomad node status
| 命令 | 描述 | | 命令 | 描述 |
|------|------| |------|------|
| `./mgmt.sh status` | 显示项目状态总览 | | `make status` | 显示项目状态总览 |
| `./mgmt.sh deploy` | 快速部署所有服务 | | `make deploy` | 快速部署所有服务 |
| `./mgmt.sh cleanup` | 清理所有部署的服务 | | `make cleanup` | 清理所有部署的服务 |
| `./mgmt.sh tofu <cmd>` | OpenTofu 管理命令 | | `cd tofu/environments/dev && tofu <cmd>` | OpenTofu 管理命令 |
| `nomad job status` | 查看 Nomad 任务状态 | | `nomad job status` | 查看 Nomad 任务状态 |
| `nomad node status` | 查看 Nomad 节点状态 | | `nomad node status` | 查看 Nomad 节点状态 |
| `podman ps` | 查看运行中的容器 | | `podman ps` | 查看运行中的容器 |
| `scripts/setup/setup-opentofu.sh help` | OpenTofu 设置帮助 | | `ansible-playbook playbooks/configure-nomad-clients.yml` | 配置 Nomad 客户端 |
## 🌩️ 支持的云服务商 ## 🌩️ 支持的云服务商
@ -191,11 +217,12 @@ nomad node status
## 📚 文档 ## 📚 文档
- [架构概览](docs/architecture/project-overview.md) - [Consul集群故障排除](docs/consul-cluster-troubleshooting.md)
- [部署指南](docs/runbooks/deployment-guide.md) - [磁盘管理](docs/disk-management.md)
- [运维手册](docs/runbooks/operations-guide.md) - [Nomad NFS设置](docs/nomad-nfs-setup.md)
- [故障排除](docs/runbooks/troubleshooting.md) - [Consul-Terraform集成](docs/setup/consul-terraform-integration.md)
- [API 文档](docs/api/README.md) - [OCI凭据设置](docs/setup/oci-credentials-setup.md)
- [Oracle云设置](docs/setup/oracle-cloud-setup.md)
## 🤝 贡献指南 ## 🤝 贡献指南