Skip to main content
版本:v1.4

内置运维特征列表

本文档将按字典序展示所有内置运维特征的参数列表。

本文档由脚本自动生成,请勿手动修改,上次更新于 2022-07-28T17:57:01+08:00。

Affinity

描述

为 pod 添加 affinity 和 toleration,它遵循路径“spec.template”中的 pod 规范。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

参数说明 (affinity)

名称描述类型是否必须默认值
podAffinity指定 pod 的亲和性调度规则。podAffinityfalse
podAntiAffinity指定 pod 的反亲和性调度规则。podAntiAffinityfalse
nodeAffinity指定 pod 的节点亲和性调度规则。nodeAffinityfalse
tolerationsSpecify tolerant taint。[]tolerationsfalse

podAffinity (affinity)

名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。[]requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
required (affinity)
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
namespaces[]stringfalse
labelSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
namespaceSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
preferred (affinity)
名称描述类型是否必须默认值
weight指定对应 podAffinityTerm 的权重。inttrue
podAffinityTerm指定一组 pod。podAffinityTermtrue
podAffinityTerm (affinity)
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
namespaces[]stringfalse
labelSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
namespaceSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse

podAntiAffinity (affinity)

名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。[]requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
required (affinity)
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
namespaces[]stringfalse
labelSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
namespaceSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
preferred (affinity)
名称描述类型是否必须默认值
weight指定对应 podAffinityTerm 的权重。inttrue
podAffinityTerm指定一组 pod。podAffinityTermtrue
podAffinityTerm (affinity)
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
namespaces[]stringfalse
labelSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
namespaceSelector (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchLabelsmap[string]:stringfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse

nodeAffinity (affinity)

名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
required (affinity)
名称描述类型是否必须默认值
nodeSelectorTerms指定一组节点选择器。[]nodeSelectorTermstrue
nodeSelectorTerms (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchFields[]matchFieldsfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
matchFields (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
preferred (affinity)
名称描述类型是否必须默认值
weightSpecify weight associated with matching the corresponding nodeSelector。inttrue
preferenceSpecify a node selector。preferencetrue
preference (affinity)
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchFields[]matchFieldsfalse
matchExpressions (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse
matchFields (affinity)
名称描述类型是否必须默认值
keystringtrue
operatorstringfalseIn
values[]stringfalse

tolerations (affinity)

名称描述类型是否必须默认值
keystringfalse
effectstringfalse
valuestringfalse
operatorstringfalseEqual
tolerationSeconds指定 toleration 的时间周期。intfalse

Annotations

描述

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

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

所有组件类型。

示例 (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"

参数说明 (annotations)

名称描述类型是否必须默认值
-map[string]:(null|string)true

Command

描述

为 pod 添加命令,它遵循路径“spec.template”中的 pod 规范。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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"]

参数说明 (command)

名称描述类型是否必须默认值
--Composition type。parameter: cannot use value C{containerName: ("" | string), command: (null | [, ...string]), args: (null | [, ...string]), addArgs: (null | [, ...string]), delArgs: (*null | [, ...string])} (type struct) as stringfalse

Container-Image

描述

Set the image of the container。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (container-image)

名称描述类型是否必须默认值
--Composition type。parameter: cannot use value C{containerName: ("" | string), image: string, imagePullPolicy: ("" | "IfNotPresent" | "Always" | "Never")} (type struct) as stringfalse

Cpuscaler

描述

Automatically scale the component based on CPU usage。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps

示例 (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
cpuPercent: 60

参数说明 (cpuscaler)

名称描述类型是否必须默认值
targetAPIVersionSpecify the apiVersion of scale target。stringfalseapps/v1
targetKindSpecify the kind of scale target。stringfalseDeployment
min能够将工作负载缩容到的最小副本个数。intfalse1
max能够将工作负载扩容到的最大副本个数。intfalse10
cpuUtil每个容器的平均 CPU 利用率 例如, 50 意味者 CPU 利用率为 50%。intfalse50

Env

描述

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

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (env)

名称描述类型是否必须默认值
--Composition type。parameter: cannot use value C{env: {[]: (_: string)->string, }, containerName: ("" | string), replace: (false | bool), unset: (*[] | [, ...string])} (type struct) as stringfalse

Expose

描述

为组件暴露端口,以便能够通过 web 进行访问。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps

示例 (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]

参数说明 (expose)

名称描述类型是否必须默认值
annotationsSpecify the annotaions of the exposed service。map[string]:stringtrue
port指定要暴露的端口。[]inttrue
type指定要创建的服务类型,可选值:"ClusterIP","NodePort","LoadBalancer","ExternalName"。stringfalseClusterIP

Gateway

描述

为组件启用公网访问,使用 K8s v1.20+ 的 Ingress API。

适用于组件类型

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps

示例 (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

参数说明 (gateway)

名称描述类型是否必须默认值
http定义一组网关路径到 Pod 服务端口的映射关系。map[string]:inttrue
classInSpec在 kubernetes ingress 的 '.spec.ingressClassName' 定义 ingress class 而不是在 'kubernetes.io/ingress.class' 注解中定义。boolfalsefalse
class所使用的 kubernetes ingress class。stringfalsenginx
gatewayHost指定 Ingress 网关的主机名,当为空时,会自动生成主机名。stringfalse
secretNameSpecify the secret name you want to quote to use tls。stringfalse
domain暴露服务所绑定的域名。stringfalse

Hostalias

描述

Add host aliases on K8s pod for your workload which follows the pod spec in path 'spec.template'。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (hostalias)

名称描述类型是否必须默认值
hostAliases定义容器内的 hostAliases。[]hostAliasestrue

hostAliases (hostalias)

名称描述类型是否必须默认值
ipstringtrue
hostnames[]stringtrue

Import-Grafana-Dashboard

描述

导入 Grafana 仪表盘。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

参数说明 (import-grafana-dashboard)

名称描述类型是否必须默认值
grafanaServiceNamestringtrue
grafanaServiceNamespacestringfalsedefault
credentialSecretstringtrue
credentialSecretNamespacestringfalsedefault
urls[]stringtrue

Init-Container

描述

为 pod 添加初始化容器,并使用共享卷。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (init-container)

名称描述类型是否必须默认值
name指定初始化容器的名称。stringtrue
cmd指定初始化容器的命令。[]stringfalse
env指定初始化容器的环境变量。[]envfalse
mountName指定共享卷的挂载名。stringfalseworkdir
appMountPath指定共享卷在应用容器的挂载路径。stringtrue
image指定初始化容器的镜像。stringtrue
args指定初始化容器的参数。[]stringfalse
initMountPath指定共享卷初始化容器的挂载路径。stringtrue
extraVolumeMounts指定初始化容器的额外挂载卷。[]extraVolumeMountstrue

env (init-container)

名称描述类型是否必须默认值
name环境变量名称。stringtrue
value环境变量的值。stringfalse
valueFrom从哪个资源中读取环境变量的定义。valueFromfalse
valueFrom (init-container)
名称描述类型是否必须默认值
secretKeyRefsecret 键的引用。secretKeyReffalse
configMapKeyRefconfigmap 键的引用。configMapKeyReffalse
secretKeyRef (init-container)
名称描述类型是否必须默认值
nameSecret 名称。stringtrue
key选择 Secret 中存在的 key。stringtrue
configMapKeyRef (init-container)
名称描述类型是否必须默认值
name环境变量的名称。stringtrue
keyconfigmap 中的键名。stringtrue

extraVolumeMounts (init-container)

名称描述类型是否必须默认值
name挂载的卷名。stringtrue
mountPath初始化容器中的挂载路径。stringtrue

Json-Merge-Patch

描述

使用 JSON Merge Patch 策略,遵循 RFC 7396。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

所有组件类型。

参数说明 (json-merge-patch)

名称描述类型是否必须默认值
-map[string]:(null|bool|string|bytes|{...}|[...]|number)true

Json-Patch

描述

使用 JSON Patch 策略,遵循 RFC 6902。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

所有组件类型。

参数说明 (json-patch)

名称描述类型是否必须默认值
operations[]operationstrue

operations (json-patch)

名称描述类型是否必须默认值
-map[string]:(null|bool|string|bytes|{...}|[...]|number)true

Labels

描述

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

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

所有组件类型。

示例 (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"

参数说明 (labels)

名称描述类型是否必须默认值
-map[string]:(null|string)true

Lifecycle

描述

为 pod 添加生命周期钩子,它遵循路径“spec.template”中的 pod 规范。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (lifecycle)

名称描述类型是否必须默认值
postStartpostStartfalse
preStoppreStopfalse

postStart (lifecycle)

名称描述类型是否必须默认值
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
exec (lifecycle)
名称描述类型是否必须默认值
command[]stringtrue
httpGet (lifecycle)
名称描述类型是否必须默认值
pathstringfalse
portinttrue
hoststringfalse
schemestringfalseHTTP
httpHeaders[]httpHeadersfalse
httpHeaders (lifecycle)
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
tcpSocket (lifecycle)
名称描述类型是否必须默认值
portinttrue
hoststringfalse

preStop (lifecycle)

名称描述类型是否必须默认值
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
exec (lifecycle)
名称描述类型是否必须默认值
command[]stringtrue
httpGet (lifecycle)
名称描述类型是否必须默认值
pathstringfalse
portinttrue
hoststringfalse
schemestringfalseHTTP
httpHeaders[]httpHeadersfalse
httpHeaders (lifecycle)
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
tcpSocket (lifecycle)
名称描述类型是否必须默认值
portinttrue
hoststringfalse

Nocalhost

描述

使用 nocalhost 作为开发环境的配置。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (nocalhost)

名称描述类型是否必须默认值
env[]envfalse
portinttrue
serviceTypestringfalsedeployment
gitUrlstringfalse
imagestringtrue
shellstringfalsebash
workDirstringfalse/home/nocalhost-dev
storageClassstringfalse
resourcesresourcestrue
persistentVolumeDirs[]persistentVolumeDirsfalse
commandcommandtrue
debugdebugfalse
hotReloadboolfalsetrue
syncsynctrue
portForward[]stringfalse

env (nocalhost)

名称描述类型是否必须默认值
namestringtrue
valuestringtrue

resources (nocalhost)

名称描述类型是否必须默认值
limitslimitstrue
requestsrequeststrue
limits (nocalhost)
名称描述类型是否必须默认值
memorystringfalse2Gi
cpustringfalse2
requests (nocalhost)
名称描述类型是否必须默认值
memorystringfalse512Mi
cpustringfalse0.5

persistentVolumeDirs (nocalhost)

名称描述类型是否必须默认值
pathstringtrue
capacitystringtrue

command (nocalhost)

名称描述类型是否必须默认值
debug[...]true
run[...]true

debug (nocalhost)

名称描述类型是否必须默认值
remoteDebugPortintfalse

sync (nocalhost)

名称描述类型是否必须默认值
typestringfalsesend
filePattern[...]true
ignoreFilePattern[...]true

Resource

描述

为 pod 添加资源请求和限制,它遵循路径“spec.template”中的 pod 规范。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (resource)

名称描述类型是否必须默认值
cpu指定 cpu 请求和限制的大小。numberfalse1
memory指定内存请求和限制的大小。stringfalse2048Mi
requests指定请求的资源。requestsfalse
limits指定限制的资源。limitsfalse

requests (resource)

名称描述类型是否必须默认值
cpu指定 cpu 请求的大小。numberfalse1
memory指定内存请求的大小。stringfalse2048Mi

limits (resource)

名称描述类型是否必须默认值
cpu指定 cpu 限制的大小。numberfalse1
memory指定内存限制的大小。stringfalse2048Mi

Scaler

描述

调整 pod 的副本数,它遵循路径“spec.template”中的 pod 规范。

适用于组件类型

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps

示例 (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'

参数说明 (scaler)

名称描述类型是否必须默认值
replicas工作负载的 Pod 个数。intfalse1

Service-Account

描述

为 pod 指定 serviceAccount,它遵循路径“spec.template”中的 pod 规范。

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (service-account)

名称描述类型是否必须默认值
name指定 ServiceAccount 名称。stringtrue
create指定是否创建新的 ServiceAccount。boolfalsefalse
privileges指定 ServiceAccount 的权限,若不为空,则会创建 RoleBinding 及 ClusterRoleBindings。[]privilegesfalse

privileges (service-account)

名称描述类型是否必须默认值
verbs指定资源允许的动作。[]stringtrue
apiGroups指定资源的 apiGroups。[]stringfalse
resources指定允许的资源。[]stringfalse
resourceNames指定允许的资源名称。[]stringfalse
nonResourceURLs指定允许的资源 URL。[]stringfalse
scope指定权限的范围,默认为 namespace 范围。stringfalsenamespace

Service-Binding

描述

绑定云资源的密钥到组件环境变量中,该定义已废弃,请使用 'storage' 定义。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

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

示例 (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.

参数说明 (service-binding)

名称描述类型是否必须默认值
envMappings环境变量到密钥的映射。map[string]:#KeySecrettrue

Sidecar

描述

为 pod 添加 sidecar 容器,它遵循路径“spec.template”中的 pod 规范。

目前这个运维特征默认在 VelaUX 处隐藏,你可以在 CLI 侧使用。

适用于组件类型

基于以下资源的组件:

示例 (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

参数说明 (sidecar)

名称描述类型是否必须默认值
name容器名称。stringtrue
cmd容器的执行命令。[]stringfalse
env指定 sidecar 中的环境变量。[]envfalse
image容器镜像。stringtrue
args指定 sidecar 中的参数。[]stringfalse
volumes挂载卷。[]volumesfalse
livenessProbe判断容器是否存活的探针。livenessProbefalse
readinessProbe判断容器是否就绪,能够接受用户流量的探针。readinessProbefalse

env (sidecar)

名称描述类型是否必须默认值
name环境变量名称。stringtrue
value环境变量的值。stringfalse
valueFrom从哪个资源中读取环境变量的定义。valueFromfalse
valueFrom (sidecar)
名称描述类型是否必须默认值
secretKeyRefsecret 键的引用。secretKeyReffalse
configMapKeyRefconfigmap 键的引用。configMapKeyReffalse
fieldRef指定要用于环境变量的字段。fieldReffalse
secretKeyRef (sidecar)
名称描述类型是否必须默认值
nameSecret 名称。stringtrue
key选择 Secret 中存在的 key。stringtrue
configMapKeyRef (sidecar)
名称描述类型是否必须默认值
name环境变量的名称。stringtrue
keyconfigmap 中的键名。stringtrue
fieldRef (sidecar)
名称描述类型是否必须默认值
fieldPath指定要用于环境变量的字段路径。stringtrue

volumes (sidecar)

名称描述类型是否必须默认值
pathstringtrue
namestringtrue

livenessProbe (sidecar)

名称描述类型是否必须默认值
exec通过在容器中执行一条命令判断是否就绪。请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。execfalse
httpGet通过发送 httpGet 请求判断容器是否就绪。 请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。httpGetfalse
tcpSocket通过 tcpSocket 是否开启判断容器是否就绪。请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。tcpSocketfalse
initialDelaySeconds定义容器启动多少秒之后开始第一次检查。intfalse0
periodSeconds定义每次检查之间的时间间隔。intfalse10
timeoutSeconds定义检查的超时时间。intfalse1
successThreshold定义检查成功多少次之后判断容器已经就绪。intfalse1
failureThreshold定义检查失败多少次之后判断容器已经不健康。intfalse3
exec (sidecar)
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
httpGet (sidecar)
名称描述类型是否必须默认值
path定义服务端点请求的路径。stringtrue
port定义服务端点的端口号。inttrue
httpHeaders[]httpHeadersfalse
httpHeaders (sidecar)
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
tcpSocket (sidecar)
名称描述类型是否必须默认值
port指定健康检查的 TCP socket。inttrue

readinessProbe (sidecar)

名称描述类型是否必须默认值
exec通过在容器中执行一条命令判断是否就绪。请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。execfalse
httpGet通过发送 httpGet 请求判断容器是否就绪。 请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。httpGetfalse
tcpSocket通过 tcpSocket 是否开启判断容器是否就绪。请注意就绪性检查必须并且也只能定义 httpGet,tcpSocket 或者 exec 中的一个。tcpSocketfalse
initialDelaySeconds定义容器启动多少秒之后开始第一次检查。intfalse0
periodSeconds定义每次检查之间的时间间隔。intfalse10
timeoutSeconds定义检查的超时时间。intfalse1
successThreshold定义检查成功多少次之后判断容器已经就绪。intfalse1
failureThreshold定义检查失败多少次之后判断容器已经不健康。intfalse3
exec (sidecar)
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
httpGet (sidecar)
名称描述类型是否必须默认值
path定义服务端点请求的路径。stringtrue
port定义服务端点的端口号。inttrue
httpHeaders[]httpHeadersfalse
httpHeaders (sidecar)
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
tcpSocket (sidecar)
名称描述类型是否必须默认值
port指定健康检查的 TCP socket。inttrue

Storage

描述

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

适用于组件类型

基于以下资源的组件:

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

示例 (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

参数说明 (storage)

名称描述类型是否必须默认值
pvc声明 pvc 类型存储。[]pvcfalse
configMap声明 ConfigMap 类型存储。[]configMapfalse
secret声明 Secret 类型存储。[]secretfalse
emptyDir声明 EmptyDir 类型存储。[]emptyDirfalse

pvc (storage)

名称描述类型是否必须默认值
namestringtrue
mountPathstringtrue
volumeModestringfalseFilesystem
subPathstringfalse
mountOnlyboolfalsefalse
accessModes[...]true
volumeNamestringfalse
storageClassNamestringfalse
resourcesresourcesfalse
dataSourceRefdataSourceReffalse
dataSourcedataSourcefalse
selectorselectorfalse
resources (storage)
名称描述类型是否必须默认值
requestsrequeststrue
limitslimitsfalse
requests (storage)
名称描述类型是否必须默认值
storagestringtrue
limits (storage)
名称描述类型是否必须默认值
storagestringtrue
dataSourceRef (storage)
名称描述类型是否必须默认值
namestringtrue
kindstringtrue
apiGroupstringtrue
dataSource (storage)
名称描述类型是否必须默认值
namestringtrue
kindstringtrue
apiGroupstringtrue
selector (storage)
名称描述类型是否必须默认值
matchLabelsmap[string]:stringfalse
matchExpressionsmatchExpressionsfalse
matchExpressions (storage)
名称描述类型是否必须默认值
keystringtrue
values[]stringtrue
operatorstringtrue

configMap (storage)

名称描述类型是否必须默认值
namestringtrue
mountPathstringfalse
defaultModeintfalse420
items[]itemsfalse
subPathstringfalse
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountOnlyboolfalsefalse
datamap[string]:(null|bool|string|bytes|{...}|[...]|number)false
readOnlyboolfalsefalse
items (storage)
名称描述类型是否必须默认值
pathstringtrue
keystringtrue
modeintfalse511
mountToEnv (storage)
名称描述类型是否必须默认值
envNamestringtrue
configMapKeystringtrue
mountToEnvs (storage)
名称描述类型是否必须默认值
envNamestringtrue
configMapKeystringtrue

secret (storage)

名称描述类型是否必须默认值
namestringtrue
mountPathstringfalse
defaultModeintfalse420
items[]itemsfalse
subPathstringfalse
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountOnlyboolfalsefalse
datamap[string]:(null|bool|string|bytes|{...}|[...]|number)false
stringDatamap[string]:(null|bool|string|bytes|{...}|[...]|number)false
readOnlyboolfalsefalse
items (storage)
名称描述类型是否必须默认值
pathstringtrue
keystringtrue
modeintfalse511
mountToEnv (storage)
名称描述类型是否必须默认值
envNamestringtrue
secretKeystringtrue
mountToEnvs (storage)
名称描述类型是否必须默认值
envNamestringtrue
secretKeystringtrue

emptyDir (storage)

名称描述类型是否必须默认值
namestringtrue
mountPathstringtrue
mediumstringfalseempty
subPathstringfalse