53 lines
2.3 KiB
Markdown
53 lines
2.3 KiB
Markdown
---
|
||
title: "GitOps"
|
||
type: concept
|
||
tags: [DevOps, Git, 基础设施, 部署]
|
||
sources: [DevOps-Culture-and-Transformation.md, ctp-topic-33-an-introduction-to-gitops.md]
|
||
last_updated: 2026-04-19
|
||
---
|
||
|
||
## Definition
|
||
GitOps 是一种使用 Git 作为单一真相源(Single Source of Truth)来管理基础设施和部署的文化理念和运维框架,所有配置和部署声明都存储在 Git 仓库中。它是 DevOps 的逻辑演进,将软件开发原则应用于部署流程。
|
||
|
||
## Key Principles(四大原则)
|
||
1. **Declarative Configuration**(声明式配置):系统以声明形式定义,描述期望状态而非具体步骤
|
||
2. **Version Control**(版本控制):所有配置存储在 Git 中,实现版本管理和审计追踪
|
||
3. **CD Process Separation**(CD 流程分离):CI 和 CD 解耦以增强安全性
|
||
4. **Incremental Infrastructure**(增量基础设施):渐进式实施基础设施变更
|
||
|
||
## Core Benefits(核心优势)
|
||
- 使用开发者熟悉的工具提升开发生产力
|
||
- 通过轻松的回滚能力最小化失败部署
|
||
- 支持更快的功能发布
|
||
- 通过 Git 特性实现实时审计和改进安全性
|
||
|
||
## Key Components(核心组件)
|
||
- **Git**:存储部署基础设施和应用配置,作为唯一真相源
|
||
- **GitOps Controller**:协调 Git 状态与实际系统状态的代理
|
||
- **CD Pipeline**:自动化部署流程
|
||
- **Infrastructure as Code**:通过代码管理基础设施
|
||
|
||
## Implementation Models(实现模型)
|
||
- **Pull Model**(拉取模型):GitOps 推荐模型,监控 Git 和目标系统,自动同步变更
|
||
- **Push Model**(推送模型):传统 CI/CD 部署模式,通过触发器推送变更
|
||
|
||
## Kubernetes Workflow
|
||
1. 开发者提交代码
|
||
2. 创建容器镜像
|
||
3. 将部署配置存储在 Git 中
|
||
4. GitOps Agent 监控变化
|
||
5. 向环境推出镜像
|
||
|
||
## Key Concepts
|
||
- [[Declarative Configuration]](声明式配置)
|
||
- [[Infrastructure as Code (IaC)]](基础设施即代码)
|
||
- [[CI/CD 流水线]]
|
||
- [[Pull Model]](拉取模型)
|
||
- [[Idempotent Operation]](幂等操作)
|
||
|
||
## Related Entities
|
||
- [[Victor Etkin]] — GitOps 概念的演讲者和布道者
|
||
|
||
## Related Sources
|
||
- [[ctp-topic-33-an-introduction-to-gitops]] — GitOps 入门介绍
|
||
- [[DevOps-Culture-and-Transformation]] — DevOps 文化转型 |