vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.67k stars 1.4k forks source link

Modernize the Velero code base #2597

Open carlisia opened 4 years ago

carlisia commented 4 years ago

TODO

v1.5

v1.6

v1.7

v1.8

v1.9

v1.10

v1.11

v1.12

v1.1x


Recipe for converting:

Note for developers:

If you get a " not found" error when attempting to patch a status, it is very likely a case of the status subresource not being enabled in the CRD. The way to verify this is by running kubectl get crd $CRDNAME and then checking if .spec.versions.subresources.status is set. Here are the usual ways to address this:

What

To modernize the Velero code base and tests and bring it more up-to-date and consistent with newer Kubernetes apps, while cleaning up technical debt along the way.

Why

Update: it will also greatly speed up our make update, make ci and make verify targets since it will no longer involve generating code when running those.

How

The end result will...

Strategy

For this change to work in an incremental manner, we need to be able to CRUD some resources with the existing go-client library, and some resources with the runtime-controller library. This has been accomplished with the PR below, which instantiates the runtime-controller Manager and uses this manager's client to CRUD the BSL resource:

https://github.com/vmware-tanzu/velero/pull/2561

The idea is to build on this PR and convert one resource/controller at a time. We have 10 resources and 1 (BSL) is done, so that leaves us with 9.

We would leave the backup and restore ones for last, since they are the most involved in terms of logic and tests.

We would start converting the smallest resource/controller, which is the ServerStatusRequest, to get an idea of how long it takes to do this work for 1 resource/controller, end-to-end. This would help estimate the reminder of the work.

While we work on this transition, we will keep the existing api package/library in its entirety, in case anyone is importing and using this package. Keeping this around is of no cost since it's all generated in an automated way.

For the Velero to transition completely, it would entail removing this (by then) obsolete package, which is a braking change. So we would like to spread this work over the current and next few releases to be able to introduce this change with v2.0.

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

carlisia commented 4 years ago

@vmware-tanzu/velero-maintainers PTAL.

carlisia commented 4 years ago

@nrb / @ashish-amarnath: I'm thinking https://github.com/vmware-tanzu/velero/blob/main/pkg/controller/backup_tracker.go, even though is in the controller package, is not a controller and has nothing to be converted. Just wanted to get a sanity check.

blackpiglet commented 2 years ago

By far, there are several controllers and CRDs not converted yet, including:

kaovilai commented 1 year ago

Hopefully we makes it to kubebuilder/v3 layout

blackpiglet commented 1 year ago

Do you mean changing the layout to something like this project? https://github.com/jetstack/kubebuilder-sample-controller

Could you give some scenarios that need the change? Or What benefit do we get from the change?

kaovilai commented 1 year ago

The benefit would be we can use kubebuilder CLI from now on to generate new API and controllers boilerplate code

https://book.kubebuilder.io/migration/legacy/migration_guide_v1tov2.html

kaovilai commented 1 year ago

Specifically we should be able to call

kubebuilder create api --group batch --version v1 --kind CronJob

And get boilerplate code for a new controller done automatically. And any future migrations should be simple as there are already many projects using the v3 layout.

In addition it standardizes the project to a layout that is more common to a new contributors.

https://book.kubebuilder.io/cronjob-tutorial/new-api.html