34 lines
1.1 KiB
Markdown
34 lines
1.1 KiB
Markdown
---
|
||
title: "Idempotent Operation"
|
||
type: concept
|
||
tags: [DevOps, GitOps, 基础概念]
|
||
sources: [ctp-topic-33-an-introduction-to-gitops.md]
|
||
last_updated: 2026-04-19
|
||
---
|
||
|
||
## Definition
|
||
Idempotent Operation(幂等操作)是指可以多次执行而不会改变超出初始应用结果的操作。无论执行多少次,最终状态都与执行一次相同。
|
||
|
||
## Examples
|
||
- Kubernetes 部署:多次 apply 相同配置不会导致重复创建
|
||
- Terraform apply:重复执行会产生相同的基础设施状态
|
||
- 文件权限设置:重复 chmod 相同权限
|
||
- 数据库 UPSERT:重复插入或更新
|
||
|
||
## Non-Idempotent Examples
|
||
- `curl` 请求:每次执行都会创建新资源
|
||
- 计数器递增:每次执行都会改变值
|
||
- 文件追加:重复执行会累积内容
|
||
|
||
## Importance in GitOps
|
||
- 确保部署过程可重复执行
|
||
- 支持自动重试和恢复
|
||
- 简化故障处理和调试
|
||
|
||
## Related Concepts
|
||
- [[GitOps]]
|
||
- [[Declarative Configuration]]
|
||
- [[Infrastructure as Code (IaC)]]
|
||
|
||
## Related Sources
|
||
- [[ctp-topic-33-an-introduction-to-gitops]] — GitOps 入门介绍 |