Version Control
#
IntroductionIn KubeVela, ApplicationRevision keeps the snapshot of the application and all its runtime dependencies such as ComponentDefinition, external Policy or referred objects. This revision can be used to review the application changes and rollback to past configurations.
In KubeVela v1.3, for application which uses the PublishVersion
feature, we support viewing the history revisions, checking the differences across revisions, rolling back to the latest succeeded revision and re-publishing past revisions.
For application with the app.oam.dev/publishVersion
annotation, the workflow runs are strictly controlled.
The annotation, which is noted as publishVersion in the following paragraphs, is used to identify a static version of the application and its dependencies.
When the annotation is updated to a new value, the application will generate a new revision no matter if the application spec or the dependencies are changed. It will then trigger a fresh new run of workflow after terminating the previous run.
During the running of workflow, all related data are retrieved from the ApplicationRevision, which means the changes to the application spec or the dependencies will not take effects until a newer publishVerison
is annotated.
#
Use GuideFo example, let's start with an application with external workflow and policies to deploy podinfo in managed clusters.
For external workflow and policies, please refer to Multi-cluster Application Delivery for more details.
You can check the application status by running vela status podinfo -n examples
and view all the related real-time resources by vela status podinfo -n examples --tree --detail
.
This application should be successful after a while.
Now if we edit the component image and set it to an invalid value, such as stefanprodan/podinfo:6.0.xxx
.
The application will not re-run the workflow to make this change take effect automatically.
But the application spec changes, it means the next workflow run will update the deployment image.
#
Inspect Changes across RevisionsNow let's run vela live-diff podinfo -n examples
to check this diff
We can see all the changes of the application spec and the dependencies. Now let's make this change take effects. There are two ways to make it take effects. You can choose any one of them.
- Update the
publishVersion
annotation in the application toalpha2
to trigger the re-run of workflow. - Run
vela up podinfo -n examples --publish-version alpha2
to publish the new version.
We will find the application stuck at runningWorkflow
as the deployment cannot finish the update progress due to the invalid image.
Now we can run vela revision list podinfo -n examples
to list all the available revisions.
#
Rollback to Last Successful RevisionBefore rolling back, we need to suspend the workflow of the application first. Run vela workflow suspend podinfo -n examples
.
After the application workflow is suspended, run vela workflow rollback podinfo -n examples
, the workflow will be rolled back and the application resources will restore to the succeeded state.
Now if we return back to see all the resources, we will find the resources have been turned back to use the valid image again.
#
Re-publish a History RevisionThis feature is introduced after v1.3.1.
Rolling back revision allows you to directly go back to the latest successful state. An alternative way is to re-publish an old revision, which will re-run the workflow but can go back to any revision that is still available.
For example, you might have 2 successful revisions available to use.
Alternatively, you can directly use vela up podinfo -n examples --revision podinfo-v1 --publish-version beta1
to re-publish the earliest version. This process will let the application to use the past revision and re-run the whole workflow. A new revision that is totally same with the specified one will be generated.
You can find that the beta1 version shares the same hash with alpha1 version.
By default, application will hold at most 10 revisions. If you want to modify this number, you can set it in the
--application-revision-limit
bootstrap parameter of KubeVela controller.