Version: v1.8

Application Version Control

overall-arch

In 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 publishVersion is annotated.

Fo example, let’s start with an application with external workflow and policies to deploy podinfo in managed clusters.

Application Version Control - 图2tip

We use reference of external workflow and policies, it works the same. You can refer to Multi-cluster Application Delivery for more details.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: podinfo
  5. namespace: examples
  6. annotations:
  7. app.oam.dev/publishVersion: alpha1
  8. spec:
  9. components:
  10. - name: podinfo
  11. type: webservice
  12. properties:
  13. image: stefanprodan/podinfo:6.0.1
  14. workflow:
  15. ref: make-release-in-hangzhou
  16. ---
  17. apiVersion: core.oam.dev/v1alpha1
  18. kind: Policy
  19. metadata:
  20. name: override-high-availability
  21. namespace: examples
  22. type: override
  23. properties:
  24. components:
  25. - type: webservice
  26. traits:
  27. - type: scaler
  28. properties:
  29. replicas: 3
  30. ---
  31. apiVersion: core.oam.dev/v1alpha1
  32. kind: Policy
  33. metadata:
  34. name: topology-hangzhou-clusters
  35. namespace: examples
  36. type: topology
  37. properties:
  38. clusterLabelSelector:
  39. region: hangzhou
  40. ---
  41. apiVersion: core.oam.dev/v1alpha1
  42. kind: Workflow
  43. metadata:
  44. name: make-release-in-hangzhou
  45. namespace: examples
  46. steps:
  47. - name: deploy-hangzhou
  48. type: deploy
  49. properties:
  50. policies: ["topology-hangzhou-clusters", "override-high-availability"]

You can check the application status by:

  1. vela status podinfo -n examples

expected output

  1. About:
  2. Name: podinfo
  3. Namespace: examples
  4. Created at: 2022-04-13 19:32:02 +0800 CST
  5. Status: runningWorkflow
  6. Workflow:
  7. mode: DAG
  8. finished: false
  9. Suspend: false
  10. Terminated: false
  11. Steps
  12. - id:auqaxnbix2
  13. name:deploy-hangzhou
  14. type:deploy
  15. phase:running
  16. message:wait healthy
  17. Services:
  18. - Name: podinfo
  19. Cluster: velad-003 Namespace: examples
  20. Type: webservice
  21. Unhealthy Ready:0/3
  22. Traits:
  23. scaler
  24. - Name: podinfo
  25. Cluster: velad-002 Namespace: examples
  26. Type: webservice
  27. Unhealthy Ready:0/3
  28. Traits:
  29. scaler

View all the related real-time resources by:

  1. vela status podinfo -n examples --tree --detail

expected output

  1. CLUSTER NAMESPACE RESOURCE STATUS APPLY_TIME DETAIL
  2. hangzhou1 ─── examples ─── Deployment/podinfo updated 2022-04-13 19:32:03 Ready: 3/3 Up-to-date: 3 Available: 3 Age: 4m16s
  3. hangzhou2 ─── examples ─── Deployment/podinfo updated 2022-04-13 19:32:03 Ready: 3/3 Up-to-date: 3 Available: 3 Age: 4m16s

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.

You can run vela live-diff to check revision difference:

  1. vela live-diff podinfo -n examples

expected output

  1. * Application (podinfo) has been modified(*)
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. annotations:
  6. app.oam.dev/publishVersion: alpha1
  7. name: podinfo
  8. namespace: examples
  9. spec:
  10. components:
  11. - name: podinfo
  12. properties:
  13. - image: stefanprodan/podinfo:6.0.1
  14. + image: stefanprodan/podinfo:6.0.xxx
  15. type: webservice
  16. workflow:
  17. ref: make-release-in-hangzhou
  18. status: {}
  19. * External Policy (topology-hangzhou-clusters) has no change
  20. * External Policy (override-high-availability) has no change
  21. * External Workflow (make-release-in-hangzhou) has no change

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 publish an app with specified revision. You can choose any one of them.

  1. Update the publishVersion annotation in the application to alpha2 to trigger the re-run of workflow.

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: podinfo
    5. namespace: examples
    6. annotations:
    7. - app.oam.dev/publishVersion: alpha1
    8. + app.oam.dev/publishVersion: alpha2
    9. ...
  2. Run vela up --publish-version <revision-name to publish the new version.

    1. vela up podinfo -n examples --publish-version alpha2

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 to list all the available revisions.

  1. vela revision list podinfo -n examples

expected output

  1. NAME PUBLISH_VERSION SUCCEEDED HASH BEGIN_TIME STATUS SIZE
  2. podinfo-v1 alpha1 true 65844934c2d07288 2022-04-13 19:32:02 Succeeded 23.7 KiB
  3. podinfo-v2 alpha2 false 44124fb1a5146a4d 2022-04-13 19:46:50 Executing 23.7 KiB

Before rolling back, we need to suspend the workflow of the application first.

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

  1. vela workflow rollback podinfo -n examples

expected output

  1. Find succeeded application revision podinfo-v1 (PublishVersion: alpha1) to rollback.
  2. Application spec rollback successfully.
  3. Application status rollback successfully.
  4. Application rollback completed.
  5. Application outdated revision cleaned up.

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.

  1. vela status podinfo -n examples --tree --detail --detail-format wide

expected output

  1. CLUSTER NAMESPACE RESOURCE STATUS APPLY_TIME DETAIL
  2. hangzhou1 ─── examples ─── Deployment/podinfo updated 2022-04-13 19:32:03 Ready: 3/3 Up-to-date: 3 Available: 3 Age: 17m Containers: podinfo Images: stefanprodan/podinfo:6.0.1 Selector: app.oam.dev/component=podinfo
  3. hangzhou2 ─── examples ─── Deployment/podinfo updated 2022-04-13 19:32:03 Ready: 3/3 Up-to-date: 3 Available: 3 Age: 17m Containers: podinfo Images: stefanprodan/podinfo:6.0.1 Selector: app.oam.dev/component=podinfo

Application Version Control - 图3note

This feature is introduced after v1.3+.

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.

Let’s list the history revision by:

  1. vela revision list podinfo -n examples

expected output

  1. NAME PUBLISH_VERSION SUCCEEDED HASH BEGIN_TIME STATUS SIZE
  2. podinfo-v1 alpha1 true 65844934c2d07288 2022-04-13 20:45:19 Succeeded 23.7 KiB
  3. podinfo-v2 alpha2 true 4acae1a66013283 2022-04-13 20:45:45 Succeeded 23.7 KiB
  4. podinfo-v3 alpha3 false 44124fb1a5146a4d 2022-04-13 20:46:28 Executing 23.7 KiB

Alternatively, you can directly run the following command to rollback to a specified revision:

  1. vela up podinfo -n examples --revision podinfo-v1 --publish-version beta1

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.

  1. NAME PUBLISH_VERSION SUCCEEDED HASH BEGIN_TIME STATUS SIZE
  2. podinfo-v1 alpha1 true 65844934c2d07288 2022-04-13 20:45:19 Succeeded 23.7 KiB
  3. podinfo-v2 alpha2 true 4acae1a66013283 2022-04-13 20:45:45 Succeeded 23.7 KiB
  4. podinfo-v3 alpha3 false 44124fb1a5146a4d 2022-04-13 20:46:28 Failed 23.7 KiB
  5. podinfo-v4 beta1 true 65844934c2d07288 2022-04-13 20:46:49 Succeeded 23.7 KiB

You can find that the beta1 version shares the same hash with alpha1 version.

Application Version Control - 图4info

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.

Last updated on May 6, 2023 by Tianxin Dong