Version: v1.3

Built-in Policy Type

This documentation will walk through the built-in policies.

Overview

Allow configuration drift for applied resources.

Parameter

NameTypeDescription
enableboolIf true, allow configuration drift.

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: apply-once-app
  5. spec:
  6. components:
  7. - name: hello-world
  8. type: webservice
  9. properties:
  10. image: oamdev/hello-world
  11. traits:
  12. - type: scaler
  13. properties:
  14. replicas: 1
  15. policies:
  16. - name: apply-once
  17. type: apply-once
  18. properties:
  19. enable: true

Overview

Configure the garbage collection behavior for the application.

Parameter

NameTypeDescription
keepLegacyResourceboolIf true, outdated versioned resourcetracker will not be recycled automatically. Outdated resources will be kept until resourcetracker be deleted manually.
rules[]GarbageCollectPolicyRuleA list of rules to control gc strategy at resource level, if one resource is controlled by multiple rules, first rule will be used.

GarbageCollectPolicyRule

NameTypeDescription
selectorGarbageCollectPolicyRuleSelectorSelect the target resources of the rule.
strategyStringThe strategy for target resources to recycle. Available values: never, onAppDelete, onAppUpdate.

GarbageCollectPolicyRuleSelector

NameTypeDescription
componentNames[]StringSelect target resources by component names.
componentTypes[]StringSelect target resources by component types.
traitTypes[]StringSelect target resources by trait types.

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-app
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: oamdev/hello-world
  11. port: 8000
  12. traits:
  13. - type: ingress-1-20
  14. properties:
  15. domain: testsvc.example.com
  16. http:
  17. "/": 8000
  18. policies:
  19. - name: keep-legacy-resource
  20. type: garbage-collect
  21. properties:
  22. keepLegacyResource: true
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: garbage-collect-app
  5. spec:
  6. components:
  7. - name: hello-world-new
  8. type: webservice
  9. properties:
  10. image: oamdev/hello-world
  11. traits:
  12. - type: expose
  13. properties:
  14. port: [8000]
  15. policies:
  16. - name: garbage-collect
  17. type: garbage-collect
  18. properties:
  19. rules:
  20. - selector:
  21. traitTypes:
  22. - expose
  23. strategy: onAppDelete

Overview

Describe the configuration to override when deploying resources.

Parameter

NameTypeDescription
components[]ComponentPatchA list of component configurations to override.
selector[]StringA list of component names to use. If not set, all components will be used.

ComponentPatch

NameTypeDescription
namestringThe name of the component to override. If not set, it will match all components with the specified type. Can be used with wildcard * for fuzzy match.
typeStringThe type of the component to override. If not set, all component types will be matched.
propertiesObjectThe component properties to merge.
traits[]TraitPatchA list of trait configurations to override.

TraitPatch

NameTypeDescription
typeStringThe type of the trait to override.
propertiesObjectThe trait properties to merge.
disableboolIf true, this trait will be removed.

Examples

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: deploy-with-override
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-with-override
  9. type: webservice
  10. properties:
  11. image: nginx
  12. policies:
  13. - name: topology-hangzhou-clusters
  14. type: topology
  15. properties:
  16. clusterLabelSelector:
  17. region: hangzhou
  18. - name: topology-local
  19. type: topology
  20. properties:
  21. clusters: ["local"]
  22. namespace: examples-alternative
  23. - name: override-nginx-legacy-image
  24. type: override
  25. properties:
  26. components:
  27. - name: nginx-with-override
  28. properties:
  29. image: nginx:1.20
  30. - name: override-high-availability
  31. type: override
  32. properties:
  33. components:
  34. - type: webservice
  35. traits:
  36. - type: scaler
  37. properties:
  38. replicas: 3
  39. workflow:
  40. steps:
  41. - type: deploy
  42. name: deploy-local
  43. properties:
  44. policies: ["topology-local"]
  45. - type: deploy
  46. name: deploy-hangzhou
  47. properties:
  48. policies: ["topology-hangzhou-clusters", "override-nginx-legacy-image", "override-high-availability"]
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: advance-override
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-advance-override-legacy
  9. type: webservice
  10. properties:
  11. image: nginx:1.20
  12. - name: nginx-advance-override-latest
  13. type: webservice
  14. properties:
  15. image: nginx
  16. policies:
  17. - name: topology-hangzhou-clusters
  18. type: topology
  19. properties:
  20. clusterLabelSelector:
  21. region: hangzhou
  22. - name: topology-local
  23. type: topology
  24. properties:
  25. clusters: ["local"]
  26. namespace: examples-alternative
  27. - name: override-nginx-legacy
  28. type: override
  29. properties:
  30. selector: ["nginx-advance-override-legacy"]
  31. - name: override-nginx-latest
  32. type: override
  33. properties:
  34. selector: ["nginx-advance-override-latest", "nginx-advance-override-stable"]
  35. components:
  36. - name: nginx-advance-override-stable
  37. type: webservice
  38. properties:
  39. image: nginx:stable
  40. workflow:
  41. steps:
  42. - type: deploy
  43. name: deploy-local
  44. properties:
  45. policies: ["topology-local", "override-nginx-legacy"]
  46. - type: deploy
  47. name: deploy-hangzhou
  48. properties:
  49. policies: ["topology-hangzhou-clusters", "override-nginx-latest"]

Overview

Describe the destination where components should be deployed to.

Parameter

NameTypeDescription
clusters[]stringThe names of the clusters to select.
clusterLabelSelectormpa[string]stringThe label selector for clusters. Exclusive to “clusters”
namespacestringThe target namespace to deploy in the selected clusters. If not set, components will inherit the original namespace.

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: basic-topology
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-basic
  9. type: webservice
  10. properties:
  11. image: nginx
  12. policies:
  13. - name: topology-hangzhou-clusters
  14. type: topology
  15. properties:
  16. clusters: ["hangzhou-1", "hangzhou-2"]
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: label-selector-topology
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-label-selector
  9. type: webservice
  10. properties:
  11. image: nginx
  12. policies:
  13. - name: topology-hangzhou-clusters
  14. type: topology
  15. properties:
  16. clusterLabelSelector:
  17. region: hangzhou
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: local-ns-topology
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-local-ns
  9. type: webservice
  10. properties:
  11. image: nginx
  12. policies:
  13. - name: topology-local
  14. type: topology
  15. properties:
  16. clusters: ["local"]
  17. namespace: examples-alternative

Last updated on Nov 1, 2022 by Tianxin Dong