# GitOps

**GitOps**是一种软件交付的运作模型：Git 仓库中保存着对基础设施或应用期望状态的声明式描述，一个自动化控制器持续协调运行中的系统，使其与仓库中的描述保持一致。这个名字由 Git 与“Ops”融合而成，该模型与 [Kubernetes](https://www.edgepedia.org/zh/kubernetes) 关系最为密切——在 Kubernetes 中，控制器监视仓库并将变更拉入集群，而非由外部流水线将变更推入集群。<sup>[1](https://www.aipatternbook.com/gitops)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 该术语由 Weaveworks 首席执行官亚历克西斯·理查森（Alexis Richardson）于 2017 年创造，用以描述该公司如何运营自己的 Kubernetes 集群<sup>[2](https://github.com/readme/featured/defining-gitops)</sup><sup> • </sup><sup>[1](https://www.aipatternbook.com/gitops)</sup> |
| 标准化 | GitOps 工作组于 2020 年在云原生计算基金会（CNCF）下成立；OpenGitOps 原则于 2021 年 10 月发布<sup>[2](https://github.com/readme/featured/defining-gitops)</sup><sup> • </sup><sup>[3](https://www.devopschina.org/?download_id=6160&sdm_process_download=1)</sup> |
| 核心机制 | Git 仓库是期望状态的唯一事实来源；自动化流程使生产环境与之匹配，除 Git 操作外无需人工干预<sup>[4](https://www.gitops.tech/)</sup><sup> • </sup><sup>[5](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/use-cases.html)</sup> |
| 部署方向 | 拉取式：集群从仓库拉取期望状态，不同于传统的推送式 CI/CD 系统<sup>[6](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)</sup> |
| 主流工具 | Argo CD 和 Flux 是专门聚焦于 GitOps 的工具；两者均为 CNCF 项目，Flux 已从 CNCF 毕业<sup>[7](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/comparison.html)</sup><sup> • </sup><sup>[8](https://fluxcd.io/flux/?lang=en)</sup> |
| 采用情况 | 在 2024 年 CNCF 年度调查中（样本量 689），30% 的受访者表示其部分部署实践遵循 GitOps 原则，25% 表示大部分遵循，22% 表示几乎全部遵循<sup>[9](https://www.linuxfoundation.org/hubfs/Research%20Reports/cncf_annual_survey24_031225a.pdf)</sup> |
| 企业案例 | Adobe 的 Flex CI & CD 项目将 GitOps 作为部署的基础，支撑 3,000 多名开发者和 3,000 多个生产服务<sup>[10](https://www.cncf.io/case-studies/adobe/)</sup> |

## 定义与原则

其核心思想是：一个 Git 仓库始终包含对生产环境当前所需基础设施的声明式描述，外加一个自动化流程使生产环境与所描述的状态相匹配。<sup>[4](https://www.gitops.tech/)</sup> 由于期望状态存于版本控制之中，仓库保留了环境随时间变化的完整历史，每一次变更都通过一次 Git 提交完成，可以像代码一样接受审查。<sup>[4](https://www.gitops.tech/)</sup><sup> • </sup><sup>[1](https://www.aipatternbook.com/gitops)</sup>

随着该术语的传播，其用法出现了不一致，理查森便于 2020 年在 CNCF 框架下成立了 GitOps 工作组以确定统一定义。他直言动机：他希望避免 DevOps 和敏捷所遭遇的命运——两者都缺乏清晰的定义。该工作组以“尽可能少的陈述”来定义 GitOps。<sup>[2](https://github.com/readme/featured/defining-gitops)</sup> 2021 年 10 月，工作组发布了 OpenGitOps 原则。第一条原则指出整个系统必须以声明式方式描述；第二条指出期望状态必须以强制不可变性和版本控制的方式存储，并保留完整的版本历史。正如一位工作组成员所说，当人们看到这些原则被列出后，他们意识到基础设施即代码只涵盖了声明式部分，“那是第一条，但还有另外三条原则需要解决”。<sup>[3](https://www.devopschina.org/?download_id=6160&sdm_process_download=1)</sup><sup> • </sup><sup>[2](https://github.com/readme/featured/defining-gitops)</sup>

## 工作原理

GitOps 工作流以持续循环的方式运行，而非一次性部署：

1. 开发者向声明式配置提交变更，通常是 Kubernetes 清单、Helm 软件包或 [Kustomize](https://www.edgepedia.org/zh/kustomize) 叠加配置，变更经审查后合并。<sup>[6](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)</sup>
2. 运行在集群内部或旁边的控制器监视仓库，并在声明状态发生变化时拉取最新状态。<sup>[6](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)</sup>
3. 控制器将 Git 中的期望状态与集群的实际状态进行比较，并施加必要的变更使二者收敛。<sup>[6](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)</sup>

**协调与漂移。** 比较步骤正是 GitOps 与仅仅将配置存入版本控制的区别所在。例如，[Argo CD](https://www.edgepedia.org/zh/argo-cd) 的应用控制器是一个 Kubernetes 控制器，它持续监视运行中的应用，将当前实际状态与仓库中指定的期望目标状态进行比较，检测 `OutOfSync` 状态，并可选择采取纠正措施。<sup>[11](https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/architecture.md)</sup> 这赋予了系统自愈特性：它始终以达成期望状态为目标，在 Git 之外进行的手动变更会被检测到并被回退或标记为漂移。<sup>[12](https://about.gitlab.com/blog/gitops-as-the-evolution-of-operations/)</sup>

**拉取与推送。** 在传统的推送式 CI/CD 系统中，外部流水线持有凭证并将变更推入集群。在 GitOps 的拉取模型中，集群自身从仓库拉取期望状态，因此 CI/CD 平台无需对集群 API 具备入站连接。<sup>[6](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)</sup>

## 起源与管理

Weaveworks 于 2017 年在一篇题为“GitOps：通过拉取请求进行运维”的博客文章中创造了该术语，用以描述团队学到的可靠运营 Kubernetes 的具体方式，包括远程搭建系统和在可用区之间迁移工作负载。<sup>[13](https://cloudogu.github.io/gitops-talks/2022-11-continuous-lifecycle/pdf/GitOps%3A%20It%20this%20something%20for%20me.pdf)</sup><sup> • </sup><sup>[14](https://siliconangle.com/2022/01/20/weaveworks-pioneered-gitops-brought-containers-mainstream-awsshowcases2e1/)</sup> 理查森在 [Pivotal Software](https://www.edgepedia.org/zh/pivotal-software) 担任应用平台负责人后创立了 Weaveworks，使命是让企业开发者更容易进行容器开发——这些开发者发现早期的容器工具在操作上过于复杂。<sup>[14](https://siliconangle.com/2022/01/20/weaveworks-pioneered-gitops-brought-containers-mainstream-awsshowcases2e1/)</sup>

Weaveworks 于 2024 年关停，不再拥有其旧域名。GitOps 现由 CNCF 的 OpenGitOps 工作组管理，该工作组维护着当前的 GitOps 原则。<sup>[4](https://www.gitops.tech/)</sup>

## 工具

AWS 规范性指导比较了九种面向 Kubernetes 的 GitOps 工具：Argo CD、Flux、Weave GitOps、Jenkins X、GitLab CI/CD、Spinnaker、Rancher Fleet、Codefresh 和 [Pulumi](https://www.edgepedia.org/zh/pulumi)。其中，Argo CD 和 Flux 是专门聚焦于 GitOps 的工具，其余工具则在不同程度上采纳了 GitOps 原则；Argo CD、Flux 和 Weave GitOps 侧重于工作流的 CD 环节，通常需要与独立的 CI 工具集成。<sup>[7](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/comparison.html)</sup>

**Argo CD** 是一个面向 Kubernetes 的声明式 GitOps 持续交付工具，支持 Git 仓库、Helm 仓库和 OCI 镜像作为事实来源，并提供自动同步、清理和自愈的同步策略。<sup>[15](https://docs.aws.amazon.com/eks/latest/userguide/argocd.html)</sup> AWS 将其描述为适合重视可视化管理与以应用为中心的工作流的环境，它提供网页界面。<sup>[5](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/use-cases.html)</sup>

**Flux** 由一组 Kubernetes 控制器和自定义资源构成，可与任何 Kubernetes 发行版以及 Kustomize、Helm、RBAC 等常用工具配合使用，并在 Flagger 的帮助下支持通过金丝雀发布、功能开关和 A/B rollout 实现渐进式交付。它是 CNCF 毕业项目，在 CNCF CI/CD 技术雷达上被归类为“采纳”。<sup>[8](https://fluxcd.io/flux/?lang=en)</sup> AWS 将 Flux 定位为适合需要轻量部署、强大多租户能力以及与更广泛的 CNCF 生态系统深度集成的场景。<sup>[5](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/use-cases.html)</sup>

## 采用与实践

2024 年 CNCF 年度调查询问了各组织的部署实践和工具在多大程度上遵循 GitOps 原则（样本量 689）。2024 年，8% 尚未开始，15% 刚刚起步，30% 表示部分实践遵循，25% 表示大部分遵循，22% 表示几乎全部遵循；2023 年对应数字为 8%、20%、28%、25% 和 19%，因此报告实质性或接近完全遵循的比例从 44% 增长到 47%。<sup>[9](https://www.linuxfoundation.org/hubfs/Research%20Reports/cncf_annual_survey24_031225a.pdf)</sup> 另一项 2024 年关于内部开发者门户的调查显示，83% 的受访者已至少部分将 GitOps 实施到其 DevOps 实践中。<sup>[16](https://info.getport.io/hubfs/2024%20state%20of%20internal%20developer%20portals_edited.pdf)</sup>

企业案例研究展示了该模型的大规模应用。Adobe 的 Flex CI & CD 项目将 Git 确立为事实来源，采纳了声明式基础设施和应用定义，并使用自动化协调使运行环境与源代码管理中已批准的状态保持一致，减少了人工干预，防止了[配置漂移](https://www.edgepedia.org/zh/configuration-drift)，并取代了基于队列的部署工作流；GitOps 实践现已成为 Adobe 部署基础设施的标准，支撑 3,000 多名开发者和 3,000 多个生产服务。<sup>[10](https://www.cncf.io/case-studies/adobe/)</sup> 在一个金融科技迁移项目中，GitOps 黄金路径与内部开发者平台相结合，使应用团队能在数小时内而非数周内自助获得生产就绪的基线，同时治理在 30 多个遗留应用中保持一致。<sup>[17](https://ntechlab.io/case-study/how-to-scale-fintech-migrations-a-gitops-golden-path-with-idp/)</sup>

## 与 DevOps 和 CI/CD 的关系

GitOps 是运维实践长期演进的一部分，而非对其的替代。现代 IT 运维的文化变革由 DevOps 和 SRE 方法所描述；自动化可追溯至持续集成；Kubernetes 增加了自愈特性，使系统能够自我维护。在此框架下，GitOps 是将这种自愈自动化与以版本化方式存储描述系统的全部代码并通过明确定义的流程加以应用相结合的名称。<sup>[12](https://about.gitlab.com/blog/gitops-as-the-evolution-of-operations/)</sup>

## References

1. [GitOps, Encyclopedia of Agentic Coding Patterns](https://www.aipatternbook.com/gitops)
2. [What's in a name? Moving GitOps beyond buzzword, GitHub ReadMe](https://github.com/readme/featured/defining-gitops)
3. [OpenGitOps Principles chapter, DevOps China](https://www.devopschina.org/?download_id=6160&sdm_process_download=1)
4. [GitOps is Continuous Deployment for cloud native applications, gitops.tech](https://www.gitops.tech/)
5. [Argo CD and Flux use cases, AWS Prescriptive Guidance](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/use-cases.html)
6. [Flux, AWS Prescriptive Guidance](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/flux.html)
7. [GitOps tools comparison, AWS Prescriptive Guidance](https://docs.aws.amazon.com/prescriptive-guidance/latest/eks-gitops-tools/comparison.html)
8. [Flux Documentation](https://fluxcd.io/flux/?lang=en)
9. [CNCF Annual Survey 2024, Linux Foundation](https://www.linuxfoundation.org/hubfs/Research%20Reports/cncf_annual_survey24_031225a.pdf)
10. [Adobe case study, CNCF](https://www.cncf.io/case-studies/adobe/)
11. [Argo CD architecture documentation, argoproj/argo-cd on GitHub](https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/architecture.md)
12. [GitOps viewed as part of the Ops evolution, GitLab](https://about.gitlab.com/blog/gitops-as-the-evolution-of-operations/)
13. [Origin: blog post by Weaveworks, August 2017 (GitOps: Operations by Pull Request), Cloudogu GitOps Talks](https://cloudogu.github.io/gitops-talks/2022-11-continuous-lifecycle/pdf/GitOps%3A%20It%20this%20something%20for%20me.pdf)
14. [How Weaveworks pioneered GitOps and brought containers into the mainstream, SiliconANGLE](https://siliconangle.com/2022/01/20/weaveworks-pioneered-gitops-brought-containers-mainstream-awsshowcases2e1/)
15. [Continuous Deployment with Argo CD, Amazon EKS documentation](https://docs.aws.amazon.com/eks/latest/userguide/argocd.html)
16. [2024 State of Internal Developer Portals, Port](https://info.getport.io/hubfs/2024%20state%20of%20internal%20developer%20portals_edited.pdf)
17. [How to Scale FinTech Migrations: A GitOps Golden Path with IDP, N-TechLab](https://ntechlab.io/case-study/how-to-scale-fintech-migrations-a-gitops-golden-path-with-idp/)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Build, deployment, and development tooling › Deployment and continuous integration

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/gitops

English original: https://www.edgepedia.org/gitops
