Auto-sync: update nexus workspace
This commit is contained in:
@@ -1,44 +1,79 @@
|
||||
---
|
||||
title: "GitOps"
|
||||
type: concept
|
||||
tags:
|
||||
- DevOps
|
||||
- CI/CD
|
||||
- Kubernetes
|
||||
- Infrastructure as Code
|
||||
---
|
||||
|
||||
## Definition
|
||||
GitOps 是一种将软件开发的版本控制与协作原则应用于云原生基础设施和应用部署的方法论。核心思想:**使用 Git 作为单一事实来源(Single Source of Truth)声明系统的期望状态,由自动化代理(GitOps Controller)持续协调实际状态向期望状态收敛。**
|
||||
|
||||
## Four Principles
|
||||
1. **声明式配置(Declarative Configuration)**:所有基础设施和应用配置必须以声明式代码描述,而非命令式脚本
|
||||
2. **版本控制(Version Control)**:所有配置存储在 Git 仓库中,享受完整的变更历史、代码审查和回滚能力
|
||||
3. **CD 流程分离(CD Process Separation)**:CI 专注构建和分析代码,CD 专注部署,两者解耦增强安全性
|
||||
4. **自修复协调器(Automated Reconciliation)**:GitOps Controller 持续监控实际状态与 Git 声明状态,自动调和偏差
|
||||
|
||||
## Key Benefits
|
||||
- 开发者只需掌握 Git 即可完成安全部署
|
||||
- 分钟级代码变更上线
|
||||
- 零停机回滚(Git 历史即回滚计划)
|
||||
- Git 提交日志天然构成合规审计追踪
|
||||
- 提高开发者生产力(使用熟悉的工具)
|
||||
|
||||
## Pull Model vs Push Model
|
||||
|
||||
| | Pull Model(推荐) | Push Model |
|
||||
|---|---|---|
|
||||
| 机制 | 部署代理主动监控 Git 和目标系统 | CI/CD 管道主动推送变更到目标 |
|
||||
| 安全性 | 更高——系统状态不暴露给外部 | 较低——需外部访问目标系统 |
|
||||
| 代表工具 | ArgoCD, Flux | Jenkins CI/CD, Terraform Cloud |
|
||||
| 适用场景 | GitOps 核心模式 | 传统 CI/CD 扩展 |
|
||||
|
||||
## Relationship with IaC
|
||||
GitOps 是 [[Infrastructure as Code]] 的部署编排层:
|
||||
- **IaC**:定义"基础设施应该是什么样的"(Terraform/Pulumi/HCL)
|
||||
- **GitOps**:定义"如何确保基础设施始终符合声明"(ArgoCD/Flux/Atlantis)
|
||||
|
||||
## Sources
|
||||
- [[ctp-topic-33-an-introduction-to-gitops]] — GitOps 方法论入门,Victor Etkin 主讲
|
||||
- [[ctp-topic-32-using-atlantis-cicd-for-infrastructure-deployments]] — Atlantis 作为 GitOps 工具实践
|
||||
- [[ctp-topic-9-ci-cd-with-gruntwork]] — Gruntwork CI/CD 与 GitOps 的关联
|
||||
---
|
||||
title: "GitOps"
|
||||
type: concept
|
||||
tags:
|
||||
- GitOps
|
||||
- IaC
|
||||
- DevOps
|
||||
- CD
|
||||
sources:
|
||||
- ctp-topic-32-using-atlantis-cicd-for-infrastructure-deployments
|
||||
- ctp-topic-33-an-introduction-to-gitops
|
||||
- ctp-topic-9-ci-cd-with-gruntwork
|
||||
last_updated: 2026-04-29
|
||||
---
|
||||
|
||||
# GitOps
|
||||
|
||||
## Definition
|
||||
|
||||
GitOps 是将软件开发原则(尤其是 Git 版本控制)应用于基础设施和应用程序部署的方法论。其核心思想是:**将 Git 仓库作为声明式配置的单一事实来源(Single Source of Truth),通过自动化机制确保实际环境与 Git 中声明的期望状态保持一致。**
|
||||
|
||||
## Core Principles
|
||||
|
||||
1. **Declarative Configuration(声明式配置)**
|
||||
所有基础设施和应用配置以声明式语言(如 Terraform HCL、Kubernetes YAML)描述,而非命令式步骤。
|
||||
|
||||
2. **Version Control(版本控制)**
|
||||
所有配置存储在 Git 仓库中,享受版本历史、代码审查(Pull Request)和回滚能力。
|
||||
|
||||
3. **Automated CD(自动化持续交付)**
|
||||
CI 专注代码构建和分析,CD 专注部署;两者解耦,增强安全性和可靠性。
|
||||
|
||||
4. **Self-Healing(自修复协调)**
|
||||
GitOps Controller 持续监控实际状态与 Git 声明状态,自动调和偏差(drift correction)。
|
||||
|
||||
## Architecture Patterns
|
||||
|
||||
### Pull Model(推荐)
|
||||
- GitOps Agent(如 ArgoCD、Flux)同时监控 Git 仓库和目标系统
|
||||
- Agent 通过 Pull 方式主动检测变更,无需外部系统推送
|
||||
- 安全性更高,符合零信任原则
|
||||
|
||||
### Push Model
|
||||
- CI/CD 流水线(如 Jenkins、GitHub Actions)在代码变更后主动推送到目标环境
|
||||
- 配置相对简单,但安全性较低
|
||||
|
||||
## Tooling Ecosystem
|
||||
|
||||
| Tool | Role | Model |
|
||||
|------|------|-------|
|
||||
| [[Atlantis]] | Terraform 自动化 Plan/Apply | Pull(PR-based)|
|
||||
| ArgoCD | Kubernetes 应用部署 | Pull |
|
||||
| Flux | Kubernetes 持续交付 | Pull |
|
||||
| Terraform Cloud/Enterprise | Terraform 协作与状态管理 | Hybrid |
|
||||
|
||||
## GitOps vs Traditional CI/CD
|
||||
|
||||
| Dimension | Traditional CI/CD | GitOps |
|
||||
|-----------|------------------|--------|
|
||||
| Source of Truth | Pipeline definition | Git repository |
|
||||
| Trigger | Push to repo | Automated pull + diff detection |
|
||||
| State Drift Detection | Manual or periodic | Continuous automatic |
|
||||
| Rollback | Manual or scripted | Git revert + auto-sync |
|
||||
| Audit Trail | Build logs | Git commit history |
|
||||
| Security Model | Token-based push | Agent has minimal permissions |
|
||||
|
||||
## Related Concepts
|
||||
- [[Infrastructure as Code (IaC)]]:GitOps 的核心技术基础
|
||||
- [[CI/CD Pipeline]]:GitOps 的前身和组成部分
|
||||
- [[Terraform]]:主流 IaC 工具,Atlantis 是其 GitOps 工具
|
||||
|
||||
## Related Entities
|
||||
- [[Atlantis]]:Terraform GitOps 的核心工具实现
|
||||
- [[Jenkins]]:传统 CI/CD 模式(非 GitOps 原生)
|
||||
|
||||
## Related Sources
|
||||
- [[ctp-topic-32-using-atlantis-cicd-for-infrastructure-deployments]] — Atlantis 工具实践层
|
||||
- [[ctp-topic-33-an-introduction-to-gitops]] — GitOps 概念层(Victor Etkin 讲解)
|
||||
- [[ctp-topic-9-ci-cd-with-gruntwork]] — Gruntwork CI/CD 实践
|
||||
|
||||
Reference in New Issue
Block a user