Skip to content

Commit be413f6

Browse files
committed
[zh] sync custom-resource-definition-versioning.md
1 parent 453dd71 commit be413f6

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

content/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ API 升级时需要在不同 API 表示形式之间进行转换。
3131
{{< include "task-tutorial-prereqs.md" >}}
3232

3333
<!--
34-
You should have a initial understanding of [custom resources](/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
34+
You should have an initial understanding of [custom resources](/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
3535
-->
3636
你应该对[定制资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)有一些初步了解。
3737

@@ -71,10 +71,10 @@ CustomResourceDefinition API 提供了引入和升级 CustomResourceDefinition
7171
<!--
7272
Adding a new version:
7373
74-
1. Pick a conversion strategy. Since custom resource objects need to be able to
75-
be served at both versions, that means they will sometimes be served at a
76-
different version than their storage version. In order for this to be
77-
possible, the custom resource objects must sometimes be converted between the
74+
1. Pick a conversion strategy. Since custom resource objects need the ability to
75+
be served at both versions, that means they will sometimes be served in a
76+
different version than the one stored. To make this possible, the custom
77+
resource objects must sometimes be converted between the
7878
version they are stored at and the version they are served at. If the
7979
conversion involves schema changes and requires custom logic, a conversion
8080
webhook should be used. If there are no schema changes, the default `None`
@@ -95,7 +95,7 @@ Adding a new version:
9595
并且需要自定义逻辑,则应该使用 Webhook 来完成。如果没有模式变更,
9696
则可使用默认的 `None` 转换策略,为不同版本提供服务时只有 `apiVersion` 字段会被改变。
9797
2. 如果使用转换 Webhook,请创建并部署转换 Webhook。更多详细信息请参见
98-
[Webhook conversion](#webhook-conversion)
98+
[Webhook 转换](#webhook-conversion)
9999
3. 更新 CustomResourceDefinition,将新版本设置为 `served:true`,加入到
100100
`spec.versions` 列表。另外,还要设置 `spec.conversion` 字段为所选的转换策略。
101101
如果使用转换 Webhook,请配置 `spec.conversion.webhookClientConfig` 来调用 Webhook。
@@ -172,12 +172,12 @@ CustomResourceDefinition API 的 `versions` 字段可用于支持你所开发的
172172
[API 变更文档](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md)
173173
以获取一些有用的问题和建议。
174174

175+
{{< note >}}
175176
<!--
176177
In `apiextensions.k8s.io/v1beta1`, there was a `version` field instead of `versions`. The
177178
`version` field is deprecated and optional, but if it is not empty, it must
178179
match the first item in the `versions` field.
179180
-->
180-
{{< note >}}
181181
`apiextensions.k8s.io/v1beta1` 版本中曾经有一个 `version` 字段,
182182
名字不叫做 `versions`。该 `version` 字段已经被废弃,成为可选项。
183183
不过如果该字段不是空,则必须与 `versions` 字段中的第一个条目匹配。
@@ -412,7 +412,7 @@ When API requests to a deprecated version of that resource are made, a warning m
412412
The warning message for each deprecated version of the resource can be customized if desired.
413413
-->
414414
从 v1.19 开始,CustomResourceDefinition 可以指示其定义的资源的特定版本已废弃。
415-
当 CustomResourceDefinition 该资源的已废弃版本发出 API 请求时,会在 API 响应中以报头的形式返回警告消息。
415+
当该资源的已废弃版本发出 API 请求时,会在 API 响应中以报头的形式返回警告消息。
416416
如果需要,可以自定义每个不推荐使用的资源版本的警告消息。
417417

418418
<!--
@@ -439,6 +439,7 @@ spec:
439439
versions:
440440
- name: v1alpha1
441441
served: true
442+
storage: false
442443
# 此属性标明此定制资源的 v1alpha1 版本已被弃用。
443444
# 发给此版本的 API 请求会在服务器响应中收到警告消息头。
444445
deprecated: true
@@ -476,6 +477,7 @@ spec:
476477
versions:
477478
- name: v1alpha1
478479
served: true
480+
storage: false
479481
# 此属性标明此定制资源的 v1alpha1 版本已被弃用。
480482
# 发给此版本的 API 请求会在服务器响应中收到警告消息头。
481483
deprecated: true
@@ -538,11 +540,11 @@ Webhook conversion is available as beta since 1.15, and as alpha since Kubernete
538540

539541
{{< feature-state state="stable" for_k8s_version="v1.16" >}}
540542

543+
{{< note >}}
541544
<!--
542545
Webhook conversion is available as beta since 1.15, and as alpha since Kubernetes 1.13. The
543546
`CustomResourceWebhookConversion` feature must be enabled, which is the case automatically for many clusters for beta features. Please refer to the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) documentation for more information.
544547
-->
545-
{{< note >}}
546548
Webhook 转换在 Kubernetes 1.13 版本作为 Alpha 功能引入,在 Kubernetes 1.15 版本中成为 Beta 功能。
547549
要使用此功能,应启用 `CustomResourceWebhookConversion` 特性。
548550
在大多数集群上,这类 Beta 特性应该是自动启用的。
@@ -602,6 +604,7 @@ Webhook 处理由 API 服务器发送的 `ConversionReview` 请求,并在
602604
[framework 文件](https://github.com/kubernetes/kubernetes/tree/v1.15.0/test/images/crd-conversion-webhook/converter/framework.go)中,
603605
只留下[一个函数](https://github.com/kubernetes/kubernetes/blob/v1.13.0/test/images/crd-conversion-webhook/converter/example_converter.go#L29-L80)用于实现不同的转换。
604606

607+
{{< note >}}
605608
<!--
606609
The example conversion webhook server leaves the `ClientAuth` field
607610
[empty](https://github.com/kubernetes/kubernetes/tree/v1.13.0/test/images/crd-conversion-webhook/config.go#L47-L48),
@@ -610,7 +613,6 @@ authenticate the identity of the clients, supposedly API servers. If you need
610613
mutual TLS or other ways to authenticate the clients, see
611614
how to [authenticate API servers](/docs/reference/access-authn-authz/extensible-admission-controllers/#authenticate-apiservers).
612615
-->
613-
{{< note >}}
614616
转换 Webhook 服务器示例中将 `ClientAuth`
615617
字段设置为[空](https://github.com/kubernetes/kubernetes/tree/v1.13.0/test/images/crd-conversion-webhook/config.go#L47-L48),
616618
默认为 `NoClientCert`。
@@ -642,20 +644,20 @@ The assumption for next sections is that the conversion webhook server is deploy
642644
-->
643645
### 部署转换 Webhook 服务 {#deploy-the-conversion-webhook-service}
644646

645-
用于部署转换 webhook
647+
用于部署转换 Webhook
646648
的文档与[准入 Webhook 服务示例](/zh-cn/docs/reference/access-authn-authz/extensible-admission-controllers/#deploy_the_admission_webhook_service)相同。
647649
这里的假设是转换 Webhook 服务器被部署为 `default` 名字空间中名为
648650
`example-conversion-webhook-server` 的服务,并在路径 `/crdconvert`
649651
上处理请求。
650652

653+
{{< note >}}
651654
<!--
652655
When the webhook server is deployed into the Kubernetes cluster as a
653656
service, it has to be exposed via a service on port 443 (The server
654657
itself can have an arbitrary port but the service object should map it to port 443).
655658
The communication between the API server and the webhook service may fail
656659
if a different port is used for the service.
657660
-->
658-
{{< note >}}
659661
当 Webhook 服务器作为一个服务被部署到 Kubernetes 集群中时,它必须通过端口 443
660662
公开其服务(服务器本身可以使用任意端口,但是服务对象应该将它映射到端口 443)。
661663
如果为服务器使用不同的端口,则 API 服务器和 Webhook 服务器之间的通信可能会失败。
@@ -853,7 +855,7 @@ risky unless you take great care to run this webhook on all hosts
853855
which run an apiserver which might need to make calls to this
854856
webhook. Such installations are likely to be non-portable or not readily run in a new cluster.
855857
-->
856-
url 以标准 URL 形式给出 Webhook 的位置(`scheme://host:port/path`)。
858+
`url` 以标准 URL 形式给出 Webhook 的位置(`scheme://host:port/path`)。
857859
`host` 不应引用集群中运行的服务,而应通过指定 `service` 字段来提供服务引用。
858860
在某些 API 服务器中,`host` 可以通过外部 DNS 进行解析(即
859861
`kube-apiserver` 无法解析集群内 DNS,那样会违反分层规则)。
@@ -1176,7 +1178,7 @@ Example of a minimal successful response from a webhook:
11761178

11771179
Webhook 响应包含 200 HTTP 状态代码、`Content-Type: application/json`,
11781180
在主体中包含 JSON 序列化形式的数据,在 `response` 节中给出
1179-
ConversionReview 对象(与发送的版本相同)。
1181+
`ConversionReview` 对象(与发送的版本相同)。
11801182

11811183
如果转换成功,则 Webhook 应该返回包含以下字段的 `response` 节:
11821184

@@ -1427,7 +1429,7 @@ API 服务器在状态字段 `storedVersions` 中记录曾被标记为存储版
14271429
<!--
14281430
## Upgrade existing objects to a new stored version
14291431
-->
1430-
## 将现有对象升级到新的存储版本 {#upgrade-existing-objects-to-a-new-stored-version}
1432+
## 将现有对象升级到新的存储版本 {#upgrade-existing-objects-to-a-new-stored-version}
14311433

14321434
<!--
14331435
When deprecating versions and dropping support, select a storage upgrade

0 commit comments

Comments
 (0)