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)
| Name | Description | Type | Required | Default |
|---|
| podAffinity | Specify the pod affinity scheduling rules. | podAffinity | false | |
| podAntiAffinity | Specify the pod anti-affinity scheduling rules. | podAntiAffinity | false | |
| nodeAffinity | Specify the node affinity scheduling rules for the pod. | nodeAffinity | false | |
| tolerations | Specify tolerant taint. | []tolerations | false | |
podAffinity (affinity)
| Name | Description | Type | Required | Default |
|---|
| required | Specify the required during scheduling ignored during execution. | []required | false | |
| preferred | Specify the preferred during scheduling ignored during execution. | []preferred | false | |
required (affinity)
labelSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
namespaceSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
preferred (affinity)
| Name | Description | Type | Required | Default |
|---|
| weight | Specify weight associated with matching the corresponding podAffinityTerm. | int | true | |
| podAffinityTerm | Specify a set of pods. | podAffinityTerm | true | |
podAffinityTerm (affinity)
labelSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
namespaceSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
podAntiAffinity (affinity)
| Name | Description | Type | Required | Default |
|---|
| required | Specify the required during scheduling ignored during execution. | []required | false | |
| preferred | Specify the preferred during scheduling ignored during execution. | []preferred | false | |
required (affinity)
labelSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
namespaceSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
preferred (affinity)
| Name | Description | Type | Required | Default |
|---|
| weight | Specify weight associated with matching the corresponding podAffinityTerm. | int | true | |
| podAffinityTerm | Specify a set of pods. | podAffinityTerm | true | |
podAffinityTerm (affinity)
labelSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
namespaceSelector (affinity)
| Name | Description | Type | Required | Default |
|---|
| matchLabels | | map[string]string | false | |
| matchExpressions | | []matchExpressions | false | |
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" | false | In |
| values | | []string | false | |
nodeAffinity (affinity)
| Name | Description | Type | Required | Default |
|---|
| required | Specify the required during scheduling ignored during execution. | required | false | |
| preferred | Specify the preferred during scheduling ignored during execution. | []preferred | false | |
required (affinity)
| Name | Description | Type | Required | Default |
|---|
| nodeSelectorTerms | Specify a list of node selector. | []nodeSelectorTerms | true | |
nodeSelectorTerms (affinity)
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" or "Gt" or "Lt" | false | In |
| values | | []string | false | |
matchFields (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" or "Gt" or "Lt" | false | In |
| values | | []string | false | |
preferred (affinity)
| Name | Description | Type | Required | Default |
|---|
| weight | Specify weight associated with matching the corresponding nodeSelector. | int | true | |
| preference | Specify a node selector. | preference | true | |
preference (affinity)
matchExpressions (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" or "Gt" or "Lt" | false | In |
| values | | []string | false | |
matchFields (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | true | |
| operator | | "In" or "NotIn" or "Exists" or "DoesNotExist" or "Gt" or "Lt" | false | In |
| values | | []string | false | |
tolerations (affinity)
| Name | Description | Type | Required | Default |
|---|
| key | | string | false | |
| operator | | "Equal" or "Exists" | false | Equal |
| value | | string | false | |
| effect | | "NoSchedule" or "PreferNoSchedule" or "NoExecute" | false | |
| tolerationSeconds | Specify the period of time the toleration. | int | false | |
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)
| Name | Description | Type | Required | Default |
|---|
| - | | 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:
containers:
- containerName: busybox
command: ["sleep", "8640000"]
- containerName: sidecar-nginx
args: ["-q"]
Specification (command)
PatchParams (command)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| command | Specify the command to use in the target container, if not set, it will not be changed. | null | true | |
| args | Specify the args to use in the target container, if set, it will override existing args. | null | true | |
| addArgs | Specify the args to add in the target container, existing args will be kept, cannot be used with args. | null | true | |
| delArgs | Specify the existing args to delete in the target container, cannot be used with args. | null | true | |
type-option-2 (command)
| Name | Description | Type | Required | Default |
|---|
| containers | Specify the commands for multiple containers. | []containers | true | |
containers (command)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| command | Specify the command to use in the target container, if not set, it will not be changed. | null | true | |
| args | Specify the args to use in the target container, if set, it will override existing args. | null | true | |
| addArgs | Specify the args to add in the target container, existing args will be kept, cannot be used with args. | null | true | |
| delArgs | Specify the existing args to delete in the target container, cannot be used with args. | null | true | |
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:
containers:
- containerName: busybox
image: busybox-1.34.0
imagePullPolicy: IfNotPresent
- containerName: sidecar-nginx
image: nginx-1.20
Specification (container-image)
PatchParams (container-image)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| image | Specify the image of the container. | string | true | |
| imagePullPolicy | Specify the image pull policy of the container. | "" or "IfNotPresent" or "Always" or "Never" | false | empty |
type-option-2 (container-image)
| Name | Description | Type | Required | Default |
|---|
| containers | Specify the container image for multiple containers. | []containers | true | |
containers (container-image)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| image | Specify the image of the container. | string | true | |
| imagePullPolicy | Specify the image pull policy of the container. | "" or "IfNotPresent" or "Always" or "Never" | false | empty |
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:
containers:
- containerName: busybox
ports:
- containerPort: 80
protocol: TCP
hostPort: 8080
Specification (container-ports)
PatchParams (container-ports)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| ports | Specify ports you want customer traffic sent to. | []ports | true | |
ports (container-ports)
| Name | Description | Type | Required | Default |
|---|
| containerPort | Number of port to expose on the pod's IP address. | int | true | |
| protocol | Protocol for port. Must be UDP, TCP, or SCTP. | "TCP" or "UDP" or "SCTP" | false | TCP |
| hostPort | Number of port to expose on the host. | int | false | |
| hostIP | What host IP to bind the external port to. | string | false | |
type-option-2 (container-ports)
| Name | Description | Type | Required | Default |
|---|
| containers | Specify the container ports for multiple containers. | []containers | true | |
containers (container-ports)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| ports | Specify ports you want customer traffic sent to. | []ports | true | |
ports (container-ports)
| Name | Description | Type | Required | Default |
|---|
| containerPort | Number of port to expose on the pod's IP address. | int | true | |
| protocol | Protocol for port. Must be UDP, TCP, or SCTP. | "TCP" or "UDP" or "SCTP" | false | TCP |
| hostPort | Number of port to expose on the host. | int | false | |
| hostIP | What host IP to bind the external port to. | string | false | |
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)
| Name | Description | Type | Required | Default |
|---|
| min | Specify the minimal number of replicas to which the autoscaler can scale down. | int | false | 1 |
| max | Specify the maximum number of of replicas to which the autoscaler can scale up. | int | false | 10 |
| cpuUtil | Specify the average cpu utilization, for example, 50 means the CPU usage is 50%. | int | false | 50 |
| targetAPIVersion | Specify the apiVersion of scale target. | string | false | apps/v1 |
| targetKind | Specify the kind of scale target. | string | false | Deployment |
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:
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:
containerName: busybox
env:
key_for_busybox_first: value_first
key_for_busybox_second: value_second
Specification (env)
PatchParams (env)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| replace | Specify if replacing the whole environment settings for the container. | bool | false | false |
| env | Specify the environment variables to merge, if key already existing, override its value. | map[string]string | true | |
| unset | Specify which existing environment variables to unset. | []string | true | |
type-option-2 (env)
| Name | Description | Type | Required | Default |
|---|
| containers | Specify the environment variables for multiple containers. | []containers | true | |
containers (env)
| Name | Description | Type | Required | Default |
|---|
| containerName | Specify the name of the target container, if not set, use the component name. | string | false | empty |
| replace | Specify if replacing the whole environment settings for the container. | bool | false | false |
| env | Specify the environment variables to merge, if key already existing, override its value. | map[string]string | true | |
| unset | Specify which existing environment variables to unset. | []string | true | |
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)
| Name | Description | Type | Required | Default |
|---|
| port | Deprecated, the old way to specify the exposion ports. | []int | false | |
| ports | Specify portsyou want customer traffic sent to. | []ports | false | |
| annotations | Specify the annotations of the exposed service. | map[string]string | true | |
| matchLabels | | map[string]string | false | |
| type | Specify what kind of Service you want. options: "ClusterIP","NodePort","LoadBalancer","ExternalName". | "ClusterIP" or "NodePort" or "LoadBalancer" or "ExternalName" | false | ClusterIP |
ports (expose)
| Name | Description | Type | Required | Default |
|---|
| port | Number of port to expose on the pod's IP address. | int | true | |
| name | Name of the port. | string | false | |
| protocol | Protocol for port. Must be UDP, TCP, or SCTP. | "TCP" or "UDP" or "SCTP" | false | TCP |
| nodePort | exposed node port. Only Valid when exposeType is NodePort. | int | false | |
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)
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)
| Name | Description | Type | Required | Default |
|---|
| domain | Specify the domain you want to expose. | string | false | |
| http | Specify the mapping relationship between the http path and the workload port. | map[string]int | true | |
| class | Specify the class of ingress to use. | string | false | nginx |
| classInSpec | Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation. | bool | false | false |
| secretName | Specify the secret name you want to quote to use tls. | string | false | |
| gatewayHost | Specify the host of the ingress gateway, which is used to generate the endpoints when the host is empty. | string | false | |
| name | Specify a unique name for this gateway, required to support multiple gateway traits on a component. | string | false | |
| pathType | Specify a pathType for the ingress rules, defaults to "ImplementationSpecific". | "ImplementationSpecific" or "Prefix" or "Exact" | false | ImplementationSpecific |
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)
| Name | Description | Type | Required | Default |
|---|
| hostAliases | Specify the hostAliases to add. | []hostAliases | true | |
hostAliases (hostalias)
| Name | Description | Type | Required | Default |
|---|
| ip | | string | true | |
| hostnames | | []string | true | |
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:
- 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)
| Name | Description | Type | Required | Default |
|---|
| min | Specify the minimal number of replicas to which the autoscaler can scale down. | int | false | 1 |
| max | Specify the maximum number of of replicas to which the autoscaler can scale up. | int | false | 10 |
| targetAPIVersion | Specify the apiVersion of scale target. | string | false | apps/v1 |
| targetKind | Specify the kind of scale target. | string | false | Deployment |
| cpu | | cpu | true | |
| mem | | mem | false | |
| podCustomMetrics | Specify custom metrics of pod type. | []podCustomMetrics | false | |
cpu (hpa)
| Name | Description | Type | Required | Default |
|---|
| type | Specify resource metrics in terms of percentage("Utilization") or direct value("AverageValue"). | "Utilization" or "AverageValue" | false | Utilization |
| value | Specify the value of CPU utilization or averageValue. | int | false | 50 |
mem (hpa)
| Name | Description | Type | Required | Default |
|---|
| type | Specify resource metrics in terms of percentage("Utilization") or direct value("AverageValue"). | "Utilization" or "AverageValue" | false | Utilization |
| value | Specify the value of MEM utilization or averageValue. | int | false | 50 |
podCustomMetrics (hpa)
| Name | Description | Type | Required | Default |
|---|
| name | Specify name of custom metrics. | string | true | |
| value | Specify target value of custom metrics. | string | true | |
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)
| Name | Description | Type | Required | Default |
|---|
| name | Specify the name of init container. | string | true | |
| image | Specify the image of init container. | string | true | |
| imagePullPolicy | Specify image pull policy for your service. | "IfNotPresent" or "Always" or "Never" | false | IfNotPresent |
| cmd | Specify the commands run in the init container. | []string | false | |
| args | Specify the args run in the init container. | []string | false | |
| env | Specify the env run in the init container. | []env | false | |
| mountName | Specify the mount name of shared volume. | string | false | workdir |
| appMountPath | Specify the mount path of app container. | string | true | |
| initMountPath | Specify the mount path of init container. | string | true | |
| extraVolumeMounts | Specify the extra volume mounts for the init container. | []extraVolumeMounts | true | |
env (init-container)
| Name | Description | Type | Required | Default |
|---|
| name | Environment variable name. | string | true | |
| value | The value of the environment variable. | string | false | |
| valueFrom | Specifies a source the value of this var should come from. | valueFrom | false | |
valueFrom (init-container)
| Name | Description | Type | Required | Default |
|---|
| secretKeyRef | Selects a key of a secret in the pod's namespace. | secretKeyRef | false | |
| configMapKeyRef | Selects a key of a config map in the pod's namespace. | configMapKeyRef | false | |
secretKeyRef (init-container)
| Name | Description | Type | Required | Default |
|---|
| name | The name of the secret in the pod's namespace to select from. | string | true | |
| key | The key of the secret to select from. Must be a valid secret key. | string | true | |
configMapKeyRef (init-container)
| Name | Description | Type | Required | Default |
|---|
| name | The name of the config map in the pod's namespace to select from. | string | true | |
| key | The key of the config map to select from. Must be a valid secret key. | string | true | |
| Name | Description | Type | Required | Default |
|---|
| name | The name of the volume to be mounted. | string | true | |
| mountPath | The mountPath for mount in the init container. | string | true | |
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:
- 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)
| Name | Description | Type | Required | Default |
|---|
| - | | | 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:
- 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)
| Name | Description | Type | Required | Default |
|---|
| operations | | []operations | true | |
operations (json-patch)
| Name | Description | Type | Required | Default |
|---|
| - | | | 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)
| Name | Description | Type | Required | Default |
|---|
| targetAPIVersion | Specify the apiVersion of target. | string | false | apps/v1 |
| targetKind | Specify the kind of target. | "Deployment" or "StatefulSet" or "DaemonSet" | false | Deployment |
| strategy | Specify the strategy of update. | strategy | true | |
strategy (k8s-update-strategy)
| Name | Description | Type | Required | Default |
|---|
| type | Specify the strategy type. | "RollingUpdate" or "Recreate" or "OnDelete" | false | RollingUpdate |
| rollingStrategy | Specify the parameters of rollong update strategy. | rollingStrategy | false | |
rollingStrategy (k8s-update-strategy)
| Name | Description | Type | Required | Default |
|---|
| maxSurge | | string | false | 25% |
| maxUnavailable | | string | false | 25% |
| partition | | int | false | 0 |
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)
| Name | Description | Type | Required | Default |
|---|
| - | | 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)
postStart (lifecycle)
exec (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| command | | []string | true | |
httpGet (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| path | | string | false | |
| port | | int | true | |
| host | | string | false | |
| scheme | | "HTTP" or "HTTPS" | false | HTTP |
| httpHeaders | | []httpHeaders | false | |
| Name | Description | Type | Required | Default |
|---|
| name | | string | true | |
| value | | string | true | |
tcpSocket (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| port | | int | true | |
| host | | string | false | |
preStop (lifecycle)
exec (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| command | | []string | true | |
httpGet (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| path | | string | false | |
| port | | int | true | |
| host | | string | false | |
| scheme | | "HTTP" or "HTTPS" | false | HTTP |
| httpHeaders | | []httpHeaders | false | |
| Name | Description | Type | Required | Default |
|---|
| name | | string | true | |
| value | | string | true | |
tcpSocket (lifecycle)
| Name | Description | Type | Required | Default |
|---|
| port | | int | true | |
| host | | string | false | |
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)
| Name | Description | Type | Required | Default |
|---|
| port | | int | true | |
| serviceType | | string | false | deployment |
| gitUrl | | string | false | |
| image | | string | true | |
| shell | | string | false | bash |
| workDir | | string | false | /home/nocalhost-dev |
| storageClass | | string | false | |
| command | | command | true | |
| debug | | debug | false | |
| hotReload | | bool | false | true |
| sync | | sync | true | |
| env | | []env | false | |
| portForward | | []string | false | |
| persistentVolumeDirs | | []persistentVolumeDirs | false | |
| resources | | resources | true | |
command (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| run | | []string | true | |
| debug | | []string | true | |
debug (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| remoteDebugPort | | int | false | |
sync (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| type | | string | false | send |
| filePattern | | []string | true | |
| ignoreFilePattern | | []string | true | |
env (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| name | | string | true | |
| value | | string | true | |
persistentVolumeDirs (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| path | | string | true | |
| capacity | | string | true | |
resources (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| limits | | limits | true | |
| requests | | requests | true | |
limits (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| memory | | string | false | 2Gi |
| cpu | | string | false | 2 |
requests (nocalhost)
| Name | Description | Type | Required | Default |
|---|
| memory | | string | false | 512Mi |
| cpu | | string | false | 0.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)
| Name | Description | Type | Required | Default |
|---|
| cpu | Specify the amount of cpu for requests and limits. | number | false | 1 |
| memory | Specify the amount of memory for requests and limits. | string | false | 2048Mi |
| requests | Specify the resources in requests. | requests | false | |
| limits | Specify the resources in limits. | limits | false | |
requests (resource)
| Name | Description | Type | Required | Default |
|---|
| cpu | Specify the amount of cpu for requests. | number | false | 1 |
| memory | Specify the amount of memory for requests. | string | false | 2048Mi |
limits (resource)
| Name | Description | Type | Required | Default |
|---|
| cpu | Specify the amount of cpu for limits. | number | false | 1 |
| memory | Specify the amount of memory for limits. | string | false | 2048Mi |
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)
| Name | Description | Type | Required | Default |
|---|
| replicas | Specify the number of workload. | int | false | 1 |
Service-Account
Description