Skip to content

Commit

Permalink
summarize the modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
roycaihw committed Mar 13, 2019
1 parent f8757a2 commit 4f34cdc
Showing 1 changed file with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,42 @@ You can enable the feature using the `CustomResourcePublishOpenAPI` feature gate

Custom resource validation schema will be converted to OpenAPI v2 schema, and
show up in `definitions` and `paths` fields in the OpenAPI spec.
Additional modification is applied during the conversion to keep backwards compatiblity with
kubectl in previous 1.13 version. The conversion won't modify the validation schema defined in CRD,
and therefore won't affect [validation](#validation) in API server. See
[conversion implementation](https://github.com/kubernetes/kubernetes/blob/83ff0f6c64485ffe491d5116596072f466be1bd5/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/conversion.go#L42-L112)
and [compatibility analysis](https://github.com/kubernetes/kube-openapi/pull/143) for detail.
The following additional modifications are applied during the conversion to keep backwards compatiblity with
kubectl in previous 1.13 version. These modifications prevent kubectl from being over-strict and rejecting
valid openapi schemas that it doesn't understand. The conversion won't modify the validation schema defined in CRD,
and therefore won't affect [validation](#validation) in API server.

1. The following fields are removed as they aren't supported by OpenAPI v2

- The fields `oneOf`, `anyOf` and `not` are removed

2. The following fields are removed as they aren't allowed by kubectl in
previous 1.13 version

- For a schema with a `$ref`
- the fields `properties` and `type` are removed
- if the `$ref` is outside of the `definitions`, the field `$ref` is removed
- For a schema of a primitive data type (which means the field `type` has two elements: one type and one format)
- if any one of the two elements is `null`, the field `type` is removed
- otherwise, the fields `type` and `properties` are removed
- For a schema of more than two types
- the fields `type` and `properties` are removed
- For a schema of `null` type
- the field `type` is removed
- For a schema of `array` type
- if the schema doesn't have exact one item, the fields `type` and `items` are
removed
- For a schema with no type specified
- the field `properties` is removed

3. The following fields are removed as they aren't supported by gnostic

- The fields `id`, `schema`, `definitions`, `additionalItems`, `dependencies`,
and `patternProperties` are removed
- For a schema with a `externalDocs`
- if the `externalDocs` has `url` defined, the field `externalDocs` is removed
- For a schema with `items` defined
- if the field `items` has multiple schemas, the field `items` is removed

### Additional printer columns

Expand Down

0 comments on commit 4f34cdc

Please sign in to comment.