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
Merged

Add docs for CustomResource validation #5290

merged 1 commit into from
Sep 6, 2017

Conversation

nikhita
Copy link
Member

@nikhita nikhita 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
Copy link
Contributor

@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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 4, 2017
@k8sio-netlify-preview-bot
Copy link
Collaborator

k8sio-netlify-preview-bot commented Sep 4, 2017

Deploy preview ready!

Built with commit 3fb9908

https://deploy-preview-5290--kubernetes-io-vnext-staging.netlify.com

@nikhita
Copy link
Member Author

nikhita commented Sep 4, 2017

/cc @enisoc

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

In this example, the CustomResourceDefinition applies the following validations on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be changed as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the object creation request is accepted.

Copy link
Contributor

@tengqm tengqm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@chenopis chenopis added this to the 1.8 milestone Sep 5, 2017
@enisoc
Copy link
Member

enisoc 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
Copy link
Contributor

sttts 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
Copy link
Member Author

nikhita 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not support = rejected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or ignored?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we should better write "cannot be set".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

add info about supported fields
@sttts
Copy link
Contributor

sttts commented Sep 6, 2017

/lgtm

@sttts
Copy link
Contributor

sttts commented Sep 6, 2017

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

Copy link
Contributor

@chenopis chenopis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/docs lgtm

@chenopis chenopis merged commit a26f481 into kubernetes:release-1.8 Sep 6, 2017
anguslees added a commit to anguslees/sealed-secrets that referenced this pull request Sep 21, 2017
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
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
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants