Skip to main content
Version: Next

Built-in Trait Type

This documentation will walk through all the built-in trait types sorted alphabetically.

It was generated automatically by scripts, please don't update manually, last updated at 2023-07-28T09:33:26+08:00.

Affinity

Description

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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
labels:
label-key: label-value
to-delete-label-key: to-delete-label-value
traits:
- type: affinity
properties:
podAffinity:
preferred:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: "secrity"
values: ["S1"]
namespaces: ["default"]
topologyKey: "kubernetes.io/hostname"

Specification (affinity)

NameDescriptionTypeRequiredDefault
podAffinitySpecify the pod affinity scheduling rules.podAffinityfalse
podAntiAffinitySpecify the pod anti-affinity scheduling rules.podAntiAffinityfalse
nodeAffinitySpecify the node affinity scheduling rules for the pod.nodeAffinityfalse
tolerationsSpecify tolerant taint.[]tolerationsfalse

podAffinity (affinity)

NameDescriptionTypeRequiredDefault
requiredSpecify the required during scheduling ignored during execution.[]requiredfalse
preferredSpecify the preferred during scheduling ignored during execution.[]preferredfalse
required (affinity)
NameDescriptionTypeRequiredDefault
labelSelectorlabelSelectorfalse
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
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.podAffinityTermtrue
podAffinityTerm (affinity)
NameDescriptionTypeRequiredDefault
labelSelectorlabelSelectorfalse
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
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.[]requiredfalse
preferredSpecify the preferred during scheduling ignored during execution.[]preferredfalse
required (affinity)
NameDescriptionTypeRequiredDefault
labelSelectorlabelSelectorfalse
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
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.podAffinityTermtrue
podAffinityTerm (affinity)
NameDescriptionTypeRequiredDefault
labelSelectorlabelSelectorfalse
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
matchExpressions[]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.[]preferredfalse
required (affinity)
NameDescriptionTypeRequiredDefault
nodeSelectorTermsSpecify a list of node selector.[]nodeSelectorTermstrue
nodeSelectorTerms (affinity)
NameDescriptionTypeRequiredDefault
matchExpressions[]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
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

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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: myapp
spec:
components:
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
port: 8000
traits:
- type: labels
properties:
"release": "stable"
- type: annotations
properties:
"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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
traits:
- type: sidecar
properties:
name: sidecar-nginx
image: nginx
- type: command
properties:
# you can use command to control multiple containers by filling `containers`
# NOTE: in containers, you must set the container name for each container
containers:
- containerName: busybox
command: ["sleep", "8640000"]
- containerName: sidecar-nginx
args: ["-q"]

Specification (command)

NameDescriptionTypeRequiredDefault
PatchParams 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.[]containerstrue
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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
traits:
- type: sidecar
properties:
name: sidecar-nginx
image: nginx
- type: container-image
properties:
# you can use container-image to control multiple containers by filling `containers`
# NOTE: in containers, you must set the container name for each container
containers:
- containerName: busybox
image: busybox-1.34.0
imagePullPolicy: IfNotPresent
- containerName: sidecar-nginx
image: nginx-1.20

Specification (container-image)

NameDescriptionTypeRequiredDefault
PatchParams or type-option-2false

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)

NameDescriptionTypeRequiredDefault
containersSpecify the container image for multiple containers.[]containerstrue
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

Container-Ports

Description

Expose on the host and bind the external port to host to enable web traffic for your component.

Apply To Component Types

Component based on the following kinds of resources:

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

Examples (container-ports)

It's used to define Pod networks directly. hostPort routes the container's port directly to the port on the scheduled node, so that you can access the Pod through the host's IP plus hostPort. Don't specify a hostPort for a Pod unless it is absolutely necessary(run DaemonSet service). When you bind a Pod to a hostPort, it limits the number of places the Pod can be scheduled, because each <hostIP, hostPort, protocol> combination must be unique. If you don't specify the hostIP and protocol explicitly, Kubernetes will use 0.0.0.0 as the default hostIP and TCP as the default protocol. If you explicitly need to expose a Pod's port on the node, consider using expose or gateway trait, or exposeType and ports parameter of webservice component before resorting to container-ports trait.

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
cpu: "0.5"
exposeType: ClusterIP
image: busybox
memory: 1024Mi
ports:
- expose: false
port: 80
protocol: TCP
- expose: false
port: 801
protocol: TCP
traits:
- type: container-ports
properties:
# you can use container-ports to control multiple containers by filling `containers`
# NOTE: in containers, you must set the container name for each container
containers:
- containerName: busybox
ports:
- containerPort: 80
protocol: TCP
hostPort: 8080

Specification (container-ports)

NameDescriptionTypeRequiredDefault
PatchParams or type-option-2false

PatchParams (container-ports)

NameDescriptionTypeRequiredDefault
containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
portsSpecify ports you want customer traffic sent to.[]portstrue
ports (container-ports)
NameDescriptionTypeRequiredDefault
containerPortNumber of port to expose on the pod's IP address.inttrue
protocolProtocol for port. Must be UDP, TCP, or SCTP."TCP" or "UDP" or "SCTP"falseTCP
hostPortNumber of port to expose on the host.intfalse
hostIPWhat host IP to bind the external port to.stringfalse

type-option-2 (container-ports)

NameDescriptionTypeRequiredDefault
containersSpecify the container ports for multiple containers.[]containerstrue
containers (container-ports)
NameDescriptionTypeRequiredDefault
containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
portsSpecify ports you want customer traffic sent to.[]portstrue
ports (container-ports)
NameDescriptionTypeRequiredDefault
containerPortNumber of port to expose on the pod's IP address.inttrue
protocolProtocol for port. Must be UDP, TCP, or SCTP."TCP" or "UDP" or "SCTP"falseTCP
hostPortNumber of port to expose on the host.intfalse
hostIPWhat host IP to bind the external port to.stringfalse

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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: website
spec:
components:
- name: frontend
type: webservice
properties:
image: nginx
traits:
- type: cpuscaler
properties:
min: 1
max: 10
cpuUtil: 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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
traits:
- type: sidecar
properties:
name: sidecar-nginx
image: nginx
- type: env
properties:
# you can use env to control multiple containers by filling `containers`
# NOTE: in containers, you must set the container name for each container
containers:
- containerName: busybox
env:
key_for_busybox_first: value_first
key_for_busybox_second: value_second
- containerName: sidecar-nginx
env:
key_for_nginx_first: value_first
key_for_nginx_second: value_second
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
traits:
- type: sidecar
properties:
name: sidecar-nginx
image: nginx
- type: env
properties:
# you can use env to control one container, if containerName not specified, it will patch on the first index container
containerName: busybox
env:
key_for_busybox_first: value_first
key_for_busybox_second: value_second

Specification (env)

NameDescriptionTypeRequiredDefault
PatchParams 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.[]containerstrue
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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test-app
spec:
components:
- name: hello-world
type: webservice
properties:
image: crccheck/hello-world
traits:
- type: expose
properties:
port: [8000]

Specification (expose)

NameDescriptionTypeRequiredDefault
portDeprecated, the old way to specify the exposion ports.[]intfalse
portsSpecify portsyou want customer traffic sent to.[]portsfalse
annotationsSpecify the annotations of the exposed service.map[string]stringtrue
matchLabelsmap[string]stringfalse
typeSpecify what kind of Service you want. options: "ClusterIP","NodePort","LoadBalancer","ExternalName"."ClusterIP" or "NodePort" or "LoadBalancer" or "ExternalName"falseClusterIP

ports (expose)

NameDescriptionTypeRequiredDefault
portNumber of port to expose on the pod's IP address.inttrue
nameName of the port.stringfalse
protocolProtocol for port. Must be UDP, TCP, or SCTP."TCP" or "UDP" or "SCTP"falseTCP
nodePortexposed node port. Only Valid when exposeType is NodePort.intfalse

Gateway

Description

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)

# vela-app.yaml
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: gateway
properties:
domain: testsvc.example.com
http:
"/": 8000

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
nameSpecify a unique name for this gateway, required to support multiple gateway traits on a component.stringfalse
pathTypeSpecify a pathType for the ingress rules, defaults to "ImplementationSpecific"."ImplementationSpecific" or "Prefix" or "Exact"falseImplementationSpecific

Hostalias

Description

Add host aliases 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 (hostalias)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-with-hostalias
spec:
components:
- name: busybox-runner
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000'
traits:
- type: hostalias
properties:
hostAliases:
- ip: 127.0.0.1
hostnames:
- localname
- locals

Specification (hostalias)

NameDescriptionTypeRequiredDefault
hostAliasesSpecify the hostAliases to add.[]hostAliasestrue

hostAliases (hostalias)

NameDescriptionTypeRequiredDefault
ipstringtrue
hostnames[]stringtrue

Hpa

Description

Configure k8s HPA for Deployment or Statefulsets.

Apply To Component Types

Component based on the following kinds of resources:

  • deployments.apps
  • statefulsets.apps

Examples (hpa)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: helloworld
spec:
components:
- name: helloworld
type: webservice
properties:
cpu: "0.5"
exposeType: ClusterIP
image: oamdev/hello-world
memory: 1024Mi
ports:
- expose: true
port: 80
protocol: TCP
traits:
- type: scaler
properties:
replicas: 1
- type: hpa
properties:
targetAPIVersion: apps/v1
targetKind: Deployment
max: 10
min: 1
cpu:
type: Utilization
value: 80
mem:
type: AverageValue
value: 90
podCustomMetrics:
# here are custom metric names and values. Please replace them to be your metrics
- name: pod_net_received_rate
value: "77"
- name: pod_net_transmitted_rate
value: "88"
- name: pod_net_received_packets_rate
value: "95"
- name: pod_net_transmitted_packets_rate
value: "99"
policies:
- name: apply-once
type: apply-once
properties:
enable: true
rules:
- strategy:
path: ["spec.replicas"]
selector:
resourceTypes: ["Deployment","StatefulSet"]

Specification (hpa)

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
targetAPIVersionSpecify the apiVersion of scale target.stringfalseapps/v1
targetKindSpecify the kind of scale target.stringfalseDeployment
cpucputrue
memmemfalse
podCustomMetricsSpecify custom metrics of pod type.[]podCustomMetricsfalse

cpu (hpa)

NameDescriptionTypeRequiredDefault
typeSpecify resource metrics in terms of percentage("Utilization") or direct value("AverageValue")."Utilization" or "AverageValue"falseUtilization
valueSpecify the value of CPU utilization or averageValue.intfalse50

mem (hpa)

NameDescriptionTypeRequiredDefault
typeSpecify resource metrics in terms of percentage("Utilization") or direct value("AverageValue")."Utilization" or "AverageValue"falseUtilization
valueSpecify the value of MEM utilization or averageValue.intfalse50

podCustomMetrics (hpa)

NameDescriptionTypeRequiredDefault
nameSpecify name of custom metrics.stringtrue
valueSpecify target value of custom metrics.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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
traits:
- type: init-container
properties:
name: init-busybox
image: busybox
cmd: ["echo", "hello"]
initMountPath: /data
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.[]envfalse
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.configMapKeyReffalse
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.

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

Apply To Component Types

All Component Types

Examples (json-merge-patch)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
labels:
pod-label-key: pod-label-value
to-delete-label-key: to-delete-label-value
traits:
# the json merge patch can be used to add, replace and delete fields
# the following part will
# 1. add `deploy-label-key` to deployment labels
# 2. set deployment replicas to 3
# 3. set `pod-label-key` to `pod-label-modified-value` in pod labels
# 4. delete `to-delete-label-key` in pod labels
# 5. reset `containers` for pod
- type: json-merge-patch
properties:
metadata:
labels:
deploy-label-key: deploy-label-added-value
spec:
replicas: 3
template:
metadata:
labels:
pod-label-key: pod-label-modified-value
to-delete-label-key: null
spec:
containers:
- name: busybox-new
image: busybox:1.34
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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
spec:
components:
- name: busybox
type: webservice
properties:
image: busybox
cmd: ["sleep", "86400"]
labels:
pod-label-key: pod-label-value
to-delete-label-key: to-delete-label-value
traits:
# the json patch can be used to add, replace and delete fields
# the following part will
# 1. add `deploy-label-key` to deployment labels
# 2. set deployment replicas to 3
# 3. set `pod-label-key` to `pod-label-modified-value` in pod labels
# 4. delete `to-delete-label-key` in pod labels
# 5. add sidecar container for pod
- type: json-patch
properties:
operations:
- op: add
path: "/spec/replicas"
value: 3
- op: replace
path: "/spec/template/metadata/labels/pod-label-key"
value: pod-label-modified-value
- op: remove
path: "/spec/template/metadata/labels/to-delete-label-key"
- op: add
path: "/spec/template/spec/containers/1"
value:
name: busybox-sidecar
image: busybox:1.34
command: ["sleep", "864000"]

Specification (json-patch)

NameDescriptionTypeRequiredDefault
operations[]operationstrue

operations (json-patch)

NameDescriptionTypeRequiredDefault
-{}true

K8s-Update-Strategy

Description

Set k8s update strategy for Deployment/DaemonSet/StatefulSet.

Apply To Component Types

Component based on the following kinds of resources:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps

Examples (k8s-update-strategy)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-with-update-strategy
spec:
components:
- name: helloworld
type: webservice
properties:
cpu: "0.5"
exposeType: ClusterIP
image: oamdev/hello-world:latest
memory: 1024Mi
ports:
- expose: true
port: 80
protocol: TCP
traits:
- type: scaler
properties:
replicas: 5
- type: k8s-update-strategy
properties:
targetAPIVersion: apps/v1
targetKind: Deployment
strategy:
type: RollingUpdate
rollingStrategy:
maxSurge: 20%
maxUnavailable: 30%
---
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-node-exporter
spec:
components:
- name: node-exporter
type: daemon
properties:
image: prom/node-exporter
imagePullPolicy: IfNotPresent
volumeMounts:
hostPath:
- mountPath: /host/sys
mountPropagation: HostToContainer
name: sys
path: /sys
readOnly: true
- mountPath: /host/root
mountPropagation: HostToContainer
name: root
path: /
readOnly: true
traits:
- properties:
args:
- --path.sysfs=/host/sys
- --path.rootfs=/host/root
- --no-collector.wifi
- --no-collector.hwmon
- --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
- --collector.netclass.ignored-devices=^(veth.*)$
type: command
- properties:
annotations:
prometheus.io/path: /metrics
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
port:
- 9100
type: expose
- properties:
cpu: 0.1
memory: 250Mi
type: resource
- type: k8s-update-strategy
properties:
targetAPIVersion: apps/v1
targetKind: DaemonSet
strategy:
type: RollingUpdate
rollingStrategy:
maxSurge: 20%
maxUnavailable: 30%




Specification (k8s-update-strategy)

NameDescriptionTypeRequiredDefault
targetAPIVersionSpecify the apiVersion of target.stringfalseapps/v1
targetKindSpecify the kind of target."Deployment" or "StatefulSet" or "DaemonSet"falseDeployment
strategySpecify the strategy of update.strategytrue

strategy (k8s-update-strategy)

NameDescriptionTypeRequiredDefault
typeSpecify the strategy type."RollingUpdate" or "Recreate" or "OnDelete"falseRollingUpdate
rollingStrategySpecify the parameters of rollong update strategy.rollingStrategyfalse
rollingStrategy (k8s-update-strategy)
NameDescriptionTypeRequiredDefault
maxSurgestringfalse25%
maxUnavailablestringfalse25%
partitionintfalse0

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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: myapp
spec:
components:
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
port: 8000
traits:
- type: labels
properties:
"release": "stable"
- type: annotations
properties:
"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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-with-lifecycle
spec:
components:
- name: busybox-runner
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000'
traits:
- type: lifecycle
properties:
postStart:
exec:
command:
- echo
- 'hello world'
preStop:
httpGet:
host: "www.aliyun.com"
scheme: "HTTPS"
port: 443

Specification (lifecycle)

NameDescriptionTypeRequiredDefault
postStartpostStartfalse
preStoppreStopfalse

postStart (lifecycle)

NameDescriptionTypeRequiredDefault
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
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

preStop (lifecycle)

NameDescriptionTypeRequiredDefault
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
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

Description

nocalhost develop configuration.

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 (nocalhost)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: bookinfo
spec:
components:
- name: productpage
type: webservice
properties:
image: nocalhost-docker.pkg.coding.net/nocalhost/bookinfo/productpage:latest
port: 9080
traits:
- type: nocalhost
properties:
port: 9080
gitUrl: https://github.com/nocalhost/bookinfo-productpage.git
image: nocalhost-docker.pkg.coding.net/nocalhost/dev-images/python:3.7.7-slim-productpage-with-pydevd
shell: "bash"
workDir: "/opt/work"
resources:
limits:
memory: 1Gi
cpu: "1"
requests:
memory: 512Mi
cpu: "0.5"
debug:
remoteDebugPort: 9009
hotReload: true
sync:
type: send
filePattern:
- ./
ignoreFilePattern:
- .git
- .idea
command:
run:
- sh
- run.sh
debug:
- sh
- debug.sh
env:
- name: "foo"
value: "bar"
portForward:
- 39080:9080

Specification (nocalhost)

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

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
requestsrequeststrue
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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: resource-app
spec:
components:
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
ports:
- port: 8000
traits:
- type: resource
properties:
cpu: 2
memory: 2Gi
requests:
cpu: 2
memory: 2Gi
limits:
cpu: 4
memory: 4Gi

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.requestsfalse
limitsSpecify the resources in limits.limitsfalse

requests (resource)

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

limits (resource)

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

Scaler

Description

Manually scale 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

Examples (scaler)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: website
spec:
components:
- name: frontend
type: webservice
properties:
image: nginx
traits:
- type: scaler
properties:
replicas: 2
- type: sidecar
properties:
name: "sidecar-test"
image: "fluentd"
- name: backend
type: worker
properties:
image: busybox
cmd:
- sleep
- '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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: vela-doc
namespace: vela-system
spec:
components:
- name: frontend
type: webservice
properties:
image: oamdev/vela-cli:v1.5.0-beta.1
cmd: ["/bin/vela","show"]
ports:
- port: 18081
expose: true
traits:
- type: service-account
properties:
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.[]privilegesfalse

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:

endpoint: https://xxx.com
password: 123
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.

traits:
- type: service-binding
properties:
envMappings:
DB_PASSWORD:
secret: db-conn-example
key: password
endpoint:
secret: db-conn-example
key: endpoint
username:
secret: db-conn-example
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.

traits:
- type: service-binding
properties:
envMappings:
DB_PASSWORD:
secret: db-conn-example
key: password
endpoint:
secret: db-conn-example
username:
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.

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: webapp
spec:
components:
- name: binding-test-comp
type: webservice
properties:
image: zzxwill/flask-web-application:v0.3.1-crossplane
ports: 80
traits:
- type: service-binding
properties:
envMappings:
# environments refer to db-conn secret
DB_PASSWORD:
secret: db-conn-example
key: password
endpoint:
secret: db-conn-example
username:
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)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: vela-app-with-sidecar
spec:
components:
- name: log-gen-worker
type: worker
properties:
image: busybox
cmd:
- /bin/sh
- -c
- >
i=0;
while true;
do
echo "$i: $(date)" >> /var/log/date.log;
i=$((i+1));
sleep 1;
done
volumes:
- name: varlog
mountPath: /var/log
type: emptyDir
traits:
- type: sidecar
properties:
name: count-log
image: busybox
cmd: [ /bin/sh, -c, 'tail -n+1 -f /var/log/date.log']
volumes:
- name: varlog
path: /var/log

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.[]volumesfalse
livenessProbeInstructions for assessing whether the container is alive.livenessProbefalse
readinessProbeInstructions for assessing whether the container is in a suitable state to serve traffic.readinessProbefalse

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.valueFromfalse
valueFrom (sidecar)
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.configMapKeyReffalse
fieldRefSpecify the field reference for env.fieldReffalse
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.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.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.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
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.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.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
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

Startup-Probe

Description

Add startup probe hooks for the specified 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 (startup-probe)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-with-startup-probe
spec:
components:
- name: busybox-runner
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000'
traits:
- type: sidecar
properties:
name: nginx
image: nginx
# This startup-probe is blocking the startup of the main container
# as the URL has a typo '.comm' vs '.com'
- type: startup-probe
properties:
containerName: "busybox-runner"
httpGet:
host: "www.guidewire.comm"
scheme: "HTTPS"
port: 443
periodSeconds: 4
failureThreshold: 4
# This startup probe targets the nginx sidecar
- type: startup-probe
properties:
containerName: nginx
httpGet:
host: "www.guidewire.com"
scheme: "HTTPS"
port: 443
periodSeconds: 5
failureThreshold: 5

Specification (startup-probe)

NameDescriptionTypeRequiredDefault
StartupProbeParams or type-option-2false

StartupProbeParams (startup-probe)

NameDescriptionTypeRequiredDefault
containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
initialDelaySecondsNumber of seconds after the container has started before liveness probes are initiated. Minimum value is 0.intfalse0
periodSecondsHow often, in seconds, to execute the probe. Minimum value is 1.intfalse10
timeoutSecondsNumber of seconds after which the probe times out. Minimum value is 1.intfalse1
successThresholdMinimum consecutive successes for the probe to be considered successful after having failed. Minimum value is 1.intfalse1
failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded. Minimum value is 1.intfalse3
terminationGracePeriodSecondsOptional duration in seconds the pod needs to terminate gracefully upon probe failure. Set this value longer than the expected cleanup time for your process.intfalse
execInstructions for assessing container startup status by executing a command. Either this attribute or the httpGet attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the httpGet attribute and the tcpSocket attribute and the gRPC attribute.execfalse
httpGetInstructions for assessing container startup status by executing an HTTP GET request. Either this attribute or the exec attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the tcpSocket attribute and the gRPC attribute.httpGetfalse
grpcInstructions for assessing container startup status by probing a gRPC service. Either this attribute or the exec attribute or the grpc attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the tcpSocket attribute.grpcfalse
tcpSocketInstructions for assessing container startup status by probing a TCP socket. Either this attribute or the exec attribute or the tcpSocket attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the gRPC attribute.tcpSocketfalse
exec (startup-probe)
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 (startup-probe)
NameDescriptionTypeRequiredDefault
pathThe endpoint, relative to the port, to which the HTTP GET request should be directed.stringfalse
portThe port numer to access on the host or container.inttrue
hostThe hostname to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead.stringfalse
schemeThe Scheme to use for connecting to the host."HTTP" or "HTTPS"falseHTTP
httpHeadersCustom headers to set in the request. HTTP allows repeated headers.[]httpHeadersfalse
httpHeaders (startup-probe)
NameDescriptionTypeRequiredDefault
nameThe header field name.stringtrue
valueThe header field value.stringtrue
grpc (startup-probe)
NameDescriptionTypeRequiredDefault
portThe port number of the gRPC service.inttrue
serviceThe name of the service to place in the gRPC HealthCheckRequest.stringfalse
tcpSocket (startup-probe)
NameDescriptionTypeRequiredDefault
portNumber or name of the port to access on the container.stringtrue
hostHost name to connect to, defaults to the pod IP.stringfalse

type-option-2 (startup-probe)

NameDescriptionTypeRequiredDefault
probesSpecify the startup probe for multiple containers.[]probestrue
probes (startup-probe)
NameDescriptionTypeRequiredDefault
containerNameSpecify the name of the target container, if not set, use the component name.stringfalseempty
initialDelaySecondsNumber of seconds after the container has started before liveness probes are initiated. Minimum value is 0.intfalse0
periodSecondsHow often, in seconds, to execute the probe. Minimum value is 1.intfalse10
timeoutSecondsNumber of seconds after which the probe times out. Minimum value is 1.intfalse1
successThresholdMinimum consecutive successes for the probe to be considered successful after having failed. Minimum value is 1.intfalse1
failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded. Minimum value is 1.intfalse3
terminationGracePeriodSecondsOptional duration in seconds the pod needs to terminate gracefully upon probe failure. Set this value longer than the expected cleanup time for your process.intfalse
execInstructions for assessing container startup status by executing a command. Either this attribute or the httpGet attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the httpGet attribute and the tcpSocket attribute and the gRPC attribute.execfalse
httpGetInstructions for assessing container startup status by executing an HTTP GET request. Either this attribute or the exec attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the tcpSocket attribute and the gRPC attribute.httpGetfalse
grpcInstructions for assessing container startup status by probing a gRPC service. Either this attribute or the exec attribute or the grpc attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the tcpSocket attribute.grpcfalse
tcpSocketInstructions for assessing container startup status by probing a TCP socket. Either this attribute or the exec attribute or the tcpSocket attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the gRPC attribute.tcpSocketfalse
exec (startup-probe)
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 (startup-probe)
NameDescriptionTypeRequiredDefault
pathThe endpoint, relative to the port, to which the HTTP GET request should be directed.stringfalse
portThe port numer to access on the host or container.inttrue
hostThe hostname to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead.stringfalse
schemeThe Scheme to use for connecting to the host."HTTP" or "HTTPS"falseHTTP
httpHeadersCustom headers to set in the request. HTTP allows repeated headers.[]httpHeadersfalse
httpHeaders (startup-probe)
NameDescriptionTypeRequiredDefault
nameThe header field name.stringtrue
valueThe header field value.stringtrue
grpc (startup-probe)
NameDescriptionTypeRequiredDefault
portThe port number of the gRPC service.inttrue
serviceThe name of the service to place in the gRPC HealthCheckRequest.stringfalse
tcpSocket (startup-probe)
NameDescriptionTypeRequiredDefault
portNumber or name of the port to access on the container.stringtrue
hostHost name to connect to, defaults to the pod IP.stringfalse

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)

# sample.yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: storage-app
spec:
components:
- name: express-server
type: webservice
properties:
image: oamdev/hello-world
ports:
- port: 8000
traits:
- type: storage
properties:
# PVC type storage
pvc:
- name: test1
mountPath: /test/mount/pvc
# EmptyDir type storage
emptyDir:
- name: test1
mountPath: /test/mount/emptydir
# ConfigMap type storage
configMap:
- name: test1
mountPath: /test/mount/cm
# Mount ConfigMap to Env
mountToEnv:
envName: TEST_ENV
configMapKey: key1
data:
key1: value1
key2: value2
# Secret type storage
secret:
- name: test1
mountPath: /test/mount/secret
# Mount Secret to Env
mountToEnv:
envName: TEST_SECRET
secretKey: key1
data:
key1: dmFsdWUx
key2: dmFsdWUy

Specification (storage)

NameDescriptionTypeRequiredDefault
pvcDeclare pvc type storage.[]pvcfalse
configMapDeclare config map type storage.[]configMapfalse
secretDeclare secret type storage.[]secretfalse
emptyDirDeclare empty dir type storage.[]emptyDirfalse
hostPathDeclare host path type storage.[]hostPathfalse

pvc (storage)

NameDescriptionTypeRequiredDefault
namestringtrue
mountOnlyboolfalsefalse
mountPathstringtrue
subPathstringfalse
volumeModestringfalseFilesystem
volumeNamestringfalse
accessModes[]stringtrue
storageClassNamestringfalse
resourcesresourcesfalse
dataSourceRefdataSourceReffalse
dataSourcedataSourcefalse
selectorselectorfalse
resources (storage)
NameDescriptionTypeRequiredDefault
requestsrequeststrue
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
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountPathstringfalse
subPathstringfalse
defaultModeintfalse420
readOnlyboolfalsefalse
datamap[string]_false
items[]itemsfalse
mountToEnv (storage)
NameDescriptionTypeRequiredDefault
envNamestringtrue
configMapKeystringtrue
mountToEnvs (storage)
NameDescriptionTypeRequiredDefault
envNamestringtrue
configMapKeystringtrue
items (storage)
NameDescriptionTypeRequiredDefault
keystringtrue
pathstringtrue
modeintfalse511

secret (storage)

NameDescriptionTypeRequiredDefault
namestringtrue
mountOnlyboolfalsefalse
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountPathstringtrue
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

hostPath (storage)

NameDescriptionTypeRequiredDefault
namestringtrue
pathstringtrue
mountPathstringtrue
type"Directory" or "DirectoryOrCreate" or "FileOrCreate" or "File" or "Socket" or "CharDevice" or "BlockDevice"falseDirectory

Topologyspreadconstraints

Description

Add topology spread constraints 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 (topologyspreadconstraints)

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: application-with-topologyspreadconstraints
spec:
components:
- name: busybox-runner
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000'
traits:
- type: topologyspreadconstraints
properties:
constraints:
- topologyKey: zone
labelSelector:
matchLabels:
zone: us-east-1a
maxSkew: 1
whenUnsatisfiable: DoNotSchedule
minDomains: 1
nodeAffinityPolicy: Ignore
nodeTaintsPolicy: Ignore
- topologyKey: node
labelSelector:
matchExpressions:
- key: foo
operator: In
values:
- abc
maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
minDomains: 1
nodeAffinityPolicy: Ignore
nodeTaintsPolicy: Ignore

Specification (topologyspreadconstraints)

NameDescriptionTypeRequiredDefault
constraints[]constraintstrue

constraints (topologyspreadconstraints)

NameDescriptionTypeRequiredDefault
maxSkewDescribe the degree to which Pods may be unevenly distributed.inttrue
topologyKeySpecify the key of node labels.stringtrue
whenUnsatisfiableIndicate how to deal with a Pod if it doesn't satisfy the spread constraint."DoNotSchedule" or "ScheduleAnyway"falseDoNotSchedule
labelSelectorlabelSelector to find matching Pods.labelSelectortrue
minDomainsIndicate a minimum number of eligible domains.intfalse
matchLabelKeysA list of pod label keys to select the pods over which spreading will be calculated.[]stringfalse
nodeAffinityPolicyIndicate how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew."Honor" or "Ignore"falseHonor
nodeTaintsPolicyIndicate how we will treat node taints when calculating pod topology spread skew."Honor" or "Ignore"falseHonor
labelSelector (topologyspreadconstraints)
NameDescriptionTypeRequiredDefault
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
matchExpressions (topologyspreadconstraints)
NameDescriptionTypeRequiredDefault
keystringtrue
operator"In" or "NotIn" or "Exists" or "DoesNotExist"falseIn
values[]stringfalse