Kubernetes anti-patterns: Let’s do GitOps, not CIOps!

GitOps介绍 翻译过来就是, Git 版本控制管理 IaC 的 CI/CD,核心是使用 Git 仓库来管理基础设施和应用的配置,以 Git 仓库作为基础设施和应用的单一事实来源,从其他地方修改配置(比如手动改线上配置)一概不予通过。借助 IaC,目标环境当前所需基础设施的期望状态以声明式配置的方式作为代码保存在 Git 仓库中,借助于 GitOps,如果集群的实际状态与 Git 仓库中定义的期望状态不匹配,会根据期望状态来调整当前的状态,最终使实际状态符合期望状态。 阅读详情

When we speak to customers about deployment automation for Kubernetes, we often see an anti-pattern that is not fully understood by most of the folks who implement it. In fact, the majority of Kubernetes CI/CD tutorials out there prescribe exactly this anti-pattern.

What is this anti-pattern?

The anti-pattern is when the CI system runs build and tests, followed by a deployment directly to Kubernetes. The levels of sophistication on how this can be done vary, and of course, most of the time deployment is done in the final stages of a fairly complex pipeline...

Also, the implementation details vary – some folks use kubectl set image - while others use helm upgrade , ksonnet apply or an in-house templating solution. What people use exactly is irrelevant. Overall the method is broken and please let me explain why.

We’ve been calling this “CIOps”, and it poses multiple challenges that I shall discuss in this post. I’ll start with an example.

CIOps - an example

Let’s say someone uses a hosted CI product (Travis CI and CircleCI are popular choices) and they want to deploy apps from CI to Kubernetes.

To do this, they have to give the CI access to the Kubernetes API. Firstly, this poses a security risk, aswe wrote previously. Additionally, this also means that they have to ensure that each CI job is configured correctly to deploy to the right cluster and that it has up-to-date credentials. Whenever they refresh those credentials or bring up a new cluster, re-configuring multiple CI jobs can be challenging, especially with many apps deployed independently. They may attempt to limit access to e.g. a single namespace dedicated for the given app, but such credentials are even harder to manage, as there is no tool that can manage Kubernetes credentials with limited scopes and can configure the given CI product as well.

How does “CIOps” compare to GitOps?

Here is what a typical “CIOps” deployment pipeline looks like, where the both developer and the CI system have full-access to the cluster as well as the container registry – there are no clear boundaries.

Typical "CIOps" pipeline

And this is what a common pipeline with the GitOps model looks like – there is boundary defined by an operator that runs inside the cluster and has exclusive rights to maintain the status of the cluster, all based on the config Git repo being the source of truth.

In some cases, the config repo can be the same as the code repo, but it’s recommended that you separate these for more complex apps. Any changes should go through the config repo, and any ad-hoc changes made to the cluster will be undone, unless replicated in config repo.

Common GitOps pipeline

And this is what the Weave Cloud version of this pipeline looks like. Notice, there is an extra operator that ensures the latest container image tags are propagated to the workload definitions in the config repo, and that there is a policy associated with it. The rest of the pipeline is the same as above. The GitOps model is also very easy to extend to multiple clusters.

Weave Cloud GitOps pipeline

In-cluster “CIOps”

It’s not uncommon to deploy a CI system directly into a Kubernetes cluster (sometimes for the whole cluster, and sometimes on a per-namespace basis).

This model avoids some of the aforementioned security issues. The configuration problem also goes away, but there other tradeoffs. For instance, you have to have enough resources to run your builds, and to manage the build log storage. Also, you will need to run the data services on which your CI of choice depends.

With multiple clusters, this approach implies that images are built independently in each of the clusters, and that each of each of those images aren’t going to be 100% identical, which ruins the idea of container images. You need to make sure your builds are truly reproducible, and this can be very hard.

Deployment doesn’t go well - another CIOps example

Let’s consider a scenario where one CI job updated a deployment and the update didn’t go as intended. How do you find out what version to rollback to? You’d probably need to trace through your build logs to find out.

Kubernetes assigns revisions to workloads (namely Deployments), but these aren’t universally applied to every kind of object. You have to take additional steps to map workload revisions, any other associated objects (e.g. ConfigMap or Service) and the version of the app code that you are looking to deploy. You could consider making API-level snapshots of the entire cluster, but that doesn’t help when you have to relate exact changes. Driving all cluster changes through Git is just much easier, and also helps to relate changes directly.

But what if there were multiple jobs trying to deploy the same version with different config, or what if someone got the config completely wrong and their CI job happens to override someone else’s deployment?

It is hard to ensure the ordering of CI jobs. There are few guarantees as to which builds will finish before other builds. And it is easy to end with a race between deployments. You can build your own guards around such things, but why solve a local issue? Some CI implementations may provide locking and/or ordering, but why should you depend on a given CI vendor?

All CI systems vary, it’s very hard to tell with certainty what goes on by looking at a CI system alone without organization-specific knowledge. In order to get someone new to quickly understand, you have to show them how your CI is setup.

A Kubernetes cluster can be treated as the source of truth, but it doesn’t have the knowledge about where the source code for each of your apps is and how the “world” outside of Kubernetes is structured. You could attempt to define as much of “your world” inside of Kubernetes, but that’s a challenging task…

If you consider for a moment that you could define this “world” in a Git repo (or in a set of repos), all you need to do is ensure Kubernetes is pointed to its part of the “world” (e.g. staging or production subdirectory, or branch if you prefer).

Finally, if you lost your production cluster and bring up a new one, there are multiple challenges:

  • How do tell what versions of each app you need to deploy?
  • You have to re-run all of your CI jobs for that cluster…
  • How do you ensure every CI job will deploy to the right cluster?

The Verdict on “CIOps”

In either case, whether you choose a hosted CI or have one that runs in your Kubernetes cluster, the biggest problem you will face at scale is that the CI and the Kubernetes cluster both compete to be the source of truth. CI systems are generally not designed to be the source of truth, although some are often treated that way. Kubernetes is somewhat better at it, and you could add snapshots, but using Git is just so much better.

It’s also hard to tell a transitional and accidental state apart from the intended states. With GitOps this is much clearer at any given time. CIOps can be mistaken for GitOps, and you shouldn’t make that mistake.

__EK486-0.zip 立即下载

相关推荐

ZYNQ SD卡启动实验

ZYNQ SD卡启动实验

化学和超级电容混合储能双层容量配置平抑风电波动,采用RLMD分解风电功率,粒子群算法求解(Matlab代码实现)

内容概要:本文提出一种针对风电功率波动的混合储能系统双层容量配置方法,采用化学储能(如锂离子电池)与超级电容器构成混合储能系统,以充分发挥前者高能量密度与后者高功率密度及快速响应的优势。为实现精细化功率分配,引入可重复局部均值分解(RLMD)对风电功率序列进行多尺度分解,有效分离出不同时间尺度的波动分量,据此制定协调控制策略:高频波动由超级电容承担,低频波动由化学储能承担,从而减轻单一储能单元的压力,延长整体系统寿命。在此基础上,构建了一个双层优化模型:上层模型以系统全寿命周期成本最低和运行稳定性最高为优化目标,确定储能单元的最优额定容量;下层模型则以实时功率分配损耗最小为目标,实现储能间的动态功率分配。整个优化问题采用粒子群优化算法(PSO)进行高效求解,并通过Matlab代码实现了完整的仿真验证。仿真结果表明,该方法不仅能显著平抑风电并网带来的功率波动,改善电能质量,还能有效降低系统综合成本,并通过合理分配充放电任务,减少化学储能的循环次数,延长其使用寿命。; 适合人群:具备电力系统、新能源控制或优化算法基础,从事风电并网、储能系统设计与优化等相关领域的科研人员及工程技术人员。; 使用场景及目标:①解决风电功率波动对电网稳定性的影响;②优化混合储能系统中电池与超级电容的容量配置,实现成本与性能的平衡;③掌握RLMD信号分解与粒子群算法在能源系统优化中的应用; 阅读建议:此资源结合了信号处理、储能控制与智能优化算法,建议读者在学习过程中重点关注RLMD分解原理、双层优化模型的构建逻辑及粒子群算法的实现细节,并结合提供的Matlab代码进行仿真复现与参数调试,以深入理解各模块的协同机制。

Rosenbrock 优化实验:GD、PSO 与 GA 的收敛对比matlab代码.rar

Rosenbrock 优化实验:GD、PSO 与 GA 的收敛对比matlab代码.rar

全桥LLC谐振(变频+移相混合控制)变换器闭环仿真模型(Simulink仿真实现)

内容概要:本文详细介绍了全桥LLC谐振变换器采用变频与移相混合控制策略的闭环仿真模型构建与实现过程,重点阐述了其在Simulink环境下的系统建模、控制逻辑设计及闭环调节机制。通过融合频率调节与相位移动两种控制方式,实现对输出电压的高精度调控与高效能量转换,同时详尽展示了仿真模型的搭建步骤、关键参数设定以及反馈回路设计,确保系统具备优良的动态响应与稳定性。此外,文档还融入了状态估计与卡尔曼滤波等先进算法的应用,提升了系统的智能化水平与抗干扰能力,体现了该模型在现代电力电子系统研究中的综合性与前沿性。; 适合人群:具备一定电力电子与自动控制理论基础,熟悉MATLAB/Simulink仿真工具,从事电源设计、新能源变换技术研究的研发人员及高校研究生。; 使用场景及目标:①掌握全桥LLC谐振变换器的混合控制原理与仿真建模方法;②实现变频与移相控制的协同优化,提升变换器效率与动态性能;③应用于高频电源、电动汽车充电、可再生能源并网等领域的系统仿真与优化研究; 阅读建议:此资源以Simulink仿真为核心,不仅提供模型实现细节,更强调控制策略的设计思想与系统级优化思路,建议读者结合文档中的参考文献与配套代码,动手实践并调试模型,深入理解闭环控制参数对系统性能的影响。

用于居民用水定价和工业废水成本优化的MATLAB与LINGO模型.rar

用于居民用水定价和工业废水成本优化的MATLAB与LINGO模型.rar

电动汽车充电调度、到达行为以及考虑可再生能源的电价的MATLAB优化。.rar

电动汽车充电调度、到达行为以及考虑可再生能源的电价的MATLAB优化。.rar

哔哩哔哩概念-com,bilibili,app,blue-8,89,0.apk

哔哩哔哩概念版,armv7a架构, 版本号8,89,0.

生成式AI教师发展研究趋势数据集二十年

本数据集系统映射2006至2026二十年间生成式人工智能与智能体技术在教师专业发展领域的研究趋势、新兴主题与未来方向,适合教育技术、文献计量与学术趋势分析研究。生成式AI与智能体技术正在重塑教师培训、教研支持与课堂辅助的形态,本数据集将二十年跨度的相关研究整理为结构化记录,按时间脉络呈现研究主题的演化路径,可支撑主题建模、研究热点识别、跨年度趋势对比与前沿方向预测等分析任务。典型应用场景包括:教育技术领域的文献综述与系统性综述、科研选题与基金申请的趋势依据、教育政策研究的技术采纳分析、文献计量学与时序文本挖掘的方法教学。数据规模约12MB,结构规整,可直接配合Pandas、NLTK、Gensim等工具开展主题模型、关键词共现网络、时间序列趋势与可视化分析,也适合作为数字人文与教育研究课程的案例数据。重要说明:本数据为公开研究成果的整理汇编,分析结论应以原始文献为准。许可:CC0公有领域,可自由使用与二次分发。

大盘分时VWAP-看懂每天的资金底牌

看懂大盘的文章集合

T17_低空经济试验区十五五通用航空机场与无人机物流网设计方案_技术方案版.pptx

T17_低空经济试验区十五五通用航空机场与无人机物流网设计方案_技术方案版.pptx

AI政务大模型数字人平台规划方案(技术方案版).pptx

AI政务大模型数字人平台规划方案(技术方案版).pptx

全桥LLC谐振软开关Simulink仿真设计

内容概要:本文详细阐述了全桥LLC谐振软开关的Simulink仿真设计,重点聚焦于其闭环控制策略、关键参数设计及软启动过程的实现。以2.5kW双向全桥LLC变换器为例,深入剖析了变频与移相混合控制方法的协同应用,并提供了完整的仿真模型、设计报告与计算书,帮助读者系统掌握LLC谐振变换器在实现高效零电压/零电流开关(ZVS/ZCS)和维持稳定输出方面的核心技术与工程实践细节; 适合人群:具备电力电子技术基础,从事开关电源、新能源变换系统、高效率DC-DC变换器研发的工程师及高校相关专业的研究生; 使用场景及目标:①深入理解全桥LLC谐振变换器的工作原理与软开关的实现机制;②掌握基于Simulink的闭环控制系统建模、仿真调试与动态响应分析方法;③应用于高效率、高功率密度电源产品的设计、优化与性能验证; 阅读建议:建议读者结合提供的仿真模型与设计文档同步操作,重点关注谐振腔参数(如谐振电感、励磁电感、谐振电容)的匹配、控制环路(特别是变频与移相控制的协调)的设计以及系统的动态响应特性,通过反复的仿真验证与参数调整,深化对LLC拓扑性能边界与设计权衡的理解。

git交互式学习系统(html)

git交互式学习系统(html)

基于多策略改进蜣螂算法(MSDBO)的多无人机协同三维避障路径规划研究(Matlab代码实现)

内容概要:本研究聚焦于多无人机协同三维避障路径规划问题,提出了一种基于多策略改进蜣螂优化算法(MSDBO)的解决方案。该方法通过融合多种优化策略,有效提升了传统蜣螂算法在复杂三维空间中的搜索能力与收敛性能,解决了多无人机在执行任务过程中面临的路径规划难题。算法设计综合考虑了路径长度、飞行高度、环境威胁及转弯角度等因素,构建了以最低综合成本为目标的优化模型,并在Matlab平台上完成了仿真验证。实验结果表明,所提MSDBO算法相较于传统优化算法在路径质量、避障能力和计算效率方面均有显著提升,能够为多无人机系统在城市空中交通、应急救援等复杂场景下的协同飞行提供可靠的技术支撑。 适合人群:具备一定优化算法基础和Matlab编程能力,从事无人机控制、智能优化、路径规划等相关领域的科研人员及研究生。 使用场景及目标:①应用于多无人机集群在复杂三维环境中的协同避障路径规划;②为智能交通、智慧城市建设、灾害巡检等实际工程问题提供高效路径优化方案;③推动智能优化算法在无人系统中的理论研究与实践应用。 阅读建议:建议读者结合Matlab代码深入理解算法实现细节,重点关注目标函数构建、约束处理机制及多策略改进部分,并可通过调整环境参数和无人机数量进行扩展性实验,进一步掌握算法的适应性与鲁棒性。

T14_低空经济校企合作共建机制与实施路径设计方案_可研报告版.pptx

T14_低空经济校企合作共建机制与实施路径设计方案_可研报告版.pptx

增材制造基于冷喷涂固态成型的金属3D打印技术:零氧化铜铝复合与航空修复应用

内容概要:本文系统阐述了固态金属成型技术——冷喷涂增材制造(CSAM)的核心原理、工艺机制与工程应用。CSAM通过将金属粉末以超音速撞击基体,在不熔化材料的前提下实现固态冶金结合,具有近乎零氧化、热影响区小、适用于铜铝钛及异种金属复合制造等优势。文章深入解析其结合机制(如绝热剪切失稳、氧化膜破裂与新鲜金属接触)、关键工艺参数(气体选择、温度、速度、氧含量)、复合致密化手段(激光辅助、原位微锻造、热处理等),并展示了在新能源汽车散热板、航空部件修复、金属基复合材料等领域的实际应用。同时指出了当前存在的塑性低、精度不足、成本高等痛点及其工程对策,并展望了大型化、多材料集成、全链条数字化与绿色制造的发展趋势。; 适合人群:从事增材制造、材料工程、金属加工及相关领域研发的技术人员,具备一定材料科学与制造工艺背景的科研人员和工程师。; 使用场景及目标:①理解冷喷涂与其他金属3D打印技术的本质差异与互补关系;②掌握CSAM在异种金属连接、热敏感部件修复、高性能涂层制备中的应用潜力;③指导工艺优化、材料选型与工业落地路径设计; 阅读建议:本文兼具理论深度与工程实践视角,建议结合图表与案例重点研读结合机制、复合工艺与应用场景部分,并关注氧含量控制、数字孪生与标准化趋势,以推动技术从实验室向规模化生产转化。

14-15日周末听写音频.mp3

14-15日周末听写音频.mp3

政务服务AI知识库平台规划方案(生态合作版).pptx

政务服务AI知识库平台规划方案(生态合作版).pptx

上一篇: GitOps实操工具-Flux安装与设置
下一篇: 集中化管理平台 — Ansible 详解
hxpjava1
博客等级 码龄19年 1365粉丝 511原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值