Built-in Trait Type

    Affinity specifies affinity and toleration K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    For now this trait is hidden from the VelaUX. Available when using CLI

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (affinity)

    Specification (affinity)

    podAffinity (affinity)

    NameDescriptionTypeRequiredDefault
    requiredSpecify the required during scheduling ignored during execution.[]requiredfalse
    preferredSpecify the preferred during scheduling ignored during execution.false
    required (affinity)
    NameDescriptionTypeRequiredDefault
    labelSelectorfalse
    namespaces[]stringfalse
    topologyKeystringtrue
    namespaceSelectornamespaceSelectorfalse
    labelSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressions[]matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    namespaceSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    preferred (affinity)
    NameDescriptionTypeRequiredDefault
    weightSpecify weight associated with matching the corresponding podAffinityTerm.inttrue
    podAffinityTermSpecify a set of pods.podAffinityTermtrue
    podAffinityTerm (affinity)
    NameDescriptionTypeRequiredDefault
    labelSelectorlabelSelectorfalse
    namespaces[]stringfalse
    topologyKeystringtrue
    namespaceSelectorfalse
    labelSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    namespaceSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressions[]matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse

    podAntiAffinity (affinity)

    NameDescriptionTypeRequiredDefault
    requiredSpecify the required during scheduling ignored during execution.false
    preferredSpecify the preferred during scheduling ignored during execution.[]preferredfalse
    required (affinity)
    NameDescriptionTypeRequiredDefault
    labelSelectorlabelSelectorfalse
    namespaces[]stringfalse
    topologyKeystringtrue
    namespaceSelectorfalse
    labelSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    namespaceSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressions[]matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    preferred (affinity)
    NameDescriptionTypeRequiredDefault
    weightSpecify weight associated with matching the corresponding podAffinityTerm.inttrue
    podAffinityTermSpecify a set of pods.true
    podAffinityTerm (affinity)
    NameDescriptionTypeRequiredDefault
    labelSelectorfalse
    namespaces[]stringfalse
    topologyKeystringtrue
    namespaceSelectornamespaceSelectorfalse
    labelSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressions[]matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse
    namespaceSelector (affinity)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressionsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
    values[]stringfalse

    nodeAffinity (affinity)

    NameDescriptionTypeRequiredDefault
    requiredSpecify the required during scheduling ignored during execution.requiredfalse
    preferredSpecify the preferred during scheduling ignored during execution.false
    required (affinity)
    NameDescriptionTypeRequiredDefault
    nodeSelectorTermsSpecify a list of node selector.true
    nodeSelectorTerms (affinity)
    NameDescriptionTypeRequiredDefault
    matchExpressionsfalse
    matchFields[]matchFieldsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
    values[]stringfalse
    matchFields (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
    values[]stringfalse
    preferred (affinity)
    NameDescriptionTypeRequiredDefault
    weightSpecify weight associated with matching the corresponding nodeSelector.inttrue
    preferenceSpecify a node selector.preferencetrue
    preference (affinity)
    NameDescriptionTypeRequiredDefault
    matchExpressions[]matchExpressionsfalse
    matchFieldsfalse
    matchExpressions (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
    values[]stringfalse
    matchFields (affinity)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
    values[]stringfalse

    tolerations (affinity)

    NameDescriptionTypeRequiredDefault
    keystringfalse
    operator“Equal” or “Exists”falseEqual
    valuestringfalse
    effect“NoSchedule” or “PreferNoSchedule” or “NoExecute”false
    tolerationSecondsSpecify the period of time the toleration.intfalse

    Annotations

    Description

    Add annotations on your workload. if it generates pod, add same annotations for generated pods.

    Apply To Component Types

    All Component Types

    Examples (annotations)

    1. kind: Application
    2. metadata:
    3. name: myapp
    4. spec:
    5. components:
    6. - name: express-server
    7. type: webservice
    8. properties:
    9. image: crccheck/hello-world
    10. port: 8000
    11. traits:
    12. - type: labels
    13. properties:
    14. "release": "stable"
    15. - type: annotations
    16. properties:
    17. "description": "web application"

    Specification (annotations)

    NameDescriptionTypeRequiredDefault
    -map[string]:(null|string)true

    Command

    Description

    Add command on K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (command)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. traits:
    13. - type: sidecar
    14. properties:
    15. name: sidecar-nginx
    16. image: nginx
    17. - type: command
    18. # you can use command to control multiple containers by filling `containers`
    19. # NOTE: in containers, you must set the container name for each container
    20. containers:
    21. - containerName: busybox
    22. command: ["sleep", "8640000"]
    23. - containerName: sidecar-nginx
    24. args: ["-q"]

    Specification (command)

    NameDescriptionTypeRequiredDefault
    or type-option-2false

    PatchParams (command)

    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    commandSpecify the command to use in the target container, if not set, it will not be changed.nulltrue
    argsSpecify the args to use in the target container, if set, it will override existing args.nulltrue
    addArgsSpecify the args to add in the target container, existing args will be kept, cannot be used with args.nulltrue
    delArgsSpecify the existing args to delete in the target container, cannot be used with args.nulltrue

    type-option-2 (command)

    NameDescriptionTypeRequiredDefault
    containersSpecify the commands for multiple containers.true
    containers (command)
    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    commandSpecify the command to use in the target container, if not set, it will not be changed.nulltrue
    argsSpecify the args to use in the target container, if set, it will override existing args.nulltrue
    addArgsSpecify the args to add in the target container, existing args will be kept, cannot be used with args.nulltrue
    delArgsSpecify the existing args to delete in the target container, cannot be used with args.nulltrue

    Container-Image

    Description

    Set the image of the container.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (container-image)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. traits:
    13. - type: sidecar
    14. properties:
    15. name: sidecar-nginx
    16. image: nginx
    17. - type: container-image
    18. properties:
    19. # you can use container-image to control multiple containers by filling `containers`
    20. # NOTE: in containers, you must set the container name for each container
    21. containers:
    22. - containerName: busybox
    23. image: busybox-1.34.0
    24. imagePullPolicy: IfNotPresent
    25. - containerName: sidecar-nginx
    26. image: nginx-1.20

    Specification (container-image)

    NameDescriptionTypeRequiredDefault
    PatchParams or false

    PatchParams (container-image)

    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    imageSpecify the image of the container.stringtrue
    imagePullPolicySpecify the image pull policy of the container.“” or “IfNotPresent” or “Always” or “Never”falseempty

    type-option-2 (container-image)

    containers (container-image)
    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    imageSpecify the image of the container.stringtrue
    imagePullPolicySpecify the image pull policy of the container.“” or “IfNotPresent” or “Always” or “Never”falseempty

    Cpuscaler

    Description

    Automatically scale the component based on CPU usage.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps

    Examples (cpuscaler)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: website
    5. spec:
    6. components:
    7. - name: frontend
    8. type: webservice
    9. properties:
    10. image: nginx
    11. traits:
    12. - type: cpuscaler
    13. properties:
    14. min: 1
    15. max: 10
    16. cpuPercent: 60

    Specification (cpuscaler)

    NameDescriptionTypeRequiredDefault
    minSpecify the minimal number of replicas to which the autoscaler can scale down.intfalse1
    maxSpecify the maximum number of of replicas to which the autoscaler can scale up.intfalse10
    cpuUtilSpecify the average cpu utilization, for example, 50 means the CPU usage is 50%.intfalse50
    targetAPIVersionSpecify the apiVersion of scale target.stringfalseapps/v1
    targetKindSpecify the kind of scale target.stringfalseDeployment

    Env

    Description

    Add env on K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (env)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. traits:
    13. - type: sidecar
    14. properties:
    15. name: sidecar-nginx
    16. image: nginx
    17. - type: env
    18. properties:
    19. # you can use env to control multiple containers by filling `containers`
    20. # NOTE: in containers, you must set the container name for each container
    21. containers:
    22. - containerName: busybox
    23. env:
    24. key_for_busybox_first: value_first
    25. key_for_busybox_second: value_second
    26. - containerName: sidecar-nginx
    27. env:
    28. key_for_nginx_first: value_first
    29. key_for_nginx_second: value_second
    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. traits:
    13. - type: sidecar
    14. properties:
    15. name: sidecar-nginx
    16. image: nginx
    17. - type: env
    18. properties:
    19. # you can use env to control one container, if containerName not specified, it will patch on the first index container
    20. containerName: busybox
    21. env:
    22. key_for_busybox_first: value_first
    23. key_for_busybox_second: value_second

    Specification (env)

    NameDescriptionTypeRequiredDefault
    or type-option-2false

    PatchParams (env)

    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    replaceSpecify if replacing the whole environment settings for the container.boolfalsefalse
    envSpecify the environment variables to merge, if key already existing, override its value.map[string]stringtrue
    unsetSpecify which existing environment variables to unset.[]stringtrue

    type-option-2 (env)

    NameDescriptionTypeRequiredDefault
    containersSpecify the environment variables for multiple containers.true
    containers (env)
    NameDescriptionTypeRequiredDefault
    containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
    replaceSpecify if replacing the whole environment settings for the container.boolfalsefalse
    envSpecify the environment variables to merge, if key already existing, override its value.map[string]stringtrue
    unsetSpecify which existing environment variables to unset.[]stringtrue

    Expose

    Description

    Expose port to enable web traffic for your component.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps

    Examples (expose)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: test-app
    5. spec:
    6. components:
    7. - name: hello-world
    8. type: webservice
    9. properties:
    10. image: crccheck/hello-world
    11. traits:
    12. - type: expose
    13. properties:
    14. port: [8000]

    Specification (expose)

    NameDescriptionTypeRequiredDefault
    portSpecify the exposion ports.[]inttrue
    annotationsSpecify the annotaions of the exposed service.map[string]stringtrue
    typeSpecify what kind of Service you want. options: “ClusterIP”,”NodePort”,”LoadBalancer”,”ExternalName”.“ClusterIP” or “NodePort” or “LoadBalancer” or “ExternalName”falseClusterIP

    Enable public web traffic for the component, the ingress API matches K8s v1.20+.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps

    Examples (gateway)

    Specification (gateway)

    NameDescriptionTypeRequiredDefault
    domainSpecify the domain you want to expose.stringfalse
    httpSpecify the mapping relationship between the http path and the workload port.map[string]inttrue
    classSpecify the class of ingress to use.stringfalsenginx
    classInSpecSet ingress class in ‘.spec.ingressClassName’ instead of ‘kubernetes.io/ingress.class’ annotation.boolfalsefalse
    secretNameSpecify the secret name you want to quote to use tls.stringfalse
    gatewayHostSpecify the host of the ingress gateway, which is used to generate the endpoints when the host is empty.stringfalse

    Hostalias

    Description

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (hostalias)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: application-with-hostalias
    5. spec:
    6. components:
    7. - name: busybox-runner
    8. type: worker
    9. properties:
    10. image: busybox
    11. cmd:
    12. - sleep
    13. - '1000'
    14. - type: hostalias
    15. properties:
    16. hostAliases:
    17. - ip: 127.0.0.1
    18. hostnames:
    19. - localname
    20. - locals

    Specification (hostalias)

    NameDescriptionTypeRequiredDefault
    hostAliasesSpecify the hostAliases to add.[]hostAliasestrue

    hostAliases (hostalias)

    NameDescriptionTypeRequiredDefault
    ipstringtrue
    hostnames[]stringtrue

    Init-Container

    Description

    add an init container and use shared volume with pod.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (init-container)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. traits:
    13. - type: init-container
    14. properties:
    15. name: init-busybox
    16. image: busybox
    17. cmd: ["echo", "hello"]
    18. initMountPath: /data
    19. appMountPath: /data-initialized

    Specification (init-container)

    NameDescriptionTypeRequiredDefault
    nameSpecify the name of init container.stringtrue
    imageSpecify the image of init container.stringtrue
    imagePullPolicySpecify image pull policy for your service.“IfNotPresent” or “Always” or “Never”falseIfNotPresent
    cmdSpecify the commands run in the init container.[]stringfalse
    argsSpecify the args run in the init container.[]stringfalse
    envSpecify the env run in the init container.false
    mountNameSpecify the mount name of shared volume.stringfalseworkdir
    appMountPathSpecify the mount path of app container.stringtrue
    initMountPathSpecify the mount path of init container.stringtrue
    extraVolumeMountsSpecify the extra volume mounts for the init container.[]extraVolumeMountstrue

    env (init-container)

    NameDescriptionTypeRequiredDefault
    nameEnvironment variable name.stringtrue
    valueThe value of the environment variable.stringfalse
    valueFromSpecifies a source the value of this var should come from.valueFromfalse
    valueFrom (init-container)
    NameDescriptionTypeRequiredDefault
    secretKeyRefSelects a key of a secret in the pod’s namespace.secretKeyReffalse
    configMapKeyRefSelects a key of a config map in the pod’s namespace.false
    secretKeyRef (init-container)
    NameDescriptionTypeRequiredDefault
    nameThe name of the secret in the pod’s namespace to select from.stringtrue
    keyThe key of the secret to select from. Must be a valid secret key.stringtrue
    configMapKeyRef (init-container)
    NameDescriptionTypeRequiredDefault
    nameThe name of the config map in the pod’s namespace to select from.stringtrue
    keyThe key of the config map to select from. Must be a valid secret key.stringtrue

    extraVolumeMounts (init-container)

    NameDescriptionTypeRequiredDefault
    nameThe name of the volume to be mounted.stringtrue
    mountPathThe mountPath for mount in the init container.stringtrue

    Json-Merge-Patch

    Description

    Patch the output following Json Merge Patch strategy, following RFC 7396.

    Apply To Component Types

    All Component Types

    Examples (json-merge-patch)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. labels:
    13. pod-label-key: pod-label-value
    14. to-delete-label-key: to-delete-label-value
    15. traits:
    16. # the json merge patch can be used to add, replace and delete fields
    17. # the following part will
    18. # 1. add `deploy-label-key` to deployment labels
    19. # 2. set deployment replicas to 3
    20. # 3. set `pod-label-key` to `pod-label-modified-value` in pod labels
    21. # 4. delete `to-delete-label-key` in pod labels
    22. # 5. reset `containers` for pod
    23. - type: json-merge-patch
    24. properties:
    25. metadata:
    26. labels:
    27. deploy-label-key: deploy-label-added-value
    28. spec:
    29. replicas: 3
    30. template:
    31. metadata:
    32. labels:
    33. pod-label-key: pod-label-modified-value
    34. to-delete-label-key: null
    35. spec:
    36. containers:
    37. - name: busybox-new
    38. image: busybox:1.34
    39. command: ["sleep", "864000"]

    Specification (json-merge-patch)

    NameDescriptionTypeRequiredDefault
    -{}true

    Json-Patch

    Description

    Patch the output following Json Patch strategy, following RFC 6902.

    For now this trait is hidden from the VelaUX. Available when using CLI

    Apply To Component Types

    All Component Types

    Examples (json-patch)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: busybox
    5. spec:
    6. components:
    7. - name: busybox
    8. type: webservice
    9. properties:
    10. image: busybox
    11. cmd: ["sleep", "86400"]
    12. labels:
    13. pod-label-key: pod-label-value
    14. to-delete-label-key: to-delete-label-value
    15. traits:
    16. # the json patch can be used to add, replace and delete fields
    17. # the following part will
    18. # 1. add `deploy-label-key` to deployment labels
    19. # 2. set deployment replicas to 3
    20. # 3. set `pod-label-key` to `pod-label-modified-value` in pod labels
    21. # 4. delete `to-delete-label-key` in pod labels
    22. # 5. add sidecar container for pod
    23. - type: json-patch
    24. properties:
    25. operations:
    26. - op: add
    27. path: "/spec/replicas"
    28. value: 3
    29. - op: replace
    30. path: "/spec/template/metadata/labels/pod-label-key"
    31. value: pod-label-modified-value
    32. - op: remove
    33. path: "/spec/template/metadata/labels/to-delete-label-key"
    34. - op: add
    35. path: "/spec/template/spec/containers/1"
    36. value:
    37. name: busybox-sidecar
    38. command: ["sleep", "864000"]

    Specification (json-patch)

    NameDescriptionTypeRequiredDefault
    operationstrue

    operations (json-patch)

    NameDescriptionTypeRequiredDefault
    -{}true

    Labels

    Description

    Add labels on your workload. if it generates pod, add same label for generated pods.

    Apply To Component Types

    All Component Types

    Examples (labels)

    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. properties:
    10. image: crccheck/hello-world
    11. port: 8000
    12. traits:
    13. - type: labels
    14. properties:
    15. "release": "stable"
    16. - type: annotations
    17. properties:
    18. "description": "web application"

    Specification (labels)

    NameDescriptionTypeRequiredDefault
    -map[string]:(null|string)true

    Lifecycle

    Description

    Add lifecycle hooks for every container of K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (lifecycle)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: application-with-lifecycle
    5. spec:
    6. components:
    7. - name: busybox-runner
    8. type: worker
    9. properties:
    10. image: busybox
    11. cmd:
    12. - sleep
    13. - '1000'
    14. traits:
    15. - type: lifecycle
    16. properties:
    17. postStart:
    18. exec:
    19. command:
    20. - echo
    21. - 'hello world'
    22. preStop:
    23. httpGet:
    24. host: "www.aliyun.com"
    25. scheme: "HTTPS"
    26. port: 443

    Specification (lifecycle)

    NameDescriptionTypeRequiredDefault
    postStartfalse
    preStoppreStopfalse

    postStart (lifecycle)

    NameDescriptionTypeRequiredDefault
    execexecfalse
    httpGetfalse
    tcpSockettcpSocketfalse
    exec (lifecycle)
    NameDescriptionTypeRequiredDefault
    command[]stringtrue
    httpGet (lifecycle)
    NameDescriptionTypeRequiredDefault
    pathstringfalse
    portinttrue
    hoststringfalse
    scheme“HTTP” or “HTTPS”falseHTTP
    httpHeadersfalse
    httpHeaders (lifecycle)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    valuestringtrue
    tcpSocket (lifecycle)
    NameDescriptionTypeRequiredDefault
    portinttrue
    hoststringfalse

    preStop (lifecycle)

    NameDescriptionTypeRequiredDefault
    execfalse
    httpGethttpGetfalse
    tcpSocketfalse
    exec (lifecycle)
    NameDescriptionTypeRequiredDefault
    command[]stringtrue
    httpGet (lifecycle)
    NameDescriptionTypeRequiredDefault
    pathstringfalse
    portinttrue
    hoststringfalse
    scheme“HTTP” or “HTTPS”falseHTTP
    httpHeaders[]httpHeadersfalse
    httpHeaders (lifecycle)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    valuestringtrue
    tcpSocket (lifecycle)
    NameDescriptionTypeRequiredDefault
    portinttrue
    hoststringfalse

    nocalhost develop configuration.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (nocalhost)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: bookinfo
    5. spec:
    6. components:
    7. - name: productpage
    8. type: webservice
    9. properties:
    10. image: nocalhost-docker.pkg.coding.net/nocalhost/bookinfo/productpage:latest
    11. port: 9080
    12. traits:
    13. - type: nocalhost
    14. properties:
    15. port: 9080
    16. gitUrl: https://github.com/nocalhost/bookinfo-productpage.git
    17. image: nocalhost-docker.pkg.coding.net/nocalhost/dev-images/python:3.7.7-slim-productpage-with-pydevd
    18. shell: "bash"
    19. workDir: "/opt/work"
    20. limits:
    21. memory: 1Gi
    22. cpu: "1"
    23. requests:
    24. memory: 512Mi
    25. cpu: "0.5"
    26. debug:
    27. remoteDebugPort: 9009
    28. hotReload: true
    29. sync:
    30. type: send
    31. filePattern:
    32. - ./
    33. ignoreFilePattern:
    34. - .git
    35. - .idea
    36. command:
    37. run:
    38. - sh
    39. - run.sh
    40. debug:
    41. - sh
    42. - debug.sh
    43. env:
    44. - name: "foo"
    45. value: "bar"
    46. portForward:
    47. - 39080:9080

    Specification (nocalhost)

    NameDescriptionTypeRequiredDefault
    portinttrue
    serviceTypestringfalsedeployment
    gitUrlstringfalse
    imagestringtrue
    shellstringfalsebash
    workDirstringfalse/home/nocalhost-dev
    storageClassstringfalse
    commandcommandtrue
    debugfalse
    hotReloadboolfalsetrue
    syncsynctrue
    envfalse
    portForward[]stringfalse
    persistentVolumeDirs[]persistentVolumeDirsfalse
    resourcestrue

    command (nocalhost)

    NameDescriptionTypeRequiredDefault
    run[]stringtrue
    debug[]stringtrue

    debug (nocalhost)

    NameDescriptionTypeRequiredDefault
    remoteDebugPortintfalse

    sync (nocalhost)

    NameDescriptionTypeRequiredDefault
    typestringfalsesend
    filePattern[]stringtrue
    ignoreFilePattern[]stringtrue

    env (nocalhost)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    valuestringtrue

    persistentVolumeDirs (nocalhost)

    NameDescriptionTypeRequiredDefault
    pathstringtrue
    capacitystringtrue

    resources (nocalhost)

    NameDescriptionTypeRequiredDefault
    limitslimitstrue
    requeststrue
    limits (nocalhost)
    NameDescriptionTypeRequiredDefault
    memorystringfalse2Gi
    cpustringfalse2
    requests (nocalhost)
    NameDescriptionTypeRequiredDefault
    memorystringfalse512Mi
    cpustringfalse0.5

    Resource

    Description

    Add resource requests and limits on K8s pod for your workload which follows the pod spec in path ‘spec.template.’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (resource)

    Specification (resource)

    NameDescriptionTypeRequiredDefault
    cpuSpecify the amount of cpu for requests and limits.numberfalse1
    memorySpecify the amount of memory for requests and limits.stringfalse2048Mi
    requestsSpecify the resources in requests.false
    limitsSpecify the resources in limits.limitsfalse

    requests (resource)

    limits (resource)

    NameDescriptionTypeRequiredDefault
    cpuSpecify the amount of cpu for limits.numberfalse1
    memorySpecify the amount of memory for limits.stringfalse2048Mi

    Scaler

    Description

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps

    Examples (scaler)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: website
    5. spec:
    6. components:
    7. - name: frontend
    8. type: webservice
    9. properties:
    10. image: nginx
    11. traits:
    12. - type: scaler
    13. properties:
    14. replicas: 2
    15. - type: sidecar
    16. properties:
    17. name: "sidecar-test"
    18. image: "fluentd"
    19. - name: backend
    20. type: worker
    21. properties:
    22. image: busybox
    23. cmd:
    24. - sleep
    25. - '1000'

    Specification (scaler)

    NameDescriptionTypeRequiredDefault
    replicasSpecify the number of workload.intfalse1

    Service-Account

    Description

    Specify serviceAccount for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (service-account)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: vela-doc
    5. namespace: vela-system
    6. spec:
    7. components:
    8. - name: frontend
    9. type: webservice
    10. properties:
    11. image: oamdev/vela-cli:v1.5.0-beta.1
    12. cmd: ["/bin/vela","show"]
    13. ports:
    14. - port: 18081
    15. expose: true
    16. traits:
    17. - type: service-account
    18. properties:
    19. name: kubevela-vela-core

    Specification (service-account)

    NameDescriptionTypeRequiredDefault
    nameSpecify the name of ServiceAccount.stringtrue
    createSpecify whether to create new ServiceAccount or not.boolfalsefalse
    privilegesSpecify the privileges of the ServiceAccount, if not empty, RoleBindings(ClusterRoleBindings) will be created.false

    privileges (service-account)

    NameDescriptionTypeRequiredDefault
    verbsSpecify the verbs to be allowed for the resource.[]stringtrue
    apiGroupsSpecify the apiGroups of the resource.[]stringfalse
    resourcesSpecify the resources to be allowed.[]stringfalse
    resourceNamesSpecify the resourceNames to be allowed.[]stringfalse
    nonResourceURLsSpecify the resource url to be allowed.[]stringfalse
    scopeSpecify the scope of the privileges, default to be namespace scope.“namespace” or “cluster”falsenamespace

    Service-Binding

    Description

    Binding secrets of cloud resources to component env. This definition is DEPRECATED, please use ‘storage’ instead.

    For now this trait is hidden from the VelaUX. Available when using CLI

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (service-binding)

    1. Prepare a Kubernetes Secret

    The secret can be manually created, or generated by other component or external system.

    For example, we have a secret db-conn-example whose data is as below:

    1. endpoint: https://xxx.com
    2. password: 123
    3. username: myname
    1. Bind the Secret into your component by service-binding trait

    For example, we have a webservice component who needs to consume a database. The database connection string should be set to Pod environments: endpoint, username and DB_PASSWORD.

    We can set the properties for envMappings as below. For each environment, secret represents the secret name, and key represents the key of the secret.

    Here is the complete properties for the trait.

    1. traits:
    2. - type: service-binding
    3. properties:
    4. envMappings:
    5. DB_PASSWORD:
    6. secret: db-conn-example
    7. key: password
    8. endpoint:
    9. secret: db-conn-example
    10. key: endpoint
    11. username:
    12. secret: db-conn-example
    13. key: username

    In particular, if the environment name, like endpoint, is same to the key of the secret, we can omit the key. So we can simplify the properties as below.

    1. traits:
    2. - type: service-binding
    3. properties:
    4. envMappings:
    5. DB_PASSWORD:
    6. secret: db-conn-example
    7. key: password
    8. endpoint:
    9. secret: db-conn-example
    10. username:
    11. secret: db-conn-example

    We can finally prepare an Application for the business component binding-test-comp to consume the secret, which is a representative of a database cloud resource.

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: webapp
    5. spec:
    6. components:
    7. - name: binding-test-comp
    8. type: webservice
    9. properties:
    10. image: zzxwill/flask-web-application:v0.3.1-crossplane
    11. ports: 80
    12. traits:
    13. - type: service-binding
    14. properties:
    15. envMappings:
    16. # environments refer to db-conn secret
    17. DB_PASSWORD:
    18. secret: db-conn-example
    19. key: password
    20. endpoint:
    21. secret: db-conn-example
    22. username:
    23. secret: db-conn-example

    Deploy this YAML and the Secret db-conn-example will be binding into environment of workload.

    Specification (service-binding)

    NameDescriptionTypeRequiredDefault
    envMappingsThe mapping of environment variables to secret.map[string]KeySecret(#keysecret-service-binding)true

    KeySecret (service-binding)

    NameDescriptionTypeRequiredDefault
    keystringfalse
    secretstringtrue

    Sidecar

    Description

    Inject a sidecar container to K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (sidecar)

    1. apiVersion: core.oam.dev/v1beta1
    2. kind: Application
    3. metadata:
    4. name: vela-app-with-sidecar
    5. spec:
    6. components:
    7. - name: log-gen-worker
    8. type: worker
    9. properties:
    10. image: busybox
    11. cmd:
    12. - /bin/sh
    13. - -c
    14. - >
    15. i=0;
    16. while true;
    17. do
    18. echo "$i: $(date)" >> /var/log/date.log;
    19. i=$((i+1));
    20. sleep 1;
    21. done
    22. volumes:
    23. - name: varlog
    24. mountPath: /var/log
    25. type: emptyDir
    26. traits:
    27. - type: sidecar
    28. properties:
    29. name: count-log
    30. image: busybox
    31. cmd: [ /bin/sh, -c, 'tail -n+1 -f /var/log/date.log']
    32. volumes:
    33. - name: varlog

    Specification (sidecar)

    NameDescriptionTypeRequiredDefault
    nameSpecify the name of sidecar container.stringtrue
    imageSpecify the image of sidecar container.stringtrue
    cmdSpecify the commands run in the sidecar.[]stringfalse
    argsSpecify the args in the sidecar.[]stringfalse
    envSpecify the env in the sidecar.[]envfalse
    volumesSpecify the shared volume path.false
    livenessProbeInstructions for assessing whether the container is alive.livenessProbefalse
    readinessProbeInstructions for assessing whether the container is in a suitable state to serve traffic.false

    env (sidecar)

    NameDescriptionTypeRequiredDefault
    nameEnvironment variable name.stringtrue
    valueThe value of the environment variable.stringfalse
    valueFromSpecifies a source the value of this var should come from.false
    valueFrom (sidecar)
    NameDescriptionTypeRequiredDefault
    secretKeyRefSelects a key of a secret in the pod’s namespace.false
    configMapKeyRefSelects a key of a config map in the pod’s namespace.configMapKeyReffalse
    fieldRefSpecify the field reference for env.false
    secretKeyRef (sidecar)
    NameDescriptionTypeRequiredDefault
    nameThe name of the secret in the pod’s namespace to select from.stringtrue
    keyThe key of the secret to select from. Must be a valid secret key.stringtrue
    configMapKeyRef (sidecar)
    NameDescriptionTypeRequiredDefault
    nameThe name of the config map in the pod’s namespace to select from.stringtrue
    keyThe key of the config map to select from. Must be a valid secret key.stringtrue
    fieldRef (sidecar)
    NameDescriptionTypeRequiredDefault
    fieldPathSpecify the field path for env.stringtrue

    volumes (sidecar)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    pathstringtrue

    livenessProbe (sidecar)

    NameDescriptionTypeRequiredDefault
    execInstructions for assessing container health by executing a command. Either this attribute or the httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the httpGet attribute and the tcpSocket attribute.false
    httpGetInstructions for assessing container health by executing an HTTP GET request. Either this attribute or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the tcpSocket attribute.httpGetfalse
    tcpSocketInstructions for assessing container health by probing a TCP socket. Either this attribute or the exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the httpGet attribute.false
    initialDelaySecondsNumber of seconds after the container is started before the first probe is initiated.intfalse0
    periodSecondsHow often, in seconds, to execute the probe.intfalse10
    timeoutSecondsNumber of seconds after which the probe times out.intfalse1
    successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.intfalse1
    failureThresholdNumber of consecutive failures required to determine the container is not alive (liveness probe) or not ready (readiness probe).intfalse3
    exec (sidecar)
    NameDescriptionTypeRequiredDefault
    commandA command to be executed inside the container to assess its health. Each space delimited token of the command is a separate array element. Commands exiting 0 are considered to be successful probes, whilst all other exit codes are considered failures.[]stringtrue
    httpGet (sidecar)
    NameDescriptionTypeRequiredDefault
    pathThe endpoint, relative to the port, to which the HTTP GET request should be directed.stringtrue
    portThe TCP socket within the container to which the HTTP GET request should be directed.inttrue
    httpHeaders[]httpHeadersfalse
    httpHeaders (sidecar)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    valuestringtrue
    tcpSocket (sidecar)
    NameDescriptionTypeRequiredDefault
    portThe TCP socket within the container that should be probed to assess container health.inttrue

    readinessProbe (sidecar)

    NameDescriptionTypeRequiredDefault
    execInstructions for assessing container health by executing a command. Either this attribute or the httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the httpGet attribute and the tcpSocket attribute.execfalse
    httpGetInstructions for assessing container health by executing an HTTP GET request. Either this attribute or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the tcpSocket attribute.false
    tcpSocketInstructions for assessing container health by probing a TCP socket. Either this attribute or the exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the httpGet attribute.tcpSocketfalse
    initialDelaySecondsNumber of seconds after the container is started before the first probe is initiated.intfalse0
    periodSecondsHow often, in seconds, to execute the probe.intfalse10
    timeoutSecondsNumber of seconds after which the probe times out.intfalse1
    successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.intfalse1
    failureThresholdNumber of consecutive failures required to determine the container is not alive (liveness probe) or not ready (readiness probe).intfalse3
    exec (sidecar)
    NameDescriptionTypeRequiredDefault
    commandA command to be executed inside the container to assess its health. Each space delimited token of the command is a separate array element. Commands exiting 0 are considered to be successful probes, whilst all other exit codes are considered failures.[]stringtrue
    httpGet (sidecar)
    NameDescriptionTypeRequiredDefault
    pathThe endpoint, relative to the port, to which the HTTP GET request should be directed.stringtrue
    portThe TCP socket within the container to which the HTTP GET request should be directed.inttrue
    httpHeadersfalse
    httpHeaders (sidecar)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    valuestringtrue
    tcpSocket (sidecar)
    NameDescriptionTypeRequiredDefault
    portThe TCP socket within the container that should be probed to assess container health.inttrue

    Storage

    Description

    Add storages on K8s pod for your workload which follows the pod spec in path ‘spec.template’.

    Apply To Component Types

    Component based on the following kinds of resources:

    • deployments.apps
    • statefulsets.apps
    • daemonsets.apps
    • jobs.batch

    Examples (storage)

    Specification (storage)

    NameDescriptionTypeRequiredDefault
    pvcDeclare pvc type storage.false
    configMapDeclare config map type storage.[]configMapfalse
    secretDeclare secret type storage.false
    emptyDirDeclare empty dir type storage.[]emptyDirfalse

    pvc (storage)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    mountOnlyboolfalsefalse
    mountPathstringtrue
    subPathstringfalse
    volumeModestringfalseFilesystem
    volumeNamestringfalse
    accessModes[]stringtrue
    storageClassNamestringfalse
    resourcesresourcesfalse
    dataSourceReffalse
    dataSourcedataSourcefalse
    selectorfalse
    resources (storage)
    NameDescriptionTypeRequiredDefault
    requeststrue
    limitslimitsfalse
    requests (storage)
    NameDescriptionTypeRequiredDefault
    storagestringtrue
    limits (storage)
    NameDescriptionTypeRequiredDefault
    storagestringtrue
    dataSourceRef (storage)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    kindstringtrue
    apiGroupstringtrue
    dataSource (storage)
    NameDescriptionTypeRequiredDefault
    namestringtrue
    kindstringtrue
    apiGroupstringtrue
    selector (storage)
    NameDescriptionTypeRequiredDefault
    matchLabelsmap[string]stringfalse
    matchExpressionsmatchExpressionsfalse
    matchExpressions (storage)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    values[]stringtrue
    operatorstringtrue

    configMap (storage)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    mountOnlyboolfalsefalse
    mountToEnvfalse
    mountToEnvs[]mountToEnvsfalse
    mountPathstringfalse
    subPathstringfalse
    defaultModeintfalse420
    readOnlyboolfalsefalse
    datamap[string]_false
    itemsfalse
    mountToEnv (storage)
    NameDescriptionTypeRequiredDefault
    envNamestringtrue
    configMapKeystringtrue
    mountToEnvs (storage)
    NameDescriptionTypeRequiredDefault
    envNamestringtrue
    configMapKeystringtrue
    items (storage)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    pathstringtrue
    modeintfalse511

    secret (storage)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    mountOnlyboolfalsefalse
    mountToEnvmountToEnvfalse
    mountToEnvsfalse
    mountPathstringfalse
    subPathstringfalse
    defaultModeintfalse420
    readOnlyboolfalsefalse
    stringDatamap[string]false
    datamap[string]false
    items[]itemsfalse
    mountToEnv (storage)
    NameDescriptionTypeRequiredDefault
    envNamestringtrue
    secretKeystringtrue
    mountToEnvs (storage)
    NameDescriptionTypeRequiredDefault
    envNamestringtrue
    secretKeystringtrue
    items (storage)
    NameDescriptionTypeRequiredDefault
    keystringtrue
    pathstringtrue
    modeintfalse511

    emptyDir (storage)

    NameDescriptionTypeRequiredDefault
    namestringtrue
    mountPathstringtrue
    subPathstringfalse
    medium“” or “Memory”falseempty