Version: v1.2

版本管理

组件版本

你可以通过字段 spec.components[*].externalRevision 在 Application 中指定即将生成的组件实例版本名称。

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: myapp
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. externalRevision: express-server-v1
  10. properties:
  11. image: stefanprodan/podinfo:4.0.3

如果没有主动指定版本名称,会根据规则 <component-name>-<revision-number> 自动生成。

应用创建以后,你就可以看到系统中生成了 ControllerRevision 对象来记录组件版本。

  • 获取组件实例的版本记录
  1. $ kubectl get controllerrevision -l controller.oam.dev/component=express-server
  2. NAME CONTROLLER REVISION AGE
  3. express-server-v1 application.core.oam.dev/myapp 1 2m40s
  4. express-server-v2 application.core.oam.dev/myapp 2 2m12s

你可以在灰度发布功能中进一步利用组件实例版本化以后的功能。

应用版本

除了工作流字段,应用中的每个字段更新都会生成一个对应的版本快照。

  • 查看版本快照
  1. $ kubectl get apprev -l app.oam.dev/name=myapp
  2. NAME AGE
  3. myapp-v1 54m
  4. myapp-v2 53m
  5. myapp-v3 18s

你可以在版本快照中获得应用所关联的所有信息,包括应用的字段以及对应的组件类型、运维能力等。

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: ApplicationRevision
  3. metadata:
  4. labels:
  5. app.oam.dev/app-revision-hash: a74b4a514ba2fc08
  6. app.oam.dev/name: myapp
  7. name: myapp-v3
  8. namespace: default
  9. ...
  10. spec:
  11. application:
  12. apiVersion: core.oam.dev/v1beta1
  13. kind: Application
  14. metadata:
  15. name: myapp
  16. namespace: default
  17. ...
  18. spec:
  19. components:
  20. - name: express-server
  21. properties:
  22. image: stefanprodan/podinfo:5.0.3
  23. type: webservice@v1
  24. ...
  25. componentDefinitions:
  26. webservice:
  27. apiVersion: core.oam.dev/v1beta1
  28. kind: ComponentDefinition
  29. metadata:
  30. name: webservice
  31. namespace: vela-system
  32. ...
  33. spec:
  34. schematic:
  35. cue:
  36. ...
  37. traitDefinitions:
  38. ...

应用版本对比

部署前版本对比(Live-diff)功能可以让你不用真的对运行时集群进行操作,在本地预览即将部署的版本和线上版本的差异性,并进行确认。

预览所提供的信息,会包括应用部署计划的新增、修改和移除等信息,同时也包括其中的组件和运维特征的相关信息。

假设你的新应用部署计划如下,包含镜像的变化:

  1. # new-app.yaml
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: myapp
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice@v1
  10. properties:
  11. image: crccheck/hello-world # 变更镜像

然后运行 版本对比 功能,使用如下命令:

  1. vela live-diff -f new-app.yaml -r vela-app-v1
  • 通过 -r--revision 参数,指定要比较的版本名称。
  • 通过 -c--context 指定对比差异的上下文行数。

通过 vela live-diff -h 查看更多参数用法。

点击查看对比结果

  1. ---
  2. # Application (myapp) has been modified(*)
  3. ---
  4. apiVersion: core.oam.dev/v1beta1
  5. kind: Application
  6. metadata:
  7. - annotations:
  8. - kubectl.kubernetes.io/last-applied-configuration: |
  9. - {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"myapp","namespace":"default"},"spec":{"components":[{"externalRevision":"express-server-v1","name":"express-server","properties":{"image":"stefanprodan/podinfo:4.0.3"},"type":"webservice"}]}}
  10. creationTimestamp: null
  11. - finalizers:
  12. - - app.oam.dev/resource-tracker-finalizer
  13. name: myapp
  14. namespace: default
  15. spec:
  16. components:
  17. - - externalRevision: express-server-v1
  18. - name: express-server
  19. + - name: express-server
  20. properties:
  21. - image: stefanprodan/podinfo:4.0.3
  22. - type: webservice
  23. + image: crccheck/hello-world
  24. + type: webservice@v1
  25. status:
  26. rollout:
  27. batchRollingState: ""
  28. currentBatch: 0
  29. lastTargetAppRevision: ""
  30. rollingState: ""
  31. upgradedReadyReplicas: 0
  32. upgradedReplicas: 0
  33. ---
  34. ## Component (express-server) has been modified(*)
  35. ---
  36. apiVersion: apps/v1
  37. kind: Deployment
  38. metadata:
  39. - annotations:
  40. - kubectl.kubernetes.io/last-applied-configuration: |
  41. - {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"myapp","namespace":"default"},"spec":{"components":[{"externalRevision":"express-server-v1","name":"express-server","properties":{"image":"stefanprodan/podinfo:4.0.3"},"type":"webservice"}]}}
  42. + annotations: {}
  43. labels:
  44. app.oam.dev/appRevision: ""
  45. app.oam.dev/component: express-server
  46. app.oam.dev/name: myapp
  47. app.oam.dev/resourceType: WORKLOAD
  48. - workload.oam.dev/type: webservice
  49. + workload.oam.dev/type: webservice-v1
  50. name: express-server
  51. namespace: default
  52. spec:
  53. selector:
  54. matchLabels:
  55. app.oam.dev/component: express-server
  56. template:
  57. metadata:
  58. labels:
  59. app.oam.dev/component: express-server
  60. app.oam.dev/revision: KUBEVELA_COMPONENT_REVISION_PLACEHOLDER
  61. spec:
  62. containers:
  63. - - image: stefanprodan/podinfo:4.0.3
  64. + - image: crccheck/hello-world
  65. name: express-server
  66. ports:
  67. - containerPort: 80

VelaUI 中独立在数据库中记录了应用版本,我们也推荐在数据库中记录元数据历史。