Skip to content

docs(declarative-validation): migrate declarative validation docs from k/website#726

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
aaron-prindle:migrate-dv-docs
May 29, 2026
Merged

docs(declarative-validation): migrate declarative validation docs from k/website#726
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
aaron-prindle:migrate-dv-docs

Conversation

@aaron-prindle

Copy link
Copy Markdown
Contributor

This adds a contributor-site reference page for Kubernetes declarative API validation.

PR migrates the core declarative validation material from kubernetes/website, rewrites it for API contributors, and updates the tag catalog against the current validation-gen implementation so it is up to date w.r.t existing tags, stability levels, etc.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 19, 2026
@netlify

netlify Bot commented May 19, 2026

Copy link
Copy Markdown

‼️ Deploy request for kubernetes-contributor rejected.

Name Link
🔨 Latest commit 1be6ef5


Declarative validation lets Kubernetes API authors put common validation rules next to the versioned API types they apply to. Instead of hand-writing every basic check in `validation.go`, API authors add `+k8s:` tags to `types.go`, and `validation-gen` turns those tags into Go validation code.

This does not completely replace handwritten validation as cross-field checks, compatibility quirks, and rules that cannot be expressed as tags still use handwritten validation code. The goal is to move the simple, repeated, field-local rules into a form that is easier to review and harder to accidentally drift.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some of the rules are cross fields.

@aaron-prindle aaron-prindle May 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed now - the intent was the explain common cases of keeping hand-written to the user as we do support some specific cross-field cases I have removed this now and kept this statement more generic to explain that complex/bespoke cases still need hand-written validation logic

Use this as a quick pass when reviewing a PR that adds declarative validation:

- Are the tags on the versioned API types?
- Did the PR regenerate `zz_generated.validations.go`?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are the test artifacts generated properly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to include this now:

  • Did the PR regenerate test/declarative_validation/<group>/<kind>/zz_generated.validations.main_test.go?
  • Did the PR regenerate test/declarative_validation/<group>/<kind>/zz_generated.validations.<api-version-*>_test.go?


- Put validation tags on versioned API types.
- Run `hack/update-codegen.sh` after adding or changing tags.
- For migrations of existing handwritten validation, use lifecycle wrappers so the generated result can soak before it becomes authoritative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You mentioned lifecycle wrappers . Didn't talk about explicit about it? should we talk about the lifcycle of migration in this doc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The goal of this is to port the kubernetes/website documentation which has already been approved to this page with minor updates so that it is still correct as of 5/22/2026 code changes.

I have removed this specific line now but kept some of the lifecycle related text in the into/feature-gate section as some explanation is necessary to explain what the feature gates do.

@@ -0,0 +1,792 @@
---
content_type: "reference"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I don't think we use this field on the contributor docs. Not harmful, but also OK to remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks, removed now

@lmktfy lmktfy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should merge this. Even if not perfect, merging this will be a big improvement on what we have today.

@lalitc375

Copy link
Copy Markdown

/lgtm
/approved

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
@aaron-prindle

Copy link
Copy Markdown
Contributor Author

@lmktfy - we have approval for the content of the document now from @lalitc375. PTAL, thanks!

@aaron-prindle

Copy link
Copy Markdown
Contributor Author

/assign @lmktfy

@jberkus

jberkus commented May 29, 2026

Copy link
Copy Markdown
Contributor

/approve

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aaron-prindle, jberkus

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2026
@k8s-ci-robot k8s-ci-robot merged commit c872089 into kubernetes:master May 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants