Auto-sync: update nexus workspace

This commit is contained in:
2026-04-29 15:44:38 +08:00
parent b2aadf771a
commit c961c6a394
114 changed files with 4784 additions and 1334 deletions

View File

@@ -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 AgentArgoCDFlux)同时监控 Git 仓库和目标系统
- Agent 通过 Pull 方式主动检测变更,无需外部系统推送
- 安全性更高,符合零信任原则
### Push Model
- CI/CD 流水线(如 Jenkins、GitHub Actions在代码变更后主动推送到目标环境
- 配置相对简单,但安全性较低
## Tooling Ecosystem
| Tool | Role | Model |
|------|------|-------|
| [[Atlantis]] | Terraform 自动化 Plan/Apply | PullPR-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 实践