Loading [MathJax]/jax/input/TeX/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >基于ArgoCD的GitOps转型实战经验

基于ArgoCD的GitOps转型实战经验

作者头像
DevOps云学堂
发布于 2022-12-29 09:14:15
发布于 2022-12-29 09:14:15
5160
举报
文章被收录于专栏:DevOps持续集成DevOps持续集成

image.png

TABLE OF CONTENTS

  • Some bit of context 背景
  • Initial setup 初始设置
  • How we got there 如何到达
  • ArgoCD removed pain points 解决痛点
  • Final words 结语

GitOps is a modern way to manage cloud-native systems that are powered by Kubernetes. It leverages a policy-as-code approach to define and manage every layer of the modern application stack - infrastructure, networking, application code, and the GitOps pipeline itself. GitOps 是一种管理由 Kubernetes 提供支持的云原生系统的现代方式。它利用策略即代码方法来定义和管理现代应用程序堆栈的每一层 - 基础架构、网络、应用程序代码和 GitOps 管道本身。 -- Weaveworks

GitOps as a concept was established in 2017 by Weaveworks and has since been widely adopted in software delivery with a growing number of CNCF tools being developed around it. GitOps 作为一个概念由 Weaveworks 于 2017 年建立,此后在软件交付中被广泛采用,围绕它开发了越来越多的 CNCF 工具。

image.png

While at AirQo, I've had the opportunity of working in both traditional and GitOps environments and in this article, I share experience from a DevOps perspective after having made the shift in our delivery pipeline. 在AirQo 工作期间,我有机会在传统环境和 GitOps 环境中工作,在本文中,我从 DevOps 的角度分享了在我们的交付管道中做出转变后的经验。

Some bit of context 一些背景

AirQo is a cleantech startup whose vision is clean air for all African cities. A key duty in getting there is availing our users with Africa's air quality information and so we have a number software products ranging from mobile applications, web applications, and an API just for that. Our API relies on a couple of microservices in the backend to transform the Particulate Matter(PM) data collected by our air quality monitors into consumption-ready information. We run our microservices on some few Kubernetes(k8s) clusters. AirQo是一家清洁技术初创公司,其愿景是为所有非洲城市提供清洁空气。实现这一目标的一项关键职责是让我们的用户获得非洲的空气质量信息,因此我们有许多软件产品,包括移动应用程序、Web 应用程序和 API。我们的 API 依赖于后端的几个微服务,将空气质量监测器收集的颗粒物 (PM) 数据转换为可供消费的信息。我们在一些 Kubernetes(k8s) 集群上运行我们的微服务。

We use a Gitflow worflow in our mono-repository with all the products and the corresponding k8s manifests in the same repo. 我们在单存储库中使用 Gitflow worflow,所有产品和相应的 k8s 清单都在同一存储库中。

Initial setup 初始设置

In the early days, our continuous delivery pipeline had both the integration and deployment done by the same tool, GitHub Actions. All application images pointed to the "latest" tag in within k8s configurations thus it was the de facto for all applications restarts. GitHub Actions built and pushed the images to Google Container Registry(GCR), but was did not update the corresponding k8s manifest with the new image tag despite the fact that it was the uniquely identifiable image tag(e.g prod-docs-123abc). This meant that the deployed state was always divergent from the state on GitHub at the image tag level at least. Some of the challenges we faced include;

在早期,我们的持续交付管道由同一工具 GitHub Actions 完成集成和部署。所有应用程序映像都指向 k8s 配置中的“latest”标记,因此它是所有应用程序重新启动的事实。GitHub Actions 构建了图像并将其推送到 Google Container Registry(GCR),但没有使用新的图像标签更新相应的 k8s 清单,尽管它是唯一可识别的图像标签(例如 prod-docs-123abc)。这意味着部署状态至少在图像标记级别始终与 GitHub 上的状态不同。我们面临的一些挑战包括:

1.Difficulty in telling the actual resource definition of applications on the cluster.难以分辨群集上应用程序的实际资源定义。

There were times when quick/minor fixes were made to applications directly through kubectl without going through the git workflow. It was difficult for the rest of the team to know of such changes given that they were rarely communicated or committed to GitHub. Not to mention that the image tag was obviously one of such application properties we weren't sure about. 有时,直接通过 kubectl 对应用程序进行快速/次要修复,而无需通过 git 工作流。团队的其他成员很难知道这些更改,因为它们很少被传达或提交到 GitHub。更不用说图像标签显然是我们不确定的应用程序属性之一。

2.The development team lacked visibility into their applications. 开发团队缺乏对其应用程序的可见性。

Most development team members weren't conversant with k8s and kubectl commands to for instance view live application logs whenever need arose. This made troubleshooting unnecessarily a step longer given since a DevOps engineer was needed to retrieve the logs and thus, 大多数开发团队成员不熟悉 k8s 和 kubectl 命令,例如在需要时查看实时应用程序日志。这使得故障排除不必要地延长了一步,因为需要 DevOps 工程师来检索日志.

3.A larger workload for the operations team given that it was an operations-centric approach. 运营团队的工作量更大,因为它是以运营为中心的方法。

4.Operations engineers always had to have access to the clusters via a kubeconfig in order to carry out even very basic tasks. 运营工程师始终必须通过 kubeconfig 访问集群,以便执行非常基本的任务。

5.Rolling back changes was more technical than necessary. Given that we defaulted to the latest tag on GitHub. A DevOps engineer had to get the image tag of a previous application version from GCR, then run a command to update the application image tag with a previous one.kubectl patch 回滚更改的技术性比必要的要多。鉴于我们默认为 GitHub 上的最新标签。DevOps 工程师必须从 GCR 获取以前应用程序版本的映像标记,然后运行命令以使用以前的应用程序映像标记更新应用程序映像标记。kubectl patch


How we got there 我们如何实现目标

A mono-repository setup can present some challenges and we faced one ourselves with the different products' delivery pipelines to production getting intertwined; deeming it impossible to deploy a specific product at a time. The CI/CD pipelines were all dependent on the git workflow and thus had the same trigger. Perhaps I can discuss how we went about in another article but during my search for an alternative autonomous trigger, is when I landed on ArgoCD. Up until then, I had miniature knowledge of GitOps but I found it interesting as I read about it. Fascinated by how the methodology would address many challenges we faced, I instantly installed ArgoCD on one of our clusters. Due to it's multi-tenant nature, I was able to add setup applications in the different clusters and their respective projects under one roof: and subsequently on boarded the entire team onto it. We now use ArgoCD as our deploy operator but kept GitHub Actions as our CI tool and Config Updater for image tags on Helm(which we defaulted to).

单一存储库设置可能会带来一些挑战,我们自己也面临着一个挑战,不同产品的交付管道到生产环境交织在一起;认为不可能一次部署特定产品。CI/CD 管道都依赖于 git 工作流,因此具有相同的触发器。也许我可以在另一篇文章中讨论我们是如何进行的,但是在我寻找替代自主触发器的过程中,是我使用ArgoCD的时候。在那之前,我对 GitOps 有微缩的了解,但当我读到它时,我发现它很有趣。我对该方法如何解决我们面临的许多挑战着迷,我立即在我们的一个集群上安装了ArgoCD。由于它的多租户性质,我能够在一个屋檐下添加不同集群及其各自项目中的设置应用程序:随后将整个团队加入其中。我们现在使用 ArgoCD 作为我们的部署operator,但保留了 GitHub Actions 作为我们的 CI 工具和 Helm 上图像标签的配置更新程序(我们默认使用)。

ArgoCD removed pain points ArgoCD消除了痛点

1.With ArgoCD, we are notified via slack whenever the state of the deployed application diverges from the state on GitHub. The states are also automatically synced to match the GitHub definition in line with the GitOps principle of Git as the source of truth. This ensures that changes are documented on GitHub as a bare minimum. 使用 ArgoCD,每当部署的应用程序的状态与 GitHub 上的状态不同时,我们都会通过 slack 收到通知。状态也会自动同步以匹配 GitHub 定义,符合 Git 作为事实来源的 GitOps 原则。这可确保更改至少记录在 GitHub 上。

2.The development team is now able to self serve on anything to do with their applications. The ArgoCD UI is so intuitive that they can carry out tasks ranging from creating new applications to accessing logs of existing ones without assistance from the operations team. A more developer-centric approach. 开发团队现在可以自助处理与其应用程序相关的任何事情。ArgoCD UI非常直观,他们可以在没有运营团队帮助的情况下执行从创建新应用程序到访问现有应用程序日志的各种任务。一种更加以开发人员为中心的方法。

3.Rollbacks are now much easier. It's now a matter of reverting changes on the GitHub repo and an older image tag will be deployed automatically. 回滚现在要容易得多。现在只需还原 GitHub 存储库上的更改,并且将自动部署较旧的映像标记。

4.As the DevOps engineer, I am now able to run basic operations on the clusters without using and scripting commands. For instance, I can view health statuses of all applications on the clusters at the comfort of my phone, without running any commands to switch cluster context. 作为 DevOps 工程师,我现在能够在集群上运行基本操作,而无需使用和编写脚本命令。例如,我可以在手机上舒适地查看集群上所有应用程序的运行状况,而无需运行任何命令来切换集群上下文。

image.png

Final words 结语

Our adoption of GitOps is recent but I can definitely tell that there's a lot we have to benefit from it at AirQo as we continue to explore it. I thus generally believe that what I've shared here is only but the surface and trust that you and your organisation could discovered that this methodology solves challenges you had gotten accustomed when you try it.

我们对 GitOps 的采用是最近才出现的,但我可以肯定地说,随着我们继续探索它,我们必须从 AirQo 中受益匪浅。因此,我通常认为,我在这里分享的只是表面和信任,您和您的组织可能会发现这种方法解决了您在尝试时已经习惯的挑战。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-11-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DevOps云学堂 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
基于ArgoCD的GitOps实践
GitOps 是 Weaveworks 提出的一种持续交付方式,它的核心思想是将应用系统的声明性基础架构 和应用程序存放在 Git 版本库中。将 Git 作为交付流水线的核心,每个开发人员都可以提交拉取请求 (Pull Request)并使用 Git 来加速和简化 Kubernetes 的应用程序部署和运维任务。通过使用像 Git 这样的简单工具,开发人员可以更高效地将注意力集中在创建新功能而不是运维相关任务上(例如,应用系统安装、配置、迁移等)。
100000798482
2023/03/19
1.3K0
基于ArgoCD的GitOps实践
ArgoCD 简明教程
Argo CD 是一个为 Kubernetes 而生的,遵循声明式 GitOps 理念的持续部署(CD)工具,它的配置和使用非常简单,并且自带一个简单易用的 Dashboard 页面,并且支持多种配置管理/模板工具(例如 Kustomize、Helm、Ksonnet、Jsonnet、plain-YAML)。Argo CD 被实现为一个 Kubernetes 控制器,它持续监控正在运行的应用程序并将当前的实时状态与所需的目标状态(例如 Git 仓库中的配置)进行比较,在 Git 仓库更改时自动同步和部署应用程序。
Se7en258
2021/12/27
2.9K0
ArgoCD 简明教程
使用 Argo CD 进行 GitOps 流水线改造
Argo CD 是一个为 Kubernetes 而生的,遵循声明式 GitOps 理念的持续部署工具。Argo CD 可在 Git 存储库更改时自动同步和部署应用程序。
我是阳明
2023/09/25
1.8K0
使用 Argo CD 进行 GitOps 流水线改造
数据库的GITOPS第二部分 – Atlas Operator和ArgoCD
在第 1 部分中,我们演示了如何初始化一个 Atlas 项目,并创建一个 CI/CD 流水线,通过 GitHub Actions 自动计划、验证和存储数据库迁移到 Atlas Cloud。
云云众生s
2024/03/28
1780
数据库的GITOPS第二部分 – Atlas Operator和ArgoCD
使用ArgoCD和Tekton在OpenShift上创建端到端GitOps管道
使用 ArgoCD 和 Tekton 在 OpenShift 上创建端到端 DevOps 管道的分步指南
DevOps云学堂
2023/08/22
4790
使用ArgoCD和Tekton在OpenShift上创建端到端GitOps管道
扩展 GitOps:在 Kubernetes 上轻松持续集成和部署
https://www.cncf.io/blog/2023/12/26/extending-gitops-effortless-continuous-integration-and-deployment-on-kubernetes/
五分钟学SRE
2024/04/25
2850
基于 KubeSphere 流水线的 GitOps 最佳实践
Kubesphere 3.3.0 集成了 ArgoCD,但与笔者目前使用的 K8S 版本不兼容。再者,目前 Kubesphere 中持续集成和流水线打通还是不太友好,也缺少文档说明(可能是笔者没有找到)。
我的小碗汤
2023/03/19
1.5K0
基于 KubeSphere 流水线的 GitOps 最佳实践
GitOps: Kubernetes CI/CD 的缺失环节
GitOps: The Missing Link for CI/CD for Kubernetes
DevOps云学堂
2022/12/29
5850
GitOps: Kubernetes CI/CD 的缺失环节
使用 Argo CD 的 UI 界面可视化管理 Flux 应用?
Flux 项目原本提供了一个 Web UI 来管理 Flux 集群,但该项目已经存档,FluxCD 组织不再开发,所以我们这里不再介绍了,如果你想使用 Web UI 来管理 Flux 集群,可以使用 Weaveworks 提供的 weave-gitops(https://github.com/weaveworks/weave-gitops) 项目,该下面为 Flux 提供了一个免费的开源 GUI。
我是阳明
2023/09/28
6080
使用 Argo CD 的 UI 界面可视化管理 Flux 应用?
极狐GitLab 和 ArgoCD 的集成实践
ArgoCD 是一款开源且主要针对 Kubernetes 来做 GitOps 的持续交付工具。现在是 CNCF 的孵化项目。其整体架构图如下:
LinuxSuRen
2021/09/15
1.8K0
极狐GitLab 和 ArgoCD 的集成实践
基础设施即代码·3分钟搭建一套本地K8s集群
本文是第七期DevOps训练营,开营环境准备内容。通过terraform+kind进行本地测试环境Kubernetes集群部署,部署ArgoCD来对后续DevOps工具进行交付。
DevOps云学堂
2023/08/22
6080
基础设施即代码·3分钟搭建一套本地K8s集群
Multi-cluster Operations (Part 1): Auto Deployment, Release, and Monitoring
In today's era of cloud computing and DevOps, managing and maintaining multiple cluster environments has become a challenge. Each cluster has its unique characteristics and requirements, such as development, testing, production, etc. Effectively managing these clusters requires careful planning and the right tools.
行者深蓝
2023/12/24
1600
当下最热门的 GitOps,你了解吗?
GitOps 的概念最初来源于 Weaveworks 的联合创始人 Alexis 在 2017 年 8 月发表的一篇博客 GitOps - Operations by Pull Request。文章介绍了 Weaveworks 的工程师如何以 Git 作为事实的唯一真实来源,部署、管理和监控基于 Kubernetes 的 SaaS 应用。
iMike
2020/02/21
1.9K0
GitOps应用实践系列-Argo CD 实践篇
在前两篇内容中,我分别为大家介绍了 GitOps 的概念,以及用于实施 GitOps 的工具 Argo CD。本篇我们将以一个示例项目为大家介绍 Argo CD 的实践。
Jintao Zhang
2021/11/08
1.3K0
使用 AWS、k3s、Rancher、Vault 和 ArgoCD 在 Kubernetes 上集成 GitOps
最近我写了一篇关于 CI 和 CD 之间核心区别的文章,我觉得是时候把这些理论运用到实际当中了。
LinuxSuRen
2020/11/09
2.4K0
使用 AWS、k3s、Rancher、Vault 和 ArgoCD 在 Kubernetes 上集成 GitOps
Tekton 与 Argo CD 结合实现 GitOps
前面我们使用 Tekton 完成了应用的 CI/CD 流程,但是 CD 是在 Tekton 的任务中去完成的,现在我们使用 GitOps 的方式来改造我们的流水线,将 CD 部分使用 Argo CD 来完成。
DevOps云学堂
2021/07/15
2.5K0
Tekton 与 Argo CD 结合实现 GitOps
使用 GitLab CI 与 Argo CD 进行 GitOps 实践
在现在的云原生世界里面 GitOps 不断的被提及,这种持续交付的模式越来越受到了大家的青睐,在网上也可以找到很多关于它的资源,但是关于 GitOps 相关的工作流实践的示例却并不多见,我们这里就将详细介绍一个使用示例,希望对大家实践 GitOps 有所帮助。
我是阳明
2020/07/17
5.7K0
使用 GitLab CI 与 Argo CD 进行 GitOps 实践
基于GitOps轻松实现多团队多集群应用交付
应用分发 GitOps 的核心是以 Git 仓库作为应用部署的唯一来源,持续同步 Git 仓库中应用状态到 Kubernetes 集群上。CNCF 于 2023 年底发布的一项评估 GitOps 使用趋势的微观调查结果[1],其数据显示 GitOps 已经成为大多数开发者实现快速、一致、安全交付的首要选择。2022 年 12 月 CNCF Argo 项目正式毕业[2],标志着 Argo 项目的稳定和成熟,也让更多基于 Kubernetes 的用户使用 Argo CD 来实现 GitOps CD。
用户1107783
2024/04/11
2560
基于GitOps轻松实现多团队多集群应用交付
使用Argo CD自动化Kubernetes多集群配置
客座文章最初由DoiT International高级云架构师Mike Sparr在DoiT博客上发布
CNCF
2020/11/02
2.8K0
使用Argo CD自动化Kubernetes多集群配置
tke上如何通过jenkins和argocd完成代码自动化发布
CI/CD是大部分企业非常重要的一部分,也是必备的,相信大家都不陌生,每个企业都有自己的CI/CD,今天我们讲讲如何通过jenkins和argocd来实现CI/CD。
聂伟星
2022/05/10
2.5K1
推荐阅读
相关推荐
基于ArgoCD的GitOps实践
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文