Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for CustomResource validation #5290

Merged
merged 1 commit into from Sep 6, 2017

Conversation

@nikhita
Copy link
Member

commented Sep 4, 2017

Add docs for CustomResource validation. Ref: kubernetes/kubernetes#47263, kubernetes/community#708.

/cc @sttts @deads2k @enisoc

Preview links:


This change is Reviewable

@k8s-ci-robot k8s-ci-robot requested review from sttts and deads2k Sep 4, 2017

@k8s-ci-robot

This comment has been minimized.

Copy link

commented Sep 4, 2017

@nikhita: GitHub didn't allow me to request PR reviews from the following users: ensonic.

Note that only kubernetes members can review this PR, and authors cannot review their own PRs.

In response to this:

Adds docs for CustomResource validation. Ref: kubernetes/kubernetes#47263, kubernetes/community#708.

/cc @sttts @deads2k @ensonic

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8sio-netlify-preview-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 4, 2017

@nikhita

This comment has been minimized.

Copy link
Member Author

commented Sep 4, 2017

/cc @enisoc

@k8s-ci-robot k8s-ci-robot requested a review from enisoc Sep 4, 2017

--feature-gates=CustomResourceValidation=true
```

In this example, the CustomResourceDefinition applies the following validations on

This comment has been minimized.

Copy link
@tengqm

tengqm Sep 5, 2017

Contributor

In this example -> In the following example

kubectl create -f resourcedefinition.yaml
```

If a custom object of kind `CronTab` with fields having invalid values is created, the object will be rejected.

This comment has been minimized.

Copy link
@tengqm

tengqm Sep 5, 2017

Contributor

-> A request to create a custom object of kind CronTab will be rejected if there are invalid values in its fields.

The points are: 1) the thing that is rejected is the request, not the object; 2) a rejected request will have no object created.

metadata:
name: my-new-cron-object
spec:
cronSpec: "* * * * /5"

This comment has been minimized.

Copy link
@tengqm

tengqm Sep 5, 2017

Contributor

This line should be changed as well?

This comment has been minimized.

Copy link
@nikhita

nikhita Sep 5, 2017

Author Member

This line represents an invalid value i.e * * * * /5 is invalid but * * * * */5 is valid.

However, I can see that it can cause confusion so changed this to something more explicit. (* * * *)

spec.replicas in body should be less than or equal to 10
```

If the fields contain valid values, the custom object is accepted.

This comment has been minimized.

Copy link
@tengqm

tengqm Sep 5, 2017

Contributor

the object creation request is accepted.

@tengqm

tengqm approved these changes Sep 5, 2017

Copy link
Contributor

left a comment

Thanks.

@enisoc

This comment has been minimized.

Copy link
Member

commented Sep 5, 2017

/lgtm

@nikhita Did you end up having any differences in supported fields/values versus the full OpenAPIV3 Schema? If so it would be good to list them here.

@sttts

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2017

differences in supported fields/values versus the full OpenAPIV3 Schema

Good point. We should document that (additionalProperties comes to mind, probably some more).

@nikhita

This comment has been minimized.

Copy link
Member Author

commented Sep 6, 2017

Updated. PTAL, thanks.

Validation of custom objects is possible via [OpenAPI v3 schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject).
Additionally, the following restrictions are applied to the schema:

- The fields `default`, `nullable`, `discriminator`, `readOnly`, `writeOnly`, `xml` and

This comment has been minimized.

Copy link
@sttts

sttts Sep 6, 2017

Contributor

not support = rejected?

This comment has been minimized.

Copy link
@sttts

sttts Sep 6, 2017

Contributor

or ignored?

This comment has been minimized.

Copy link
@sttts

sttts Sep 6, 2017

Contributor

then we should better write "cannot be set".

This comment has been minimized.

Copy link
@nikhita

nikhita Sep 6, 2017

Author Member

Done.

Add docs for CustomResource validation
add info about supported fields
@sttts

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2017

/lgtm

@sttts

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2017

@chenopis can you take a look from the docs perspective?

@chenopis
Copy link
Contributor

left a comment

/docs lgtm

@chenopis chenopis merged commit a26f481 into kubernetes:release-1.8 Sep 6, 2017

3 checks passed

cla/linuxfoundation nikhita authorized
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@anguslees anguslees referenced this pull request Sep 21, 2017

Closed

`validate` should support (ie: not reject) TPRs/CRDs #146

1 of 2 tasks complete

anguslees added a commit to anguslees/sealed-secrets that referenced this pull request Sep 21, 2017

Add an openapi schema declaration to the CRD
This prepares us for the associated alpha feature in k8s 1.8.  See
kubernetes/website#5290 for docs.

anguslees added a commit to anguslees/sealed-secrets that referenced this pull request Sep 21, 2017

Add an openapi schema declaration to the CRD
This prepares us for the associated alpha feature in k8s 1.8.  See
kubernetes/website#5290 for docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.