You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -309,25 +315,30 @@ If you later recreate the same CustomResourceDefinition, it will start out empty
309
315
<!--
310
316
## Specifying a structural schema
311
317
312
-
CustomResources store structured data in custom fiels (alongside the built-in fields `apiVersion`, `kind` and `metadata`, which the API server validates implicitly). With [OpenAPI v3.0 validation](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) a schema can be specified, which is validated during creation and updates, compare below for details and limits of such a schema.
318
+
CustomResources store structured data in custom fiels (alongside the built-in
319
+
fields `apiVersion`, `kind` and `metadata`, which the API server validates
320
+
implicitly). With [OpenAPI v3.0 validation](#validation) a schema can be
321
+
specified, which is validated during creation and updates, compare below for
322
+
details and limits of such a schema.
313
323
314
-
With `apiextensions.k8s.io/v1` the definition of a structural schema is mandatory for CustomResourceDefinitions (in the beta version of CustomResourceDefinition, structural schemas were optional).
324
+
With `apiextensions.k8s.io/v1` the definition of a structural schema is
325
+
mandatory for CustomResourceDefinitions. In the beta version of
326
+
CustomResourceDefinition, structural schemas were optional.
315
327
-->
316
328
## 设置结构化的模式 {#specifying-a-structural-schema}
317
329
318
330
CustomResource 对象在定制字段中保存结构化的数据,这些字段和内置的字段
319
331
`apiVersion`、`kind` 和 `metadata` 等一起存储,不过内置的字段都会被 API
A structural schema is an [OpenAPI v3.0 validation schema](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) which:
341
+
A structural schema is an [OpenAPI v3.0 validation schema](#validation) which:
331
342
332
343
1. specifies a non-empty type (via `type` in OpenAPI) for the root, for each specified field of an object node (via `properties` or `additionalProperties` in OpenAPI) and for each item in an array node (via `items` in OpenAPI), with the exception of:
333
344
* a node with `x-kubernetes-int-or-string: true`
@@ -445,7 +456,7 @@ is not a structural schema because of the following violations:
445
456
* `bar` inside of `anyOf` is not specified outside (rule 2).
446
457
* `bar`'s `type` is within `anyOf` (rule 3).
447
458
* the description is set within `anyOf` (rule 3).
448
-
* `metadata.finalizer` might not be restricted (rule 4).
459
+
* `metadata.finalizers` might not be restricted (rule 4).
449
460
-->
450
461
不是一个结构化的模式,因为其中存在以下违例:
451
462
@@ -454,7 +465,7 @@ is not a structural schema because of the following violations:
454
465
* `anyOf` 中的 `bar` 未在外部指定(规则 2)
455
466
* `bar` 的 `type` 位于 `anyOf` 中(规则 3)
456
467
* `anyOf` 中设置了 `description` (规则 3)
457
-
* `metadata.finalizer` 不可以被限制 (规则 4)
468
+
* `metadata.finalizers` 不可以被限制 (规则 4)
458
469
459
470
<!--
460
471
In contrast, the following, corresponding schema is structural:
@@ -510,7 +521,7 @@ CRDs converted from `apiextensions.k8s.io/v1beta1` to
510
521
511
522
For migrated CustomResourceDefinitions where `spec.preserveUnknownFields` is
512
523
set, pruning is _not_ enabled and you can store arbitrary data. For best
513
-
compatibility, you should update customer resources to meet an OpenAPI schema,
524
+
compatibility, you should update your custom resources to meet an OpenAPI schema,
514
525
and you should set `spec.preserveUnknownFields` true for the
515
526
CustomResourceDefinition itself.
516
527
-->
@@ -577,7 +588,7 @@ Notice that the field `someRandomField` was pruned.
577
588
578
589
<!--
579
590
This example turned off client-side validation to demonstrate the API server's behavior, by adding the `--validate=false` command line option.
580
-
Because the [OpenAPI validation schemas are also published](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#publish-validation-schema-in-openapi-v2)
591
+
Because the [OpenAPI validation schemas are also published](#publish-validation-schema-in-openapi-v2)
581
592
to clients, `kubectl` also checks for unknown fields and rejects those objects well before they would be sent to the API server.
582
593
-->
583
594
本例中通过 `--validate=false` 命令行选项 关闭了客户端的合法性检查以展示 API 服务器的行为,
@@ -588,13 +599,13 @@ to clients, `kubectl` also checks for unknown fields and rejects those objects w
588
599
<!--
589
600
#### Controlling pruning
590
601
591
-
By default, all unspecified fields for a custom resource, across all versions, are pruned. It is possible though to opt-out of that for specifc sub-trees fof fields by adding `x-kubernetes-preserve-unknown-fields: true` in the [structural OpenAPI v3 validation schema](#specifying-a-structural-schema).
602
+
By default, all unspecified fields for a custom resource, across all versions, are pruned. It is possible though to opt-out of that for specifc sub-trees fof fields by adding `x-kubernetes-preserve-unknown-fields: true` in the [structural OpenAPI v3 validation schema](#specifying-a-structural-schema).
With one of those specification, both an integer and a string validate.
733
744
734
-
In [Validation Schema Publishing](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#publish-validation-schema-in-openapi-v2),
745
+
In [Validation Schema Publishing](#publish-validation-schema-in-openapi-v2),
735
746
`x-kubernetes-int-or-string: true` is unfolded to one of the two patterns shown above.
[OpenAPI v3 schemas](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject) and you can add additional validation using [admission webhooks](/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook).
These fields can only be set with specific features enabled:
927
-
928
-
- `default`: can be set for `apiextensions.k8s.io/v1` CustomResourceDefinitions. Defaulting is in GA since 1.17 (beta since 1.16 with the `CustomResourceDefaulting` feature gate to be enabled, which is the case automatically for many clusters for beta features). Compare [Validation Schema Defaulting](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting).
936
+
The `default` field can be set when the [Defaulting feature](#defaulting) is enabled,
937
+
which is the case with `apiextensions.k8s.io/v1` CustomResourceDefinitions.
938
+
Defaulting is in GA since 1.17 (beta since 1.16 with the `CustomResourceDefaulting`
Refer to the [structural schemas](#specifying-a-structural-schema) section for other
952
+
restrictions and CustomResourceDefinition features.
953
+
-->
939
954
关于对某些 CustomResourceDefinition 特性所必需的限制,可参见
940
-
[结构化的模式定义](#specifying-a-structural-schema)。
941
-
{{< /note >}}
955
+
[结构化的模式定义](#specifying-a-structural-schema)小节。
942
956
943
957
<!--
944
958
The schema is defined in the CustomResourceDefinition. In the following example, the
@@ -1203,7 +1217,7 @@ Default values for `metadata` fields of `x-kubernetes-embedded-resources: true`
1203
1217
<!--
1204
1218
### Publish Validation Schema in OpenAPI v2
1205
1219
1206
-
CustomResourceDefinition [OpenAPI v3 validation schemas](#validation) which are [structural](#specifying-a-structural-schema) and [enable pruning](#preserving-unknown-fields) are published as part of the [OpenAPI v2 spec](/docs/concepts/overview/kubernetes-api/#openapi-and-swagger-definitions) from Kubernetes API server.
1220
+
CustomResourceDefinition [OpenAPI v3 validation schemas](#validation) which are [structural](#specifying-a-structural-schema) and [enable pruning](#field-pruning) are published as part of the [OpenAPI v2 spec](/docs/concepts/overview/kubernetes-api/#openapi-and-swagger-definitions) from Kubernetes API server.
1207
1221
1208
1222
The [kubectl](/docs/reference/kubectl/overview) command-line tool consumes the published schema to perform client-side validation (`kubectl create` and `kubectl apply`), schema explanation (`kubectl explain`) on custom resources. The published schema can be consumed for other purposes as well, like client generation or documentation.
1209
1223
-->
@@ -1356,15 +1370,15 @@ The `NAME` column is implicit and does not need to be defined in the CustomResou
1356
1370
<!--
1357
1371
#### Priority
1358
1372
1359
-
Each column includes a `priority` field for each column. Currently, the priority
1373
+
Each column includes a `priority` field. Currently, the priority
1360
1374
differentiates between columns shown in standard view or wide view (using the `-o wide` flag).
1361
1375
1362
1376
- Columns with priority `0` are shown in standard view.
1363
1377
- Columns with priority greater than `0` are shown only in wide view.
0 commit comments