--- id: ctp-topic-33-an-introduction-to-gitops title: "CTP Topic 33 An introduction to GitOps" type: source tags: [GitOps, CI/CD, DevOps, CTP] sources: [raw/Cloud & DevOps/Public-Cloud-Learning-Sessions/06_CI_CD_GitOps/ctp-topic-33-an-introduction-to-gitops.md] last_updated: 2026-04-19 --- ## Source File - [[raw/Cloud & DevOps/Public-Cloud-Learning-Sessions/06_CI_CD_GitOps/ctp-topic-33-an-introduction-to-gitops.md]] ## Summary - 核心主题:GitOps(一种将软件开发原则应用于部署流程的方法论) - 问题域:解决传统部署中的失败部署、配置不一致、审计困难等问题 - 方法/机制:基于 Git 的声明式配置、CD 流水线、基础设施即代码,通过 GitOps Controller 协调期望状态与实际状态 - 结论/价值:提升开发生产力、最小化失败部署、实现快速发布、实时审计和改进安全性 ## Key Claims - GitOps 通过使用开发者熟悉的工具提升开发生产力 - GitOps 可最大限度减少失败部署,通过轻松的回滚能力 - GitOps 支持更快的功能发布 - GitOps 通过 Git 特性实现实时审计和改进安全性 - Git 是开发者唯一需要知道的工具 - CI 和 CD 应该解耦以增强安全性 - GitOps 的拉取模型(Pull Model)监控 Git 和目标系统,推荐用于 GitOps ## Key Quotes > "GitOps applies software development principles to deployment processes, potentially resolving challenges like failed deployments and configuration inconsistencies." > "The only tool a developer needs to know is Git." > "An IDEMPOTENT operation is one that can be applied multiple times without changing the result beyond the initial application." > "GitOps is a logical evolution of DevOps, simplifying adoption and enhancing portability." ## Key Concepts - [[GitOps]]:将软件开发原则应用于部署流程的方法论 - [[Declarative Configuration]](声明式配置):以声明形式定义系统期望状态而非具体步骤 - [[Infrastructure as Code]](基础设施即代码):通过代码管理基础设施的实践 - [[CD Pipeline]](持续交付流水线):自动化部署流程 - [[GitOps Controller]]:协调 Git 状态与实际系统状态的代理 - [[Pull Model]](拉取模型):GitOps 推荐的 CD 实现模式,监控 Git 和目标系统 - [[Push Model]](推送模型):传统的 CI/CD 部署模式 - [[Idempotent Operation]](幂等操作):可多次应用而不改变结果的操怍 ## Key Entities - [[Victor Etkin]]:本次分享的演讲者,介绍 GitOps 概念 ## Connections - [[DevOps]] ← extends ← [[GitOps]] - [[CI/CD]] ← uses ← [[GitOps]] - [[Kubernetes]] ← often_used_with ← [[GitOps]] - [[Infrastructure as Code]] ← implements ← [[GitOps]] ## Contradictions - 无 ## Four Principles of GitOps 1. **Declarative Configuration**(声明式配置):系统以声明形式定义 2. **Version Control**(版本控制):所有配置存储在 Git 中 3. **CD Process Separation**(CD 流程分离):CI 和 CD 解耦 4. **Incremental Infrastructure**(增量基础设施):渐进式实施基础设施 ## GitOps Workflow (Kubernetes) 1. 开发者提交代码 2. 创建容器镜像 3. 将部署配置存储在 Git 中 4. GitOps Agent 监控变化 5. 向环境推出镜像