Application Version Control

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

    Use Guide

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

    tip

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

    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. Unhealthy Ready:0/3
    21. Traits:
    22. scaler
    23. - Name: podinfo
    24. Cluster: velad-002 Namespace: examples
    25. Type: webservice
    26. Unhealthy Ready:0/3
    27. Traits:
    28. 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

    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

    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: alpha2
      8. ...
    2. Run 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

    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:

    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

    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 of KubeVela controller.