-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Add docs for CustomResource validation #5290
Conversation
@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:
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. |
Deploy preview ready! Built with commit 3fb9908 https://deploy-preview-5290--kubernetes-io-vnext-staging.netlify.com |
/cc @enisoc |
--feature-gates=CustomResourceValidation=true | ||
``` | ||
|
||
In this example, the CustomResourceDefinition applies the following validations on |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
/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. |
Good point. We should document that (additionalProperties comes to mind, probably some more). |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not support = rejected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
/lgtm |
@chenopis can you take a look from the docs perspective? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/docs lgtm
This prepares us for the associated alpha feature in k8s 1.8. See kubernetes/website#5290 for docs.
This prepares us for the associated alpha feature in k8s 1.8. See kubernetes/website#5290 for docs.
Add docs for CustomResource validation. Ref: kubernetes/kubernetes#47263, kubernetes/community#708.
/cc @sttts @deads2k @enisoc
Preview links:
This change is