Skip to main content
Version: v1.3

Built-in Policy Type

This documentation will walk through the built-in policies.

apply-once

Overview

Allow configuration drift for applied resources.

Parameter

NameTypeDescription
enableboolIf true, allow configuration drift.

Example

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: apply-once-app
spec:
components:
- name: hello-world
type: webservice
properties:
image: oamdev/hello-world
traits:
- type: scaler
properties:
replicas: 1
policies:
- name: apply-once
type: apply-once
properties:
enable: true

garbage-collect

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

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: first-vela-app
spec:
components:
- name: express-server
type: webservice
properties:
image: oamdev/hello-world
port: 8000
traits:
- type: ingress-1-20
properties:
domain: testsvc.example.com
http:
"/": 8000
policies:
- name: keep-legacy-resource
type: garbage-collect
properties:
keepLegacyResource: true
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: garbage-collect-app
spec:
components:
- name: hello-world-new
type: webservice
properties:
image: oamdev/hello-world
traits:
- type: expose
properties:
port: [8000]
policies:
- name: garbage-collect
type: garbage-collect
properties:
rules:
- selector:
traitTypes:
- expose
strategy: onAppDelete

Override

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

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: deploy-with-override
namespace: examples
spec:
components:
- name: nginx-with-override
type: webservice
properties:
image: nginx
policies:
- name: topology-hangzhou-clusters
type: topology
properties:
clusterLabelSelector:
region: hangzhou
- name: topology-local
type: topology
properties:
clusters: ["local"]
namespace: examples-alternative
- name: override-nginx-legacy-image
type: override
properties:
components:
- name: nginx-with-override
properties:
image: nginx:1.20
- name: override-high-availability
type: override
properties:
components:
- type: webservice
traits:
- type: scaler
properties:
replicas: 3
workflow:
steps:
- type: deploy
name: deploy-local
properties:
policies: ["topology-local"]
- type: deploy
name: deploy-hangzhou
properties:
policies: ["topology-hangzhou-clusters", "override-nginx-legacy-image", "override-high-availability"]
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: advance-override
namespace: examples
spec:
components:
- name: nginx-advance-override-legacy
type: webservice
properties:
image: nginx:1.20
- name: nginx-advance-override-latest
type: webservice
properties:
image: nginx
policies:
- name: topology-hangzhou-clusters
type: topology
properties:
clusterLabelSelector:
region: hangzhou
- name: topology-local
type: topology
properties:
clusters: ["local"]
namespace: examples-alternative
- name: override-nginx-legacy
type: override
properties:
selector: ["nginx-advance-override-legacy"]
- name: override-nginx-latest
type: override
properties:
selector: ["nginx-advance-override-latest", "nginx-advance-override-stable"]
components:
- name: nginx-advance-override-stable
type: webservice
properties:
image: nginx:stable
workflow:
steps:
- type: deploy
name: deploy-local
properties:
policies: ["topology-local", "override-nginx-legacy"]
- type: deploy
name: deploy-hangzhou
properties:
policies: ["topology-hangzhou-clusters", "override-nginx-latest"]

topology

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

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: basic-topology
namespace: examples
spec:
components:
- name: nginx-basic
type: webservice
properties:
image: nginx
policies:
- name: topology-hangzhou-clusters
type: topology
properties:
clusters: ["hangzhou-1", "hangzhou-2"]
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: label-selector-topology
namespace: examples
spec:
components:
- name: nginx-label-selector
type: webservice
properties:
image: nginx
policies:
- name: topology-hangzhou-clusters
type: topology
properties:
clusterLabelSelector:
region: hangzhou
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: local-ns-topology
namespace: examples
spec:
components:
- name: nginx-local-ns
type: webservice
properties:
image: nginx
policies:
- name: topology-local
type: topology
properties:
clusters: ["local"]
namespace: examples-alternative