-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
What needs to happen?
The existing CronJob and Multiversion tutorials in the documentation are outdated and does not follow the k8s convetions. To ensure they serve as accurate, up-to-date references for the community, we must update them to follow current best practices and conventions.
Specifically, the tutorials currently:
- Are Missing Status Conditions: They do not use standard status conditions, which are a key part of the Kubernetes API conventions. This is a known issue, as seen in #4019.
- Use Outdated Testing Methodologies: The tests use an old fake client instead of the recommended
EnvTest
. See the Kubebuilder Testing documentation for more onEnvTest
.
The Deploy Image Plugin (https://book.kubebuilder.io/plugins/available/deploy-image-plugin-v1-alpha) provides a great example of a scaffold that follows these best practices, including the use of status conditions and EnvTest
. We can use it as a reference.
To understand why it is important see: https://kubernetes.slack.com/archives/CAR30FCJZ/p1755009724509139
References
- CronJob Tutorial: https://github.com/kubernetes-sigs/kubebuilder/tree/master/docs/book/src/cronjob-tutorial
- Multiversion Tutorial: https://github.com/kubernetes-sigs/kubebuilder/tree/master/docs/book/src/multiversion-tutorial
- Deploy Image Plugin Scaffold: https://book.kubebuilder.io/plugins/available/deploy-image-plugin-v1-alpha
- Example Code (
testdata
with plugins): https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v4-with-plugins
Proposed Solution
We must update the docs/book/src/cronjob-tutorial
and docs/book/src/multiversion-tutorial
to align with the best practices.
It's important to understand how these tutorials are generated: they are not manually edited. Instead, we run make generate
, which uses a special tool at hack/docs/internal
to regenerate the tutorials and inject our documentation-specific code on top.
This makes the task slightly more complex, and here is a suggested approach:
-
Directly Update the CronJob Tutorial:
- Manually edit the code in
docs/book/src/cronjob-tutorial
to include status conditions,EnvTest
, and other best practices. - Run tests locally (
make test
etc.) to ensure the updated tutorial is working as expected.
- Manually edit the code in
-
Open the First PR:
- Open a Pull Request with just the manual changes from step 1.
- This PR is expected to fail the CI because
make generate
will not produce the same result. The purpose of this PR is to serve as a reference and to get team approval on the desired final state of the tutorial.
-
Update the Generation Script:
- Open a new branch and a new PR.
- In this new branch, work on updating the generator in
hack/docs/internal
to ensure that it produces the exact same result as the code in your first PR. - The first PR will be very handy because we will be able to check the diffs in GitHub to compare the generated output with your manual changes and guide your work.
This staged approach allows us to get the desired final state approved before investing time in updating the complex generation script, which helps streamline the process.