@@ -23,7 +23,7 @@ This document explains how to define and manage objects using configuration file
2323<!--
2424Install [`kubectl`](/docs/tasks/tools/).
2525-->
26- 安装 [ ` kubectl ` ] ( /zh-cn/docs/tasks/tools/ ) 。
26+ 安装 [ ` kubectl ` ] ( /zh-cn/docs/tasks/tools/ ) 。
2727
2828{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
2929
@@ -34,7 +34,7 @@ Install [`kubectl`](/docs/tasks/tools/).
3434
3535The `kubectl` tool supports three kinds of object management:
3636-->
37- ## 权衡
37+ ## 权衡 {#trade-offs}
3838
3939` kubectl ` 工具支持三种对象管理:
4040
@@ -51,7 +51,7 @@ The `kubectl` tool supports three kinds of object management:
5151See [Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/)
5252for a discussion of the advantages and disadvantage of each kind of object management.
5353-->
54- 参看 [ Kubernetes 对象管理] ( /zh-cn/docs/concepts/overview/working-with-objects/object-management/ )
54+ 参见 [ Kubernetes 对象管理] ( /zh-cn/docs/concepts/overview/working-with-objects/object-management/ )
5555中关于每种对象管理的优缺点的讨论。
5656
5757<!--
@@ -61,16 +61,20 @@ You can use `kubectl create -f` to create an object from a configuration file.
6161Refer to the [kubernetes API reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
6262for details.
6363-->
64- ## 如何创建对象
64+ ## 如何创建对象 {#how-to-create-objects}
6565
6666你可以使用 ` kubectl create -f ` 从配置文件创建一个对象。
67- 请参考 [ kubernetes API 参考] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/) 有关详细信息 。
67+ 更多细节参阅 [ kubernetes API 参考] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)。
6868
6969* ` kubectl create -f <filename|url> `
7070
7171<!--
7272## How to update objects
73+ -->
74+ ## 如何更新对象 {#how-to-update-objects}
7375
76+ {{< warning >}}
77+ <!--
7478Updating objects with the `replace` command drops all
7579parts of the spec not specified in the configuration file. This
7680should not be used with objects whose specs are partially managed
@@ -79,9 +83,6 @@ the `externalIPs` field is managed independently from the configuration
7983file. Independently managed fields must be copied to the configuration
8084file to prevent `replace` from dropping them.
8185-->
82- ## 如何更新对象
83-
84- {{< warning >}}
8586使用 ` replace ` 命令更新对象会删除所有未在配置文件中指定的规范的某些部分。
8687不应将其规范由集群部分管理的对象使用,比如类型为 ` LoadBalancer ` 的服务,
8788其中 ` externalIPs ` 字段独立于配置文件进行管理。
@@ -92,7 +93,7 @@ file to prevent `replace` from dropping them.
9293You can use `kubectl replace -f` to update a live object according to a
9394configuration file.
9495-->
95- 你可以使用 ` kubectl replace -f ` 根据配置文件更新活动对象。
96+ 你可以使用 ` kubectl replace -f ` 根据配置文件更新活动对象。
9697
9798* ` kubectl replace -f <filename|url> `
9899
@@ -102,24 +103,19 @@ configuration file.
102103You can use `kubectl delete -f` to delete an object that is described in a
103104configuration file.
104105-->
105- ## 如何删除对象
106+ ## 如何删除对象 {#how-to-delete-objects}
106107
107108你可以使用 ` kubectl delete -f ` 删除配置文件中描述的对象。
108109
109110* ` kubectl delete -f <filename|url> `
110111
112+ {{< note >}}
111113<!--
112114If configuration file has specified the `generateName` field in the `metadata`
113115section instead of the `name` field, you cannot delete the object using
114116`kubectl delete -f <filename|url>`.
115117You will have to use other flags for deleting the object. For example:
116-
117- ```shell
118- kubectl delete <type> <name>
119- kubectl delete <type> -l <label>
120- ```
121118-->
122- {{< note >}}
123119如果配置文件在 ` metadata ` 节中设置了 ` generateName ` 字段而非 ` name ` 字段,
124120你无法使用 ` kubectl delete -f <filename|url> ` 来删除该对象。
125121你必须使用其他标志才能删除对象。例如:
@@ -136,7 +132,7 @@ kubectl delete <type> -l <label>
136132You can use `kubectl get -f` to view information about an object that is
137133described in a configuration file.
138134-->
139- ## 如何查看对象
135+ ## 如何查看对象 {#how-to-view-an-object}
140136
141137你可以使用 ` kubectl get -f ` 查看有关配置文件中描述的对象的信息。
142138
@@ -146,8 +142,7 @@ described in a configuration file.
146142The `-o yaml` flag specifies that the full object configuration is printed.
147143Use `kubectl get -h` to see a list of options.
148144-->
149- ` -o yaml ` 标志指定打印完整的对象配置。
150- 使用 ` kubectl get -h ` 查看选项列表。
145+ ` -o yaml ` 标志指定打印完整的对象配置。使用 ` kubectl get -h ` 查看选项列表。
151146
152147<!--
153148## Limitations
@@ -160,7 +155,7 @@ is executed. This can happen if a controller, such as
160155a HorizontalPodAutoscaler, makes updates directly to a live object. Here's
161156an example:
162157-->
163- ## 局限性
158+ ## 局限性 {#limitations}
164159
165160当完全定义每个对象的配置并将其记录在其配置文件中时,` create ` 、 ` replace ` 和` delete ` 命令会很好的工作。
166161但是,当更新一个活动对象,并且更新没有合并到其配置文件中时,下一次执行 ` replace ` 时,更新将丢失。
@@ -191,7 +186,7 @@ Suppose you have the URL of an object configuration file. You can use
191186object is created. This is particularly useful for tutorials and tasks
192187that point to a configuration file that could be modified by the reader.
193188-->
194- ## 从 URL 创建和编辑对象而不保存配置
189+ ## 从 URL 创建和编辑对象而不保存配置 {#creating-and-editing-an-object-from-a-url-without-saving-the-configuration}
195190
196191假设你具有对象配置文件的 URL。
197192你可以在创建对象之前使用 ` kubectl create --edit ` 对配置进行更改。
@@ -207,7 +202,7 @@ kubectl create -f <url> --edit
207202Migrating from imperative commands to imperative object configuration involves
208203several manual steps.
209204-->
210- ## 从命令式命令迁移到命令式对象配置
205+ ## 从命令式命令迁移到命令式对象配置 {#migrating-from-imperative-commands-to-imperative-object-configuration}
211206
212207从命令式命令迁移到命令式对象配置涉及几个手动步骤。
213208
@@ -237,12 +232,12 @@ several manual steps.
237232<!--
238233## Defining controller selectors and PodTemplate labels
239234-->
240- ## 定义控制器选择器和 PodTemplate 标签
235+ ## 定义控制器选择器和 PodTemplate 标签 {#defining-controller-selectors-and-podtemplate-labels}
241236
237+ {{< warning >}}
242238<!--
243239Updating selectors on controllers is strongly discouraged.
244240-->
245- {{< warning >}}
246241不建议在控制器上更新选择器。
247242{{< /warning >}}
248243
@@ -279,5 +274,3 @@ template:
279274* [使用配置文件对 Kubernetes 对象进行声明式管理](/zh-cn/docs/tasks/manage-kubernetes-objects/declarative-config/)
280275* [Kubectl 命令参考](/docs/reference/generated/kubectl/kubectl-commands/)
281276* [Kubernetes API 参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
282-
283-
0 commit comments