Skip to content

Commit 176eb18

Browse files
authored
Merge pull request #41041 from windsonsea/safer
[zh] sync 2023-05-09-Safer-More-Performant-Pruning-in-kubectl-apply.md
2 parents d5cd8ea + 0446343 commit 176eb18

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.27:kubectl apply 裁剪更安全、更高效"
4+
date: 2023-05-09
5+
slug: introducing-kubectl-applyset-pruning
6+
---
7+
<!--
8+
layout: blog
9+
title: "Kubernetes 1.27: Safer, More Performant Pruning in kubectl apply"
10+
date: 2023-05-09
11+
slug: introducing-kubectl-applyset-pruning
12+
-->
13+
14+
<!--
15+
**Authors:** Katrina Verey (independent) and Justin Santa Barbara (Google)
16+
-->
17+
**作者:** Katrina Verey(独立个人)和 Justin Santa Barbara (Google)
18+
19+
**译者:** [Michael Yao](http://github.com/windsonsea) (DaoCloud)
20+
21+
<!--
22+
Declarative configuration management with the `kubectl apply` command is the gold standard approach
23+
to creating or modifying Kubernetes resources. However, one challenge it presents is the deletion
24+
of resources that are no longer needed. In Kubernetes version 1.5, the `--prune` flag was
25+
introduced to address this issue, allowing kubectl apply to automatically clean up previously
26+
applied resources removed from the current configuration.
27+
-->
28+
通过 `kubectl apply` 命令执行声明式配置管理是创建或修改 Kubernetes 资源的黄金标准方法。
29+
但这种方法也带来了一个挑战,那就是删除不再需要的资源。
30+
在 Kubernetes 1.5 版本中,引入了 `--prune` 标志来解决此问题,
31+
允许 `kubectl apply` 自动清理从当前配置中删除的先前应用的资源。
32+
33+
<!--
34+
Unfortunately, that existing implementation of `--prune` has design flaws that diminish its
35+
performance and can result in unexpected behaviors. The main issue stems from the lack of explicit
36+
encoding of the previously applied set by the preceding `apply` operation, necessitating
37+
error-prone dynamic discovery. Object leakage, inadvertent over-selection of resources, and limited
38+
compatibility with custom resources are a few notable drawbacks of this implementation. Moreover,
39+
its coupling to client-side apply hinders user upgrades to the superior server-side apply
40+
mechanism.
41+
-->
42+
然而,现有的 `--prune` 实现存在设计缺陷,会降低性能并导致意外行为。
43+
主要问题源于先前的 `apply` 操作未对已应用的集合进行显式编码,有必要进行易错的动态发现。
44+
对象泄漏、意外过度选择资源以及与自定义资源的有限兼容性是这种实现的一些明显缺点。
45+
此外,其与客户端 apply 的耦合阻碍了用户升级到更优秀的服务器端 apply 方式。
46+
47+
<!--
48+
Version 1.27 of `kubectl` introduces an alpha version of a revamped pruning implementation that
49+
addresses these issues. This new implementation, based on a concept called _ApplySet_, promises
50+
better performance and safety.
51+
-->
52+
`kubectl` 的 1.27 版本引入了 Alpha 版本的重构裁剪实现,解决了这些问题。
53+
这个基于 **ApplySet** 概念的新实现承诺能够提供更好的性能和更好的安全性。
54+
55+
<!--
56+
An _ApplySet_ is a group of resources associated with a _parent_ object on the cluster, as
57+
identified and configured through standardized labels and annotations. Additional standardized
58+
metadata allows for accurate identification of ApplySet _member_ objects within the cluster,
59+
simplifying operations like pruning.
60+
-->
61+
**ApplySet** 是一个与集群上的****对象相关联的资源组,通过标准化的标签和注解进行标识和配置。
62+
附加的标准化元数据允许准确标识集群内的 ApplySet **成员**对象,简化了裁剪等操作。
63+
64+
<!--
65+
To leverage ApplySet-based pruning, set the `KUBECTL_APPLYSET=true` environment variable and include
66+
the flags `--prune` and `--applyset` in your `kubectl apply` invocation:
67+
68+
```shell
69+
KUBECTL_APPLYSET=true kubectl apply -f <directory/> --prune --applyset=<name>
70+
```
71+
-->
72+
为了充分利用基于 ApplySet 的裁剪,设置 `KUBECTL_APPLYSET=true` 环境变量,
73+
并在 `kubectl apply` 调用中包括标志 `--prune``--applyset`
74+
75+
```shell
76+
KUBECTL_APPLYSET=true kubectl apply -f <目录> --prune --applyset=<name>
77+
```
78+
79+
<!--
80+
By default, ApplySet uses a Secret as the parent object. However, you can also use
81+
a ConfigMap with the format `--applyset=configmaps/<name>`. If your desired Secret or
82+
ConfigMap object does not yet exist, `kubectl` will create it for you. Furthermore, custom
83+
resources can be enabled for use as ApplySet parent objects.
84+
-->
85+
默认情况下,ApplySet 使用 Secret 作为父对象。
86+
但是,你也可以通过格式 `--applyset=configmaps/<name>` 来使用 ConfigMap。
87+
如果所需的 Secret 或 ConfigMap 对象尚不存在,则 `kubectl` 将为你创建它。
88+
此外,可以启用自定义资源以用作 ApplySet 父对象。
89+
90+
<!--
91+
The ApplySet implementation is based on a new low-level specification that can support higher-level
92+
ecosystem tools by improving their interoperability. The lightweight nature of this specification
93+
enables these tools to continue to use existing object grouping systems while opting in to
94+
ApplySet's metadata conventions to prevent inadvertent changes by other tools (such as `kubectl`).
95+
-->
96+
ApplySet 实现基于新的底层规约,可以通过提高其互操作性来支持更高层次的生态系统工具。
97+
这种规约的轻量性使得这些工具可以继续使用现有的对象分组系统,
98+
同时选用 ApplySet 的元数据约定以防被其他工具(例如 `kubectl`)意外更改。
99+
100+
<!--
101+
ApplySet-based pruning offers a promising solution to the shortcomings of the previous `--prune`
102+
implementation in `kubectl` and can help streamline your Kubernetes resource management. Please
103+
give this new feature a try and share your experiences with the community—ApplySet is under active
104+
development, and your feedback is invaluable!
105+
-->
106+
基于 ApplySet 的裁剪提供了一种方法,保证有效解决之前 `kubectl``--prune` 实现的缺陷,
107+
还可以帮助优化 Kubernetes 资源管理。请使用这个新特性并与社区分享你的经验。
108+
ApplySet 正处于积极开发中,你的反馈至关重要!
109+
110+
<!--
111+
### Additional resources
112+
113+
- For more information how to use ApplySet-based pruning, read
114+
[Declarative Management of Kubernetes Objects Using Configuration Files](/docs/tasks/manage-kubernetes-objects/declarative-config/) in the Kubernetes documentation.
115+
- For a deeper dive into the technical design of this feature or to learn how to implement the
116+
ApplySet specification in your own tools, refer to [KEP&nbsp;3659](http://git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune/README.md):
117+
_ApplySet: `kubectl apply --prune` redesign and graduation strategy_.
118+
-->
119+
### 更多资源
120+
121+
- 想了解如何使用基于 ApplySet 的裁剪,请阅读 Kubernetes 文档中的
122+
[使用配置文件以声明方式管理 Kubernetes 对象](/zh-cn/docs/tasks/manage-kubernetes-objects/declarative-config/)
123+
- 如需更深入地了解此特性的技术设计或了解如何用你自己工具实现 ApplySet 规范,
124+
请参阅 [KEP-3659](http://git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune/README.md):
125+
**ApplySet: `kubectl apply --prune` 重新设计和进阶策略**
126+
127+
<!--
128+
### How do I get involved?
129+
130+
If you want to get involved in ApplySet development, you can get in touch with the developers at
131+
[SIG CLI](http://git.k8s.io/community/sig-cli). To provide feedback on the feature, please
132+
[file a bug](http://github.com/kubernetes/kubectl/issues/new?assignees=knverey,justinsb&labels=kind%2Fbug&template=bug-report.md)
133+
or [request an enhancement](http://github.com/kubernetes/kubectl/issues/new?assignees=knverey,justinsb&labels=kind%2Fbug&template=enhancement.md)
134+
on the `kubernetes/kubectl` repository.
135+
-->
136+
### 如何参与
137+
138+
如果你想参与 ApplySet 的开发,可以联系 [SIG CLI](http://git.k8s.io/community/sig-cli) 的开发人员。
139+
如需提供有关此特性的反馈,请在 `kubernetes/kubectl`
140+
代码库上[提交 bug](http://github.com/kubernetes/kubectl/issues/new?assignees=knverey,justinsb&labels=kind%2Fbug&template=bug-report.md)
141+
[提出增强请求](http://github.com/kubernetes/kubectl/issues/new?assignees=knverey,justinsb&labels=kind%2Fbug&template=enhancement.md)

0 commit comments

Comments
 (0)