2.5 KiB
2.5 KiB
title, type, sources, last_updated
| title | type | sources | last_updated | |||
|---|---|---|---|---|---|---|
| CI/CD Pipeline | concept |
|
2026-04-14 |
Definition
CI/CD 流水线(CI/CD Pipeline)是持续集成(Continuous Integration)和持续交付/部署(Continuous Delivery/Deployment)的自动化流程,用于管理基础设施代码(IaC)的构建、测试和部署。在 Gruntwork Landing Zone 架构中,每个 Landing Zone 配置独立的 Jenkins 服务器和 CI/CD 流水线来自动化 Terraform 基础设施变更。
Core Components
CI(持续集成)
- 代码提交:开发人员将特性分支代码推送到 GitHub 仓库
- 自动构建:Jenkins 触发 Terraform 初始化和格式化验证
- 自动测试:TerraTest 执行基础设施单元测试和集成测试
- 代码审查:Pull Request 必须通过审查才能合并到主分支
CD(持续交付/部署)
- 自动部署:合并到主分支后,Jenkins 自动执行 Terraform Plan
- 审批流程:变更需要人工审批后才执行 Apply
- 渐进式部署:支持 Blue-Green 部署和 Canary Release 策略
Infrastructure-Specific Considerations
- 状态管理:Terraform State 的锁定和远程存储(使用 S3 + DynamoDB)
- 幂等性:Terraform 模块设计必须支持重复执行而不产生副作用
- 回滚机制:通过 Terraform State 历史版本实现快速回滚
- 漂移检测:定期运行
terraform plan检测配置漂移
Tools in Gruntwork Landing Zone Context
- Jenkins:核心 CI/CD 引擎,每个 Landing Zone 独立部署
- Terraform:IaC 工具,定义和管理 AWS 资源
- TerraTest:Go 语言编写的基础设施测试框架
- GitHub:代码仓库,支持特性分支和 Pull Request 工作流
Git Workflow
- 特性分支开发:
feature/<description> - 通过 Pull Request 合并到主分支
- 必须经过代码审查和 CI 测试
- 合并后触发自动部署流水线
Related Concepts
- Landing-Zone-Architecture:CI/CD 流水线是 Landing Zone 自动化运维的核心机制
- Terraform-Modules:被 CI/CD 流水线自动化部署的 IaC 模块
- GitOps:基于 Git 的运维方式,CI/CD 是其技术实现
- TerraTest:用于基础设施变更的自动化测试工具