Skip to content

Commit fd704f0

Browse files
committed
[zh-cn] sync extend-resources/custom-resource-definition-v1.md
Signed-off-by: xin.li <[email protected]>
1 parent d8b01f3 commit fd704f0

File tree

1 file changed

+85
-25
lines changed

1 file changed

+85
-25
lines changed

content/zh-cn/docs/reference/kubernetes-api/extend-resources/custom-resource-definition-v1.md

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ CustomResourceDefinition 表示应在 API 服务器上公开的资源。其名
4141
<!--
4242
Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
4343
-->
44-
标准的对象元数据,更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
44+
标准的对象元数据,更多信息:
45+
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
4546

46-
- **spec** (<a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinitionSpec" >}}">CustomResourceDefinitionSpec</a>), <!--required-->必需
47+
- **spec** (<a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinitionSpec" >}}">CustomResourceDefinitionSpec</a>)<!--required-->必需
4748
<!--
4849
spec describes how the user wants the resources to appear
4950
-->
@@ -298,7 +299,7 @@ CustomResourceDefinitionSpec 描述了用户希望资源的呈现方式。
298299
schema describes the schema used for validation, pruning, and defaulting of this version of the custom resource.
299300
-->
300301

301-
schema 描述了用于验证、精简和默认此版本的自定义资源的模式。
302+
schema 描述了用于验证、精简和默认此版本的自定义资源的模式。
302303

303304
<a name="CustomResourceValidation"></a>
304305
<!--
@@ -321,7 +322,7 @@ CustomResourceDefinitionSpec 描述了用户希望资源的呈现方式。
321322
subresources specify what subresources this version of the defined custom resource have.
322323
-->
323324

324-
subresources 指定此版本已定义的自定义资源具有哪些子资源。
325+
subresources 指定此版本已定义的自定义资源具有哪些子资源。
325326

326327
<a name="CustomResourceSubresources"></a>
327328
<!--
@@ -461,7 +462,7 @@ CustomResourceDefinitionSpec 描述了用户希望资源的呈现方式。
461462
clientConfig is the instructions for how to call the webhook if strategy is `Webhook`.
462463
-->
463464

464-
如果 strategy 是 `Webhook` 那么 clientConfig 是关于如何调用 Webhook 的说明。
465+
如果 strategy 是 `Webhook`,那么 clientConfig 是关于如何调用 Webhook 的说明。
465466

466467
<a name="WebhookClientConfig"></a>
467468
<!--
@@ -581,7 +582,8 @@ CustomResourceDefinitionSpec 描述了用户希望资源的呈现方式。
581582
preserveUnknownFields 表示将对象写入持久性存储时应保留 OpenAPI 模式中未规定的对象字段。
582583
apiVersion、kind、元数据(metadata)和元数据中的已知字段始终保留。不推荐使用此字段,而建议在
583584
`spec.versions[*].schema.openAPIV3Schema` 中设置 `x-preserve-unknown-fields` 为 true。
584-
更多详细信息参见: https://kubernetes.io/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning
585+
更多详细信息参见:
586+
https://kubernetes.io/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning
585587

586588
## JSONSchemaProps {#JSONSchemaProps}
587589

@@ -689,21 +691,23 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
689691
- hostname:互联网主机名的有效表示,由 RFC 1034 第 3.1 节 [RFC1034] 定义
690692
- ipv4:由 Go 语言 net.ParseIP 解析得到的 IPv4 协议的 IP
691693
- ipv6:由 Go 语言 net.ParseIP 解析得到的 IPv6 协议的 IP
692-
- cidr: 由 Go 语言 net.ParseCIDR 解析得到的 CIDR
694+
- cidr由 Go 语言 net.ParseCIDR 解析得到的 CIDR
693695
- mac:由 Go 语言 net.ParseMAC 解析得到的一个 MAC 地址
694696
- uuid:UUID,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
695697
- uuid3:UUID3,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
696698
- uuid4:UUID4,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
697699
- uuid5:UUID5,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
698700
- isbn:一个 ISBN10 或 ISBN13 数字字符串,如 "0321751043" 或 "978-0321751041"
699701
- isbn10:一个 ISBN10 数字字符串,如 "0321751043"
700-
- isbn13: 一个 ISBN13 号码字符串,如 "978-0321751041"
701-
- creditcard:信用卡号码,满足正则表达式 ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$,其中混合任意非数字字符
702+
- isbn13:一个 ISBN13 号码字符串,如 "978-0321751041"
703+
- creditcard:信用卡号码,满足正则表达式
704+
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$,
705+
其中混合任意非数字字符
702706
- ssn:美国社会安全号码,满足正则表达式 ^\d{3}[- ]?\d{2}[- ]?\d{4}$
703707
- hexcolor:一个十六进制的颜色编码,如 "#FFFFFF",满足正则表达式 ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
704708
- rgbcolor:一个 RGB 颜色编码 例如 "rgb(255,255,255)"
705709
- byte:base64 编码的二进制数据
706-
- password: 任何类型的字符串
710+
- password任何类型的字符串
707711
- date:类似 "2006-01-02" 的日期字符串,由 RFC3339 中的完整日期定义
708712
- duration:由 Go 语言 time.ParseDuration 解析的持续时长字符串,如 "22 ns",或与 Scala 持续时间格式兼容。
709713
- datetime:一个日期时间字符串,如 "2014-12-15T19:30:20.000Z",由 RFC3339 中的 date-time 定义。
@@ -808,7 +812,7 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
808812
<!--
809813
x-kubernetes-list-type annotates an array to further describe its topology. This extension must only be used on lists and may have 3 possible values:
810814
-->
811-
x-kubernetes-list-type 注解一个数组以进一步描述其拓扑。此扩展名只能用于列表,并且可能有 3 个可能的值:
815+
x-kubernetes-list-type 注解一个数组以进一步描述其拓扑。此扩展名只能用于列表,并且可能有 3 个可能的值:
812816

813817
<!--
814818
1) `atomic`: the list is treated as a single entity, like a scalar.
@@ -840,7 +844,7 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
840844
<!--
841845
x-kubernetes-map-type annotates an object to further describe its topology. This extension must only be used when type is object and may have 2 possible values:
842846
-->
843-
x-kubernetes-map-type 注解一个对象以进一步描述其拓扑。此扩展只能在 type 为 object 时使用,并且可能有 2 个可能的值:
847+
x-kubernetes-map-type 注解一个对象以进一步描述其拓扑。此扩展只能在 type 为 object 时使用,并且可能有 2 个可能的值:
844848

845849
<!--
846850
1) `granular`:
@@ -895,7 +899,10 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
895899
- **x-kubernetes-validations.rule** (string),必需
896900

897901
<!--
898-
Rule represents the expression which will be evaluated by CEL. ref: https://github.com/google/cel-spec The Rule is scoped to the location of the x-kubernetes-validations extension in the schema. The `self` variable in the CEL expression is bound to the scoped value. Example: - Rule scoped to the root of a resource with a status subresource: {"rule": "self.status.actual \<= self.spec.maxDesired"}
902+
Rule represents the expression which will be evaluated by CEL. ref: https://github.com/google/cel-spec.
903+
The Rule is scoped to the location of the x-kubernetes-validations extension in the schema.
904+
The `self` variable in the CEL expression is bound to the scoped value.
905+
Example: - Rule scoped to the root of a resource with a status subresource: {"rule": "self.status.actual \<= self.spec.maxDesired"}
899906
-->
900907

901908
rule 表示将由 CEL 评估的表达式。参考: https://github.com/google/cel-spec。
@@ -984,10 +991,35 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
984991
- 'map':`X + Y` 执行合并,保留 `X` 中所有键的数组位置,但当 `X``Y` 的键集相交时,会被 `Y` 中的值覆盖。
985992
添加 `Y` 中具有不相交键的元素,保持其局顺序。
986993

994+
- **x-kubernetes-validations.fieldPath** (string)
995+
996+
<!--
997+
fieldPath represents the field path returned when the validation fails.
998+
It must be a relative JSON path (i.e. with array notation) scoped to the location of this
999+
x-kubernetes-validations extension in the schema and refer to an existing field.
1000+
e.g. when validation checks if a specific attribute `foo` under a map `testMap`, the fieldPath could be set to `.testMap.foo`
1001+
If the validation checks two lists must have unique attributes, the fieldPath could be set to either of the list: e.g. `.testList`
1002+
It does not support list numeric index. It supports child operation to refer to an existing field currently.
1003+
Refer to [JSONPath support in Kubernetes](https://kubernetes.io/docs/reference/kubectl/jsonpath/) for more info.
1004+
Numeric index of array is not supported. For field name which contains special characters, use `['specialName']` to refer the field name.
1005+
e.g. for attribute `foo.34$` appears in a list `testList`, the fieldPath could be set to `.testList['foo.34$']`
1006+
-->
1007+
1008+
fieldPath 表示验证失败时返回的字段路径。
1009+
它必须是相对 JSON 路径(即,支持数组表示法),范围仅限于此 x-kubernetes-validations
1010+
扩展在模式的位置,并引用现有字段。
1011+
例如,当验证检查 `testMap` 映射下是否有 `foo` 属性时,可以将 fieldPath 设置为 `.testMap.foo`
1012+
如果验证需要确保两个列表具有各不相同的属性,则可以将 fieldPath 设置到其中任一列表,例如 `.testList`
1013+
它支持使用子操作引用现有字段,而不支持列表的数字索引。
1014+
有关更多信息,请参阅 [Kubernetes 中的 JSONPath 支持](https://kubernetes.io/docs/reference/kubectl/jsonpath/)
1015+
因为其不支持数组的数字索引,所以对于包含特殊字符的字段名称,请使用 `['specialName']` 来引用字段名称。
1016+
例如,对于出现在列表 `testList` 中的属性 `foo.34$`,fieldPath 可以设置为 `.testList['foo.34$']`
1017+
9871018
- **x-kubernetes-validations.message** (string)
9881019

9891020
<!--
990-
Message represents the message displayed when validation fails. The message is required if the Rule contains line breaks. The message must not contain line breaks. If unset, the message is "failed rule: {Rule}". e.g. "must be a URL with the host matching spec.host"
1021+
Message represents the message displayed when validation fails. The message is required if the Rule contains line breaks.
1022+
The message must not contain line breaks. If unset, the message is "failed rule: {Rule}". e.g. "must be a URL with the host matching spec.host"
9911023
-->
9921024

9931025
message 表示验证失败时显示的消息。如果规则包含换行符,则需要该消息。消息不能包含换行符。
@@ -996,8 +1028,17 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
9961028
- **x-kubernetes-validations.messageExpression** (string)
9971029

9981030
<!--
999-
MessageExpression declares a CEL expression that evaluates to the validation failure message that is returned when this rule fails. Since messageExpression is used as a failure message, it must evaluate to a string. If both message and messageExpression are present on a rule, then messageExpression will be used if validation fails. If messageExpression results in a runtime error, the runtime error is logged, and the validation failure message is produced as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string with only spaces, or a string that contains line breaks, then the validation failure message will also be produced as if the messageExpression field were unset, and the fact that messageExpression produced an empty string/string with only spaces/string with line breaks will be logged. messageExpression has access to all the same variables as the rule; the only difference is the return type. Example: "x must be less than max ("+string(self.max)+")"
1031+
MessageExpression declares a CEL expression that evaluates to the validation failure message that
1032+
is returned when this rule fails. Since messageExpression is used as a failure message, it must evaluate to a string.
1033+
If both message and messageExpression are present on a rule, then messageExpression will be used if validation fails.
1034+
If messageExpression results in a runtime error, the runtime error is logged, and the validation failure message is
1035+
produced as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string
1036+
with only spaces, or a string that contains line breaks, then the validation failure message will also be produced
1037+
as if the messageExpression field were unset, and the fact that messageExpression produced an empty string/string
1038+
with only spaces/string with line breaks will be logged. messageExpression has access to all the same variables as the rule;
1039+
the only difference is the return type. Example: "x must be less than max ("+string(self.max)+")"
10001040
-->
1041+
10011042
messageExpression 声明一个 CEL 表达式,其计算结果是此规则失败时返回的验证失败消息。
10021043
由于 messageExpression 用作失败消息,因此它的值必须是一个字符串。
10031044
如果在规则中同时存在 message 和 messageExpression,则在验证失败时使用 messageExpression。
@@ -1008,6 +1049,24 @@ JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版
10081049
messageExpression 可以访问的变量与规则相同;唯一的区别是返回类型。
10091050
例如:"x must be less than max ("+string(self.max)+")"。
10101051

1052+
- **x-kubernetes-validations.reason** (string)
1053+
1054+
<!--
1055+
reason provides a machine-readable validation failure reason that is returned to the caller
1056+
when a request fails this validation rule. The HTTP status code returned to the caller will
1057+
match the reason of the reason of the first failed validation rule.
1058+
The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequired",
1059+
"FieldValueDuplicate". If not set, default to use "FieldValueInvalid".
1060+
All future added reasons must be accepted by clients when reading this value and unknown
1061+
reasons should be treated as FieldValueInvalid.
1062+
-->
1063+
1064+
reason 提供机器可读的验证失败原因,当请求未通过此验证规则时,该原因会返回给调用者。
1065+
返回给调用者的 HTTP 状态代码将与第一个失败的验证规则的原因相匹配。
1066+
目前支持的原因有:`FieldValueInvalid``FieldValueForbidden``FieldValueRequired``FieldValueDuplicate`
1067+
如果未设置,则默认使用 `FieldValueInvalid`
1068+
所有未来添加的原因在读取该值时必须被客户端接受,未知原因应被视为 `FieldValueInvalid`
1069+
10111070
## CustomResourceDefinitionStatus {#CustomResourceDefinitionStatus}
10121071

10131072
<!--
@@ -1066,15 +1125,15 @@ CustomResourceDefinitionStatus 表示 CustomResourceDefinition 的状态。
10661125
listKind is the serialized kind of the list for this resource. Defaults to "`kind`List".
10671126
-->
10681127

1069-
listKind 是此资源列表的序列化类型。默认为 "`<kind>List`"。
1128+
listKind 是此资源列表的序列化类型。默认为 "`<kind>List`"。
10701129

10711130
- **acceptedNames.shortNames** ([]string)
10721131

10731132
<!--
10741133
shortNames are short names for the resource, exposed in API discovery documents, and used by clients to support invocations like `kubectl get \<shortname>`. It must be all lowercase.
10751134
-->
10761135

1077-
shortNames 是资源的短名称,在 API 发现文档中公开,并支持客户端调用,如 `kubectl get <shortname>`。必须全部小写。
1136+
shortNames 是资源的短名称,在 API 发现文档中公开,并支持客户端调用,如 `kubectl get <shortname>`。必须全部小写。
10781137

10791138
- **acceptedNames.singular** (string)
10801139

@@ -1205,7 +1264,8 @@ CustomResourceDefinitionList 是 CustomResourceDefinition 对象的列表。
12051264
Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
12061265
-->
12071266

1208-
标准的对象元数据,更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
1267+
标准的对象元数据,更多信息:
1268+
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
12091269

12101270
## Operations {#Operations}
12111271

@@ -1372,7 +1432,7 @@ POST /apis/apiextensions.k8s.io/v1/customresourcedefinitions
13721432
-->
13731433
#### 参数
13741434

1375-
- **body**: <a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
1435+
- **body**<a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
13761436

13771437
- **dryRun** <!--(*in query*):-->**查询参数**):string
13781438

@@ -1429,7 +1489,7 @@ PUT /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}
14291489

14301490
CustomResourceDefinition 的名称。
14311491

1432-
- **body**: <a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
1492+
- **body**<a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
14331493

14341494
- **dryRun** <!--(*in query*):-->**查询参数**):string
14351495

@@ -1484,7 +1544,7 @@ PUT /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status
14841544

14851545
CustomResourceDefinition 的名称。
14861546

1487-
- **body**: <a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
1547+
- **body**<a href="{{< ref "../extend-resources/custom-resource-definition-v1#CustomResourceDefinition" >}}">CustomResourceDefinition</a>,必需
14881548

14891549
- **dryRun** <!--(*in query*):-->**查询参数**):string
14901550

@@ -1539,7 +1599,7 @@ PATCH /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}
15391599

15401600
CustomResourceDefinition 的名称。
15411601

1542-
- **body**: <a href="{{< ref "../common-definitions/patch#Patch" >}}">Patch</a>,必需
1602+
- **body**<a href="{{< ref "../common-definitions/patch#Patch" >}}">Patch</a>,必需
15431603

15441604
- **dryRun** <!--(*in query*):-->**查询参数**):string
15451605

@@ -1598,7 +1658,7 @@ PATCH /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status
15981658

15991659
CustomResourceDefinition 的名称。
16001660

1601-
- **body**: <a href="{{< ref "../common-definitions/patch#Patch" >}}">Patch</a>,必需
1661+
- **body**<a href="{{< ref "../common-definitions/patch#Patch" >}}">Patch</a>,必需
16021662

16031663
- **dryRun** <!--(*in query*):-->**查询参数**):string
16041664

@@ -1655,7 +1715,7 @@ DELETE /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}
16551715

16561716
CustomResourceDefinition 的名称。
16571717

1658-
- **body**: <a href="{{< ref "../common-definitions/delete-options#DeleteOptions" >}}">DeleteOptions</a>
1718+
- **body**<a href="{{< ref "../common-definitions/delete-options#DeleteOptions" >}}">DeleteOptions</a>
16591719

16601720
- **dryRun** <!--(*in query*):-->**查询参数**):string
16611721

@@ -1700,7 +1760,7 @@ DELETE /apis/apiextensions.k8s.io/v1/customresourcedefinitions
17001760
-->
17011761
#### 参数
17021762

1703-
- **body**: <a href="{{< ref "../common-definitions/delete-options#DeleteOptions" >}}">DeleteOptions</a>
1763+
- **body**<a href="{{< ref "../common-definitions/delete-options#DeleteOptions" >}}">DeleteOptions</a>
17041764

17051765
- **continue** <!--(*in query*):-->**查询参数**):string
17061766

0 commit comments

Comments
 (0)