Skip to content

Update CronJob and Multiversion Tutorials to Follow Best Practices #5024

@camilamacedo86

Description

@camilamacedo86

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 on EnvTest.

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


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:

  1. 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.
  2. 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.
  3. 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.

Metadata

Metadata

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release.size/XXLDenotes a PR that changes 1000+ lines, ignoring generated files.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions