@@ -23,7 +23,7 @@ This document explains how to define and manage objects using configuration file
23
23
<!--
24
24
Install [`kubectl`](/docs/tasks/tools/).
25
25
-->
26
- 安装 [ ` kubectl ` ] ( /zh-cn/docs/tasks/tools/ ) 。
26
+ 安装 [ ` kubectl ` ] ( /zh-cn/docs/tasks/tools/ ) 。
27
27
28
28
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
29
29
@@ -34,7 +34,7 @@ Install [`kubectl`](/docs/tasks/tools/).
34
34
35
35
The `kubectl` tool supports three kinds of object management:
36
36
-->
37
- ## 权衡
37
+ ## 权衡 {#trade-offs}
38
38
39
39
` kubectl ` 工具支持三种对象管理:
40
40
@@ -51,7 +51,7 @@ The `kubectl` tool supports three kinds of object management:
51
51
See [Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/)
52
52
for a discussion of the advantages and disadvantage of each kind of object management.
53
53
-->
54
- 参看 [ Kubernetes 对象管理] ( /zh-cn/docs/concepts/overview/working-with-objects/object-management/ )
54
+ 参见 [ Kubernetes 对象管理] ( /zh-cn/docs/concepts/overview/working-with-objects/object-management/ )
55
55
中关于每种对象管理的优缺点的讨论。
56
56
57
57
<!--
@@ -61,16 +61,20 @@ You can use `kubectl create -f` to create an object from a configuration file.
61
61
Refer to the [kubernetes API reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
62
62
for details.
63
63
-->
64
- ## 如何创建对象
64
+ ## 如何创建对象 {#how-to-create-objects}
65
65
66
66
你可以使用 ` kubectl create -f ` 从配置文件创建一个对象。
67
- 请参考 [ kubernetes API 参考] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/) 有关详细信息 。
67
+ 更多细节参阅 [ kubernetes API 参考] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)。
68
68
69
69
* ` kubectl create -f <filename|url> `
70
70
71
71
<!--
72
72
## How to update objects
73
+ -->
74
+ ## 如何更新对象 {#how-to-update-objects}
73
75
76
+ {{< warning >}}
77
+ <!--
74
78
Updating objects with the `replace` command drops all
75
79
parts of the spec not specified in the configuration file. This
76
80
should not be used with objects whose specs are partially managed
@@ -79,9 +83,6 @@ the `externalIPs` field is managed independently from the configuration
79
83
file. Independently managed fields must be copied to the configuration
80
84
file to prevent `replace` from dropping them.
81
85
-->
82
- ## 如何更新对象
83
-
84
- {{< warning >}}
85
86
使用 ` replace ` 命令更新对象会删除所有未在配置文件中指定的规范的某些部分。
86
87
不应将其规范由集群部分管理的对象使用,比如类型为 ` LoadBalancer ` 的服务,
87
88
其中 ` externalIPs ` 字段独立于配置文件进行管理。
@@ -92,7 +93,7 @@ file to prevent `replace` from dropping them.
92
93
You can use `kubectl replace -f` to update a live object according to a
93
94
configuration file.
94
95
-->
95
- 你可以使用 ` kubectl replace -f ` 根据配置文件更新活动对象。
96
+ 你可以使用 ` kubectl replace -f ` 根据配置文件更新活动对象。
96
97
97
98
* ` kubectl replace -f <filename|url> `
98
99
@@ -102,24 +103,19 @@ configuration file.
102
103
You can use `kubectl delete -f` to delete an object that is described in a
103
104
configuration file.
104
105
-->
105
- ## 如何删除对象
106
+ ## 如何删除对象 {#how-to-delete-objects}
106
107
107
108
你可以使用 ` kubectl delete -f ` 删除配置文件中描述的对象。
108
109
109
110
* ` kubectl delete -f <filename|url> `
110
111
112
+ {{< note >}}
111
113
<!--
112
114
If configuration file has specified the `generateName` field in the `metadata`
113
115
section instead of the `name` field, you cannot delete the object using
114
116
`kubectl delete -f <filename|url>`.
115
117
You 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
- ```
121
118
-->
122
- {{< note >}}
123
119
如果配置文件在 ` metadata ` 节中设置了 ` generateName ` 字段而非 ` name ` 字段,
124
120
你无法使用 ` kubectl delete -f <filename|url> ` 来删除该对象。
125
121
你必须使用其他标志才能删除对象。例如:
@@ -136,7 +132,7 @@ kubectl delete <type> -l <label>
136
132
You can use `kubectl get -f` to view information about an object that is
137
133
described in a configuration file.
138
134
-->
139
- ## 如何查看对象
135
+ ## 如何查看对象 {#how-to-view-an-object}
140
136
141
137
你可以使用 ` kubectl get -f ` 查看有关配置文件中描述的对象的信息。
142
138
@@ -146,8 +142,7 @@ described in a configuration file.
146
142
The `-o yaml` flag specifies that the full object configuration is printed.
147
143
Use `kubectl get -h` to see a list of options.
148
144
-->
149
- ` -o yaml ` 标志指定打印完整的对象配置。
150
- 使用 ` kubectl get -h ` 查看选项列表。
145
+ ` -o yaml ` 标志指定打印完整的对象配置。使用 ` kubectl get -h ` 查看选项列表。
151
146
152
147
<!--
153
148
## Limitations
@@ -160,7 +155,7 @@ is executed. This can happen if a controller, such as
160
155
a HorizontalPodAutoscaler, makes updates directly to a live object. Here's
161
156
an example:
162
157
-->
163
- ## 局限性
158
+ ## 局限性 {#limitations}
164
159
165
160
当完全定义每个对象的配置并将其记录在其配置文件中时,` create ` 、 ` replace ` 和` delete ` 命令会很好的工作。
166
161
但是,当更新一个活动对象,并且更新没有合并到其配置文件中时,下一次执行 ` replace ` 时,更新将丢失。
@@ -191,7 +186,7 @@ Suppose you have the URL of an object configuration file. You can use
191
186
object is created. This is particularly useful for tutorials and tasks
192
187
that point to a configuration file that could be modified by the reader.
193
188
-->
194
- ## 从 URL 创建和编辑对象而不保存配置
189
+ ## 从 URL 创建和编辑对象而不保存配置 {#creating-and-editing-an-object-from-a-url-without-saving-the-configuration}
195
190
196
191
假设你具有对象配置文件的 URL。
197
192
你可以在创建对象之前使用 ` kubectl create --edit ` 对配置进行更改。
@@ -207,7 +202,7 @@ kubectl create -f <url> --edit
207
202
Migrating from imperative commands to imperative object configuration involves
208
203
several manual steps.
209
204
-->
210
- ## 从命令式命令迁移到命令式对象配置
205
+ ## 从命令式命令迁移到命令式对象配置 {#migrating-from-imperative-commands-to-imperative-object-configuration}
211
206
212
207
从命令式命令迁移到命令式对象配置涉及几个手动步骤。
213
208
@@ -237,12 +232,12 @@ several manual steps.
237
232
<!--
238
233
## Defining controller selectors and PodTemplate labels
239
234
-->
240
- ## 定义控制器选择器和 PodTemplate 标签
235
+ ## 定义控制器选择器和 PodTemplate 标签 {#defining-controller-selectors-and-podtemplate-labels}
241
236
237
+ {{< warning >}}
242
238
<!--
243
239
Updating selectors on controllers is strongly discouraged.
244
240
-->
245
- {{< warning >}}
246
241
不建议在控制器上更新选择器。
247
242
{{< /warning >}}
248
243
@@ -279,5 +274,3 @@ template:
279
274
* [使用配置文件对 Kubernetes 对象进行声明式管理](/zh-cn/docs/tasks/manage-kubernetes-objects/declarative-config/)
280
275
* [Kubectl 命令参考](/docs/reference/generated/kubectl/kubectl-commands/)
281
276
* [Kubernetes API 参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
282
-
283
-
0 commit comments