@@ -31,7 +31,7 @@ API 升级时需要在不同 API 表示形式之间进行转换。
31
31
{{< include "task-tutorial-prereqs.md" >}}
32
32
33
33
<!--
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/).
35
35
-->
36
36
你应该对[ 定制资源] ( /zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/ ) 有一些初步了解。
37
37
@@ -71,10 +71,10 @@ CustomResourceDefinition API 提供了引入和升级 CustomResourceDefinition
71
71
<!--
72
72
Adding a new version:
73
73
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
78
78
version they are stored at and the version they are served at. If the
79
79
conversion involves schema changes and requires custom logic, a conversion
80
80
webhook should be used. If there are no schema changes, the default `None`
@@ -95,7 +95,7 @@ Adding a new version:
95
95
并且需要自定义逻辑,则应该使用 Webhook 来完成。如果没有模式变更,
96
96
则可使用默认的 ` None ` 转换策略,为不同版本提供服务时只有 ` apiVersion ` 字段会被改变。
97
97
2 . 如果使用转换 Webhook,请创建并部署转换 Webhook。更多详细信息请参见
98
- [ Webhook conversion ] ( #webhook-conversion ) 。
98
+ [ Webhook 转换 ] ( #webhook-conversion ) 。
99
99
3 . 更新 CustomResourceDefinition,将新版本设置为 ` served:true ` ,加入到
100
100
` spec.versions ` 列表。另外,还要设置 ` spec.conversion ` 字段为所选的转换策略。
101
101
如果使用转换 Webhook,请配置 ` spec.conversion.webhookClientConfig ` 来调用 Webhook。
@@ -172,12 +172,12 @@ CustomResourceDefinition API 的 `versions` 字段可用于支持你所开发的
172
172
[ API 变更文档] ( https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md )
173
173
以获取一些有用的问题和建议。
174
174
175
+ {{< note >}}
175
176
<!--
176
177
In `apiextensions.k8s.io/v1beta1`, there was a `version` field instead of `versions`. The
177
178
`version` field is deprecated and optional, but if it is not empty, it must
178
179
match the first item in the `versions` field.
179
180
-->
180
- {{< note >}}
181
181
在 ` apiextensions.k8s.io/v1beta1 ` 版本中曾经有一个 ` version ` 字段,
182
182
名字不叫做 ` versions ` 。该 ` version ` 字段已经被废弃,成为可选项。
183
183
不过如果该字段不是空,则必须与 ` versions ` 字段中的第一个条目匹配。
@@ -412,7 +412,7 @@ When API requests to a deprecated version of that resource are made, a warning m
412
412
The warning message for each deprecated version of the resource can be customized if desired.
413
413
-->
414
414
从 v1.19 开始,CustomResourceDefinition 可以指示其定义的资源的特定版本已废弃。
415
- 当 CustomResourceDefinition 该资源的已废弃版本发出 API 请求时,会在 API 响应中以报头的形式返回警告消息。
415
+ 当该资源的已废弃版本发出 API 请求时,会在 API 响应中以报头的形式返回警告消息。
416
416
如果需要,可以自定义每个不推荐使用的资源版本的警告消息。
417
417
418
418
<!--
@@ -439,6 +439,7 @@ spec:
439
439
versions:
440
440
- name: v1alpha1
441
441
served: true
442
+ storage: false
442
443
# 此属性标明此定制资源的 v1alpha1 版本已被弃用。
443
444
# 发给此版本的 API 请求会在服务器响应中收到警告消息头。
444
445
deprecated: true
@@ -476,6 +477,7 @@ spec:
476
477
versions:
477
478
- name: v1alpha1
478
479
served: true
480
+ storage: false
479
481
# 此属性标明此定制资源的 v1alpha1 版本已被弃用。
480
482
# 发给此版本的 API 请求会在服务器响应中收到警告消息头。
481
483
deprecated: true
@@ -538,11 +540,11 @@ Webhook conversion is available as beta since 1.15, and as alpha since Kubernete
538
540
539
541
{{< feature-state state="stable" for_k8s_version="v1.16" >}}
540
542
543
+ {{< note >}}
541
544
<!--
542
545
Webhook conversion is available as beta since 1.15, and as alpha since Kubernetes 1.13. The
543
546
` 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.
544
547
-->
545
- {{< note >}}
546
548
Webhook 转换在 Kubernetes 1.13 版本作为 Alpha 功能引入,在 Kubernetes 1.15 版本中成为 Beta 功能。
547
549
要使用此功能,应启用 `CustomResourceWebhookConversion` 特性。
548
550
在大多数集群上,这类 Beta 特性应该是自动启用的。
@@ -602,6 +604,7 @@ Webhook 处理由 API 服务器发送的 `ConversionReview` 请求,并在
602
604
[framework 文件](https://github.com/kubernetes/kubernetes/tree/v1.15.0/test/images/crd-conversion-webhook/converter/framework.go)中,
603
605
只留下[一个函数](https://github.com/kubernetes/kubernetes/blob/v1.13.0/test/images/crd-conversion-webhook/converter/example_converter.go#L29-L80)用于实现不同的转换。
604
606
607
+ {{< note >}}
605
608
<!--
606
609
The example conversion webhook server leaves the `ClientAuth` field
607
610
[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
610
613
mutual TLS or other ways to authenticate the clients, see
611
614
how to [authenticate API servers](/docs/reference/access-authn-authz/extensible-admission-controllers/#authenticate-apiservers).
612
615
-->
613
- {{< note >}}
614
616
转换 Webhook 服务器示例中将 `ClientAuth`
615
617
字段设置为[空](https://github.com/kubernetes/kubernetes/tree/v1.13.0/test/images/crd-conversion-webhook/config.go#L47-L48),
616
618
默认为 `NoClientCert`。
@@ -642,20 +644,20 @@ The assumption for next sections is that the conversion webhook server is deploy
642
644
-->
643
645
# ## 部署转换 Webhook 服务 {#deploy-the-conversion-webhook-service}
644
646
645
- 用于部署转换 webhook
647
+ 用于部署转换 Webhook
646
648
的文档与[准入 Webhook 服务示例](/zh-cn/docs/reference/access-authn-authz/extensible-admission-controllers/#deploy_the_admission_webhook_service)相同。
647
649
这里的假设是转换 Webhook 服务器被部署为 `default` 名字空间中名为
648
650
` example-conversion-webhook-server` 的服务,并在路径 `/crdconvert`
649
651
上处理请求。
650
652
653
+ {{< note >}}
651
654
<!--
652
655
When the webhook server is deployed into the Kubernetes cluster as a
653
656
service, it has to be exposed via a service on port 443 (The server
654
657
itself can have an arbitrary port but the service object should map it to port 443).
655
658
The communication between the API server and the webhook service may fail
656
659
if a different port is used for the service.
657
660
-->
658
- {{< note >}}
659
661
当 Webhook 服务器作为一个服务被部署到 Kubernetes 集群中时,它必须通过端口 443
660
662
公开其服务(服务器本身可以使用任意端口,但是服务对象应该将它映射到端口 443)。
661
663
如果为服务器使用不同的端口,则 API 服务器和 Webhook 服务器之间的通信可能会失败。
@@ -853,7 +855,7 @@ risky unless you take great care to run this webhook on all hosts
853
855
which run an apiserver which might need to make calls to this
854
856
webhook. Such installations are likely to be non-portable or not readily run in a new cluster.
855
857
-->
856
- url 以标准 URL 形式给出 Webhook 的位置(`scheme://host:port/path`)。
858
+ ` url` 以标准 URL 形式给出 Webhook 的位置(`scheme://host:port/path`)。
857
859
` host` 不应引用集群中运行的服务,而应通过指定 `service` 字段来提供服务引用。
858
860
在某些 API 服务器中,`host` 可以通过外部 DNS 进行解析(即
859
861
` kube-apiserver` 无法解析集群内 DNS,那样会违反分层规则)。
@@ -1176,7 +1178,7 @@ Example of a minimal successful response from a webhook:
1176
1178
1177
1179
Webhook 响应包含 200 HTTP 状态代码、`Content-Type : application/json`,
1178
1180
在主体中包含 JSON 序列化形式的数据,在 `response` 节中给出
1179
- ConversionReview 对象(与发送的版本相同)。
1181
+ ` ConversionReview` 对象(与发送的版本相同)。
1180
1182
1181
1183
如果转换成功,则 Webhook 应该返回包含以下字段的 `response` 节:
1182
1184
@@ -1427,7 +1429,7 @@ API 服务器在状态字段 `storedVersions` 中记录曾被标记为存储版
1427
1429
<!--
1428
1430
# # Upgrade existing objects to a new stored version
1429
1431
-->
1430
- # # 将现有对象升级到新的存储版本 {#upgrade-existing-objects-to-a-new-stored-version}
1432
+ # # 将现有对象升级到新的存储版本 {#upgrade-existing-objects-to-a-new-stored-version}
1431
1433
1432
1434
<!--
1433
1435
When deprecating versions and dropping support, select a storage upgrade
0 commit comments