Skip to content

Commit fe9629c

Browse files
committed
[zh] Add text to controllers/statefulset.md
1 parent 6433730 commit fe9629c

File tree

1 file changed

+186
-0
lines changed

1 file changed

+186
-0
lines changed

content/zh-cn/docs/concepts/workloads/controllers/statefulset.md

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,192 @@ StatefulSet will then begin to recreate the Pods using the reverted template.
747747
恢复模板后,还必须删除 StatefulSet 尝试使用错误的配置来运行的 Pod。这样,
748748
StatefulSet 才会开始使用被还原的模板来重新创建 Pod。
749749

750+
<!--
751+
## Revision history
752+
753+
ControllerRevision is a Kubernetes API resource used by controllers, such as the StatefulSet controller, to track historical configuration changes.
754+
755+
StatefulSets use ControllerRevisions to maintain a revision history, enabling rollbacks and version tracking.
756+
-->
757+
## 修订版本历史 {#revision-history}
758+
759+
ControllerRevision 是 Kubernetes 的一种 API 资源,由控制器(例如 StatefulSet 控制器)使用,用于跟踪配置变更历史。
760+
761+
StatefulSet 使用 ControllerRevision 来维护修订版本历史,从而支持回滚和版本跟踪。
762+
763+
<!--
764+
### How StatefulSets track changes using ControllerRevisions
765+
766+
When you update a StatefulSet's Pod template (`spec.template`), the StatefulSet controller:
767+
768+
1. Prepares a new ControllerRevision object
769+
2. Stores a snapshot of the Pod template and metadata
770+
3. Assigns an incremental revision number
771+
-->
772+
### StatefulSet 如何通过 ControllerRevision 跟踪变更
773+
774+
当你更新 StatefulSet 的 Pod 模板 (`spec.template`) 时,StatefulSet 控制器:
775+
776+
1. 准备新的 ControllerRevision 对象
777+
2. 存储 Pod 模板和元数据的快照
778+
3. 分配一个递增的修订版本号
779+
780+
<!--
781+
#### Key Properties
782+
783+
ControllerRevision key properties and other details can be checked [here](/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/)
784+
-->
785+
#### 关键属性
786+
787+
ControllerRevision 的关键属性和其他细节,
788+
请查阅[这里](/zh-cn/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/)。
789+
790+
---
791+
792+
<!--
793+
### Managing Revision History
794+
795+
Control retained revisions with `.spec.revisionHistoryLimit`:
796+
-->
797+
### 管理修订版本历史
798+
799+
通过 `.spec.revisionHistoryLimit` 控制保留的修订版本:
800+
801+
<!--
802+
```yaml
803+
apiVersion: apps/v1
804+
kind: StatefulSet
805+
metadata:
806+
name: webapp
807+
spec:
808+
revisionHistoryLimit: 5 # Keep last 5 revisions
809+
# ... other spec fields ...
810+
```
811+
-->
812+
```yaml
813+
apiVersion: apps/v1
814+
kind: StatefulSet
815+
metadata:
816+
name: webapp
817+
spec:
818+
revisionHistoryLimit: 5 # 保留最近 5 个修订版本
819+
# ... 其他 spec 字段 ...
820+
```
821+
822+
<!--
823+
- **Default**: 10 revisions retained if unspecified
824+
- **Cleanup**: Oldest revisions are garbage-collected when exceeding the limit
825+
826+
#### Performing Rollbacks
827+
828+
You can revert to a previous configuration using:
829+
-->
830+
- **默认**:如果未指定,保留 10 个修订版本
831+
- **清理**:超过限制时,最早的修订版本会被垃圾回收
832+
833+
#### 执行回滚
834+
835+
你可以通过以下方式恢复到前一个配置:
836+
837+
<!--
838+
```bash
839+
# View revision history
840+
kubectl rollout history statefulset/webapp
841+
842+
# Rollback to a specific revision
843+
kubectl rollout undo statefulset/webapp --to-revision=3
844+
```
845+
-->
846+
```bash
847+
# 查看修订版本历史
848+
kubectl rollout history statefulset/webapp
849+
850+
# 回滚到特定的修订版本
851+
kubectl rollout undo statefulset/webapp --to-revision=3
852+
```
853+
854+
<!--
855+
This will:
856+
857+
- Apply the Pod template from revision 3
858+
- Create a new ControllerRevision with an updated revision number
859+
860+
#### Inspecting ControllerRevisions
861+
862+
To view associated ControllerRevisions:
863+
-->
864+
这将会:
865+
866+
- 应用来自修订版本 3 的 Pod 模板
867+
- 使用更新的修订版本号创建新的 ControllerRevision
868+
869+
#### 检查 ControllerRevision
870+
871+
查看关联的 ControllerRevision:
872+
873+
<!--
874+
```bash
875+
# List all revisions for the StatefulSet
876+
kubectl get controllerrevisions -l app.kubernetes.io/name=webapp
877+
878+
# View detailed configuration of a specific revision
879+
kubectl get controllerrevision/webapp-3 -o yaml
880+
```
881+
-->
882+
```bash
883+
# 列出 StatefulSet 的所有修订版本
884+
kubectl get controllerrevisions -l app.kubernetes.io/name=webapp
885+
886+
# 查看特定修订版本的详细配置
887+
kubectl get controllerrevision/webapp-3 -o yaml
888+
```
889+
890+
<!--
891+
#### Best Practices
892+
893+
##### Retention Policy
894+
895+
- Set `revisionHistoryLimit` between **5–10** for most workloads
896+
- Increase only if **deep rollback history** is required
897+
-->
898+
#### 最佳实践
899+
900+
##### 保留策略
901+
902+
- 对大多数工作负载,将 `revisionHistoryLimit` 设置为 **5–10**
903+
904+
- 仅在需要**深度回滚历史**时才增加
905+
906+
<!--
907+
##### Monitoring
908+
909+
- Regularly check revisions with:
910+
-->
911+
##### 监控
912+
913+
- 定期检查修订版本:
914+
915+
```bash
916+
kubectl get controllerrevisions
917+
```
918+
919+
<!--
920+
- Alert on **rapid revision count growth**
921+
922+
##### Avoid
923+
924+
- Manual edits to ControllerRevision objects.
925+
- Using revisions as a backup mechanism (use actual backup tools).
926+
- Setting `revisionHistoryLimit: 0` (disables rollback capability).
927+
-->
928+
- 针对**修订版本数量快速增长**发出告警
929+
930+
##### 避免
931+
932+
- 手动编辑 ControllerRevision 对象。
933+
- 将修订版本用作备份机制(使用实际的备份工具)。
934+
- 设置 revisionHistoryLimit: 0(禁用回滚功能)。
935+
750936
<!--
751937
## PersistentVolumeClaim retention
752938
-->

0 commit comments

Comments
 (0)