版本:v1.8

内置运维特征列表

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

本文档由脚本自动生成,请勿手动修改,上次更新于 2023-01-16T19:19:03+08:00。

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

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. labels:
  13. label-key: label-value
  14. to-delete-label-key: to-delete-label-value
  15. traits:
  16. - type: affinity
  17. properties:
  18. podAffinity:
  19. preferred:
  20. - weight: 1
  21. podAffinityTerm:
  22. labelSelector:
  23. matchExpressions:
  24. - key: "secrity"
  25. values: ["S1"]
  26. namespaces: ["default"]
  27. topologyKey: "kubernetes.io/hostname"
名称描述类型是否必须默认值
podAffinity指定 pod 的亲和性调度规则。podAffinityfalse
podAntiAffinity指定 pod 的反亲和性调度规则。podAntiAffinityfalse
nodeAffinity指定 pod 的节点亲和性调度规则。nodeAffinityfalse
tolerationsSpecify tolerant taint。[]tolerationsfalse
名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。[]requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
namespaces[]stringfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
weight指定对应 podAffinityTerm 的权重。inttrue
podAffinityTerm指定一组 pod。podAffinityTermtrue
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
namespaces[]stringfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。[]requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
namespaces[]stringfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
weight指定对应 podAffinityTerm 的权重。inttrue
podAffinityTerm指定一组 pod。podAffinityTermtrue
名称描述类型是否必须默认值
labelSelectorlabelSelectorfalse
namespaces[]stringfalse
topologyKeystringtrue
namespaceSelectornamespaceSelectorfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse
名称描述类型是否必须默认值
required指定 requiredDuringSchedulingIgnoredDuringExecution 字段,只有规则被满足时才执行调度。requiredfalse
preferred指定 preferredDuringSchedulingIgnoredDuringExecution 字段,调度器会尝试寻找满足对应规则的节点。如果找不到匹配的节点,调度器仍然会调度该 Pod。[]preferredfalse
名称描述类型是否必须默认值
nodeSelectorTerms指定一组节点选择器。[]nodeSelectorTermstrue
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchFields[]matchFieldsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
values[]stringfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
values[]stringfalse
名称描述类型是否必须默认值
weightSpecify weight associated with matching the corresponding nodeSelector。inttrue
preferenceSpecify a node selector。preferencetrue
名称描述类型是否必须默认值
matchExpressions[]matchExpressionsfalse
matchFields[]matchFieldsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
values[]stringfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist” or “Gt” or “Lt”falseIn
values[]stringfalse
名称描述类型是否必须默认值
keystringfalse
operator“Equal” or “Exists”falseEqual
valuestringfalse
effect“NoSchedule” or “PreferNoSchedule” or “NoExecute”false
tolerationSeconds指定 toleration 的时间周期。intfalse

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

所有组件类型。

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: myapp
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: crccheck/hello-world
  11. port: 8000
  12. traits:
  13. - type: labels
  14. properties:
  15. "release": "stable"
  16. - type: annotations
  17. properties:
  18. "description": "web application"
名称描述类型是否必须默认值
-map[string]:(null|string)true

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. traits:
  13. - type: sidecar
  14. properties:
  15. name: sidecar-nginx
  16. image: nginx
  17. - type: command
  18. properties:
  19. # you can use command to control multiple containers by filling `containers`
  20. # NOTE: in containers, you must set the container name for each container
  21. containers:
  22. - containerName: busybox
  23. command: ["sleep", "8640000"]
  24. - containerName: sidecar-nginx
  25. args: ["-q"]
名称描述类型是否必须默认值
PatchParams or type-option-2false
名称描述类型是否必须默认值
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 argsnulltrue
delArgsSpecify the existing args to delete in the target container, cannot be used with argsnulltrue
名称描述类型是否必须默认值
containersSpecify the commands for multiple containers。[]containerstrue
名称描述类型是否必须默认值
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 argsnulltrue
delArgsSpecify the existing args to delete in the target container, cannot be used with argsnulltrue

Set the image of the container。

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. traits:
  13. - type: sidecar
  14. properties:
  15. name: sidecar-nginx
  16. image: nginx
  17. - type: container-image
  18. properties:
  19. # you can use container-image to control multiple containers by filling `containers`
  20. # NOTE: in containers, you must set the container name for each container
  21. containers:
  22. - containerName: busybox
  23. image: busybox-1.34.0
  24. imagePullPolicy: IfNotPresent
  25. - containerName: sidecar-nginx
  26. image: nginx-1.20
名称描述类型是否必须默认值
PatchParams or type-option-2false
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
containersSpecify the container image for multiple containers。[]containerstrue
名称描述类型是否必须默认值
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

Automatically scale the component based on CPU usage。

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: website
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: nginx
  11. traits:
  12. - type: cpuscaler
  13. properties:
  14. min: 1
  15. max: 10
  16. cpuUtil: 60
名称描述类型是否必须默认值
min能够将工作负载缩容到的最小副本个数。intfalse1
max能够将工作负载扩容到的最大副本个数。intfalse10
cpuUtil每个容器的平均 CPU 利用率 例如, 50 意味者 CPU 利用率为 50%。intfalse50
targetAPIVersionSpecify the apiVersion of scale target。stringfalseapps/v1
targetKindSpecify the kind of scale target。stringfalseDeployment

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. traits:
  13. - type: sidecar
  14. properties:
  15. name: sidecar-nginx
  16. image: nginx
  17. - type: env
  18. properties:
  19. # you can use env to control multiple containers by filling `containers`
  20. # NOTE: in containers, you must set the container name for each container
  21. containers:
  22. - containerName: busybox
  23. env:
  24. key_for_busybox_first: value_first
  25. key_for_busybox_second: value_second
  26. - containerName: sidecar-nginx
  27. env:
  28. key_for_nginx_first: value_first
  29. key_for_nginx_second: value_second
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. traits:
  13. - type: sidecar
  14. properties:
  15. name: sidecar-nginx
  16. image: nginx
  17. - type: env
  18. properties:
  19. # you can use env to control one container, if containerName not specified, it will patch on the first index container
  20. containerName: busybox
  21. env:
  22. key_for_busybox_first: value_first
  23. key_for_busybox_second: value_second
名称描述类型是否必须默认值
PatchParams or type-option-2false
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
containersSpecify the environment variables for multiple containers。[]containerstrue
名称描述类型是否必须默认值
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

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: test-app
  5. spec:
  6. components:
  7. - name: hello-world
  8. type: webservice
  9. properties:
  10. image: crccheck/hello-world
  11. traits:
  12. - type: expose
  13. properties:
  14. port: [8000]
名称描述类型是否必须默认值
port指定要暴露的端口。[]inttrue
annotationsSpecify the annotaions of the exposed service。map[string]stringtrue
type指定要创建的服务类型,可选值:”ClusterIP”,”NodePort”,”LoadBalancer”,”ExternalName”。“ClusterIP” or “NodePort” or “LoadBalancer” or “ExternalName”falseClusterIP

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  1. # vela-app.yaml
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: first-vela-app
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: oamdev/hello-world
  12. port: 8000
  13. traits:
  14. - type: gateway
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. "/": 8000
名称描述类型是否必须默认值
domain暴露服务所绑定的域名。stringfalse
http定义一组网关路径到 Pod 服务端口的映射关系。map[string]inttrue
class所使用的 kubernetes ingress class。stringfalsenginx
classInSpec在 kubernetes ingress 的 ‘.spec.ingressClassName’ 定义 ingress class 而不是在 ‘kubernetes.io/ingress.class’ 注解中定义。boolfalsefalse
secretNameSpecify the secret name you want to quote to use tls。stringfalse
gatewayHost指定 Ingress 网关的主机名,当为空时,会自动生成主机名。stringfalse

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: application-with-hostalias
  5. spec:
  6. components:
  7. - name: busybox-runner
  8. type: worker
  9. properties:
  10. image: busybox
  11. cmd:
  12. - sleep
  13. - '1000'
  14. traits:
  15. - type: hostalias
  16. properties:
  17. hostAliases:
  18. - ip: 127.0.0.1
  19. hostnames:
  20. - localname
  21. - locals
名称描述类型是否必须默认值
hostAliases定义容器内的 hostAliases。[]hostAliasestrue
名称描述类型是否必须默认值
ipstringtrue
hostnames[]stringtrue

Configure k8s HPA for Deployment or Statefulsets。

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: helloworld
  5. spec:
  6. components:
  7. - name: helloworld
  8. type: webservice
  9. properties:
  10. cpu: "0.5"
  11. exposeType: ClusterIP
  12. image: oamdev/hello-world
  13. memory: 1024Mi
  14. ports:
  15. - expose: true
  16. port: 80
  17. protocol: TCP
  18. traits:
  19. - type: scaler
  20. properties:
  21. replicas: 1
  22. - type: hpa
  23. properties:
  24. targetAPIVersion: apps/v1
  25. targetKind: Deployment
  26. max: 10
  27. min: 1
  28. cpu:
  29. type: Utilization
  30. value: 80
  31. mem:
  32. type: AverageValue
  33. value: 90
  34. podCustomMetrics:
  35. # here are custom metric names and values. Please replace them to be your metrics
  36. - name: pod_net_received_rate
  37. value: "77"
  38. - name: pod_net_transmitted_rate
  39. value: "88"
  40. - name: pod_net_received_packets_rate
  41. value: "95"
  42. - name: pod_net_transmitted_packets_rate
  43. value: "99"
  44. policies:
  45. - name: apply-once
  46. type: apply-once
  47. properties:
  48. enable: true
  49. rules:
  50. - strategy:
  51. path: ["spec.replicas"]
  52. selector:
  53. resourceTypes: ["Deployment","StatefulSet"]
名称描述类型是否必须默认值
min能够将工作负载缩容到的最小副本个数。intfalse1
max能够将工作负载扩容到的最大副本个数。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
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
nameSpecify name of custom metrics。stringtrue
valueSpecify target value of custom metrics。stringtrue

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: busybox
  5. spec:
  6. components:
  7. - name: busybox
  8. type: webservice
  9. properties:
  10. image: busybox
  11. cmd: ["sleep", "86400"]
  12. traits:
  13. - type: init-container
  14. properties:
  15. name: init-busybox
  16. image: busybox
  17. cmd: ["echo", "hello"]
  18. initMountPath: /data
  19. appMountPath: /data-initialized
名称描述类型是否必须默认值
name指定初始化容器的名称。stringtrue
image指定初始化容器的镜像。stringtrue
imagePullPolicy镜像拉取策略。“IfNotPresent” or “Always” or “Never”falseIfNotPresent
cmd指定初始化容器的命令。[]stringfalse
args指定初始化容器的参数。[]stringfalse
env指定初始化容器的环境变量。[]envfalse
mountName指定共享卷的挂载名。stringfalseworkdir
appMountPath指定共享卷在应用容器的挂载路径。stringtrue
initMountPath指定共享卷初始化容器的挂载路径。stringtrue
extraVolumeMounts指定初始化容器的额外挂载卷。[]extraVolumeMountstrue
名称描述类型是否必须默认值
name环境变量名称。stringtrue
value环境变量的值。stringfalse
valueFrom从哪个资源中读取环境变量的定义。valueFromfalse
名称描述类型是否必须默认值
secretKeyRefsecret 键的引用。secretKeyReffalse
configMapKeyRefconfigmap 键的引用。configMapKeyReffalse
名称描述类型是否必须默认值
nameSecret 名称。stringtrue
key选择 Secret 中存在的 key。stringtrue
名称描述类型是否必须默认值
name环境变量的名称。stringtrue
keyconfigmap 中的键名。stringtrue
名称描述类型是否必须默认值
name挂载的卷名。stringtrue
mountPath初始化容器中的挂载路径。stringtrue

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

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

所有组件类型。

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

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

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

所有组件类型。

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

Set k8s update strategy for Deployment/DaemonSet/StatefulSet。

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: application-with-update-strategy
  5. spec:
  6. components:
  7. - name: helloworld
  8. type: webservice
  9. properties:
  10. cpu: "0.5"
  11. exposeType: ClusterIP
  12. image: oamdev/hello-world:latest
  13. memory: 1024Mi
  14. ports:
  15. - expose: true
  16. port: 80
  17. protocol: TCP
  18. traits:
  19. - type: scaler
  20. properties:
  21. replicas: 5
  22. - type: k8s-update-strategy
  23. properties:
  24. targetAPIVersion: apps/v1
  25. targetKind: Deployment
  26. strategy:
  27. type: RollingUpdate
  28. rollingStrategy:
  29. maxSurge: 20%
  30. maxUnavailable: 30%
  31. ---
  32. apiVersion: core.oam.dev/v1beta1
  33. kind: Application
  34. metadata:
  35. name: application-node-exporter
  36. spec:
  37. components:
  38. - name: node-exporter
  39. type: daemon
  40. properties:
  41. image: prom/node-exporter
  42. imagePullPolicy: IfNotPresent
  43. volumeMounts:
  44. hostPath:
  45. - mountPath: /host/sys
  46. mountPropagation: HostToContainer
  47. name: sys
  48. path: /sys
  49. readOnly: true
  50. - mountPath: /host/root
  51. mountPropagation: HostToContainer
  52. name: root
  53. path: /
  54. readOnly: true
  55. traits:
  56. - properties:
  57. args:
  58. - --path.sysfs=/host/sys
  59. - --path.rootfs=/host/root
  60. - --no-collector.wifi
  61. - --no-collector.hwmon
  62. - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
  63. - --collector.netclass.ignored-devices=^(veth.*)$
  64. type: command
  65. - properties:
  66. annotations:
  67. prometheus.io/path: /metrics
  68. prometheus.io/port: "8080"
  69. prometheus.io/scrape: "true"
  70. port:
  71. - 9100
  72. type: expose
  73. - properties:
  74. cpu: 0.1
  75. memory: 250Mi
  76. type: resource
  77. - type: k8s-update-strategy
  78. properties:
  79. targetAPIVersion: apps/v1
  80. targetKind: DaemonSet
  81. strategy:
  82. type: RollingUpdate
  83. rollingStrategy:
  84. maxSurge: 20%
  85. maxUnavailable: 30%
名称描述类型是否必须默认值
targetAPIVersionSpecify the apiVersion of target。stringfalseapps/v1
targetKindSpecify the kind of target。“Deployment” or “StatefulSet” or “DaemonSet”falseDeployment
strategySpecify the strategy of update。strategytrue
名称描述类型是否必须默认值
typeSpecify the strategy type。“RollingUpdate” or “Recreate” or “OnDelete”falseRollingUpdate
rollingStrategySpecify the parameters of rollong update strategy。rollingStrategyfalse
名称描述类型是否必须默认值
maxSurgestringfalse25%
maxUnavailablestringfalse25%
partitionintfalse0

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

所有组件类型。

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: myapp
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: crccheck/hello-world
  11. port: 8000
  12. traits:
  13. - type: labels
  14. properties:
  15. "release": "stable"
  16. - type: annotations
  17. properties:
  18. "description": "web application"
名称描述类型是否必须默认值
-map[string]:(null|string)true

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: application-with-lifecycle
  5. spec:
  6. components:
  7. - name: busybox-runner
  8. type: worker
  9. properties:
  10. image: busybox
  11. cmd:
  12. - sleep
  13. - '1000'
  14. traits:
  15. - type: lifecycle
  16. properties:
  17. postStart:
  18. exec:
  19. command:
  20. - echo
  21. - 'hello world'
  22. preStop:
  23. httpGet:
  24. host: "www.aliyun.com"
  25. scheme: "HTTPS"
  26. port: 443
名称描述类型是否必须默认值
postStartpostStartfalse
preStoppreStopfalse
名称描述类型是否必须默认值
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
名称描述类型是否必须默认值
command[]stringtrue
名称描述类型是否必须默认值
pathstringfalse
portinttrue
hoststringfalse
scheme“HTTP” or “HTTPS”falseHTTP
httpHeaders[]httpHeadersfalse
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
名称描述类型是否必须默认值
portinttrue
hoststringfalse
名称描述类型是否必须默认值
execexecfalse
httpGethttpGetfalse
tcpSockettcpSocketfalse
名称描述类型是否必须默认值
command[]stringtrue
名称描述类型是否必须默认值
pathstringfalse
portinttrue
hoststringfalse
scheme“HTTP” or “HTTPS”falseHTTP
httpHeaders[]httpHeadersfalse
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
名称描述类型是否必须默认值
portinttrue
hoststringfalse

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

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: bookinfo
  5. spec:
  6. components:
  7. - name: productpage
  8. type: webservice
  9. properties:
  10. image: nocalhost-docker.pkg.coding.net/nocalhost/bookinfo/productpage:latest
  11. port: 9080
  12. traits:
  13. - type: nocalhost
  14. properties:
  15. port: 9080
  16. gitUrl: https://github.com/nocalhost/bookinfo-productpage.git
  17. image: nocalhost-docker.pkg.coding.net/nocalhost/dev-images/python:3.7.7-slim-productpage-with-pydevd
  18. shell: "bash"
  19. workDir: "/opt/work"
  20. resources:
  21. limits:
  22. memory: 1Gi
  23. cpu: "1"
  24. requests:
  25. memory: 512Mi
  26. cpu: "0.5"
  27. debug:
  28. remoteDebugPort: 9009
  29. hotReload: true
  30. sync:
  31. type: send
  32. filePattern:
  33. - ./
  34. ignoreFilePattern:
  35. - .git
  36. - .idea
  37. command:
  38. run:
  39. - sh
  40. - run.sh
  41. debug:
  42. - sh
  43. - debug.sh
  44. env:
  45. - name: "foo"
  46. value: "bar"
  47. portForward:
  48. - 39080:9080
名称描述类型是否必须默认值
portinttrue
serviceTypestringfalsedeployment
gitUrlstringfalse
imagestringtrue
shellstringfalsebash
workDirstringfalse/home/nocalhost-dev
storageClassstringfalse
commandcommandtrue
debugdebugfalse
hotReloadboolfalsetrue
syncsynctrue
env[]envfalse
portForward[]stringfalse
persistentVolumeDirs[]persistentVolumeDirsfalse
resourcesresourcestrue
名称描述类型是否必须默认值
run[]stringtrue
debug[]stringtrue
名称描述类型是否必须默认值
remoteDebugPortintfalse
名称描述类型是否必须默认值
typestringfalsesend
filePattern[]stringtrue
ignoreFilePattern[]stringtrue
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
名称描述类型是否必须默认值
pathstringtrue
capacitystringtrue
名称描述类型是否必须默认值
limitslimitstrue
requestsrequeststrue
名称描述类型是否必须默认值
memorystringfalse2Gi
cpustringfalse2
名称描述类型是否必须默认值
memorystringfalse512Mi
cpustringfalse0.5

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: resource-app
  5. spec:
  6. components:
  7. - name: express-server
  8. type: webservice
  9. properties:
  10. image: crccheck/hello-world
  11. ports:
  12. - port: 8000
  13. traits:
  14. - type: resource
  15. properties:
  16. cpu: 2
  17. memory: 2Gi
  18. requests:
  19. cpu: 2
  20. memory: 2Gi
  21. limits:
  22. cpu: 4
  23. memory: 4Gi
名称描述类型是否必须默认值
cpu指定 cpu 请求和限制的大小。numberfalse1
memory指定内存请求和限制的大小。stringfalse2048Mi
requests指定请求的资源。requestsfalse
limits指定限制的资源。limitsfalse
名称描述类型是否必须默认值
cpu指定 cpu 请求的大小。numberfalse1
memory指定内存请求的大小。stringfalse2048Mi
名称描述类型是否必须默认值
cpu指定 cpu 限制的大小。numberfalse1
memory指定内存限制的大小。stringfalse2048Mi

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: website
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: nginx
  11. traits:
  12. - type: scaler
  13. properties:
  14. replicas: 2
  15. - type: sidecar
  16. properties:
  17. name: "sidecar-test"
  18. image: "fluentd"
  19. - name: backend
  20. type: worker
  21. properties:
  22. image: busybox
  23. cmd:
  24. - sleep
  25. - '1000'
名称描述类型是否必须默认值
replicas工作负载的 Pod 个数。intfalse1

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: vela-doc
  5. namespace: vela-system
  6. spec:
  7. components:
  8. - name: frontend
  9. type: webservice
  10. properties:
  11. image: oamdev/vela-cli:v1.5.0-beta.1
  12. cmd: ["/bin/vela","show"]
  13. ports:
  14. - port: 18081
  15. expose: true
  16. traits:
  17. - type: service-account
  18. properties:
  19. name: kubevela-vela-core
名称描述类型是否必须默认值
name指定 ServiceAccount 名称。stringtrue
create指定是否创建新的 ServiceAccount。boolfalsefalse
privileges指定 ServiceAccount 的权限,若不为空,则会创建 RoleBinding 及 ClusterRoleBindings。[]privilegesfalse
名称描述类型是否必须默认值
verbs指定资源允许的动作。[]stringtrue
apiGroups指定资源的 apiGroups。[]stringfalse
resources指定允许的资源。[]stringfalse
resourceNames指定允许的资源名称。[]stringfalse
nonResourceURLs指定允许的资源 URL。[]stringfalse
scope指定权限的范围,默认为 namespace 范围。“namespace” or “cluster”falsenamespace

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

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. Prepare a Kubernetes Secret

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

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

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

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

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

Here is the complete properties for the trait.

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

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

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

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

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

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

名称描述类型是否必须默认值
envMappings环境变量到密钥的映射。map[string]KeySecret(#keysecret-service-binding)true
名称描述类型是否必须默认值
keystringfalse
secretstringtrue

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: vela-app-with-sidecar
  5. spec:
  6. components:
  7. - name: log-gen-worker
  8. type: worker
  9. properties:
  10. image: busybox
  11. cmd:
  12. - /bin/sh
  13. - -c
  14. - >
  15. i=0;
  16. while true;
  17. do
  18. echo "$i: $(date)" >> /var/log/date.log;
  19. i=$((i+1));
  20. sleep 1;
  21. done
  22. volumes:
  23. - name: varlog
  24. mountPath: /var/log
  25. type: emptyDir
  26. traits:
  27. - type: sidecar
  28. properties:
  29. name: count-log
  30. image: busybox
  31. cmd: [ /bin/sh, -c, 'tail -n+1 -f /var/log/date.log']
  32. volumes:
  33. - name: varlog
  34. path: /var/log
名称描述类型是否必须默认值
name容器名称。stringtrue
image容器镜像。stringtrue
cmd容器的执行命令。[]stringfalse
args指定 sidecar 中的参数。[]stringfalse
env指定 sidecar 中的环境变量。[]envfalse
volumes挂载卷。[]volumesfalse
livenessProbe判断容器是否存活的探针。livenessProbefalse
readinessProbe判断容器是否就绪,能够接受用户流量的探针。readinessProbefalse
名称描述类型是否必须默认值
name环境变量名称。stringtrue
value环境变量的值。stringfalse
valueFrom从哪个资源中读取环境变量的定义。valueFromfalse
名称描述类型是否必须默认值
secretKeyRefsecret 键的引用。secretKeyReffalse
configMapKeyRefconfigmap 键的引用。configMapKeyReffalse
fieldRef指定要用于环境变量的字段。fieldReffalse
名称描述类型是否必须默认值
nameSecret 名称。stringtrue
key选择 Secret 中存在的 key。stringtrue
名称描述类型是否必须默认值
name环境变量的名称。stringtrue
keyconfigmap 中的键名。stringtrue
名称描述类型是否必须默认值
fieldPath指定要用于环境变量的字段路径。stringtrue
名称描述类型是否必须默认值
namestringtrue
pathstringtrue
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
名称描述类型是否必须默认值
path定义服务端点请求的路径。stringtrue
port定义服务端点的端口号。inttrue
httpHeaders[]httpHeadersfalse
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
名称描述类型是否必须默认值
port指定健康检查的 TCP socket。inttrue
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
名称描述类型是否必须默认值
path定义服务端点请求的路径。stringtrue
port定义服务端点的端口号。inttrue
httpHeaders[]httpHeadersfalse
名称描述类型是否必须默认值
namestringtrue
valuestringtrue
名称描述类型是否必须默认值
port指定健康检查的 TCP socket。inttrue

Add startup probe hooks for the specified container of K8s pod for your workload which follows the pod spec in path ‘spec.template’。

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: application-with-startup-probe
  5. spec:
  6. components:
  7. - name: busybox-runner
  8. type: worker
  9. properties:
  10. image: busybox
  11. cmd:
  12. - sleep
  13. - '1000'
  14. traits:
  15. - type: sidecar
  16. properties:
  17. name: nginx
  18. image: nginx
  19. # This startup-probe is blocking the startup of the main container
  20. # as the URL has a typo '.comm' vs '.com'
  21. - type: startup-probe
  22. properties:
  23. containerName: "busybox-runner"
  24. httpGet:
  25. host: "www.guidewire.comm"
  26. scheme: "HTTPS"
  27. port: 443
  28. periodSeconds: 4
  29. failureThreshold: 4
  30. # This startup probe targets the nginx sidecar
  31. - type: startup-probe
  32. properties:
  33. containerName: nginx
  34. httpGet:
  35. host: "www.guidewire.com"
  36. scheme: "HTTPS"
  37. port: 443
  38. periodSeconds: 5
  39. failureThreshold: 5
名称描述类型是否必须默认值
StartupProbeParams or type-option-2false
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
名称描述类型是否必须默认值
path定义服务端点请求的路径。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
名称描述类型是否必须默认值
nameThe header field name。stringtrue
valueThe header field value。stringtrue
名称描述类型是否必须默认值
portThe port number of the gRPC service。inttrue
serviceThe name of the service to place in the gRPC HealthCheckRequest。stringfalse
名称描述类型是否必须默认值
portNumber or name of the port to access on the container。stringtrue
hostHost name to connect to, defaults to the pod IP。stringfalse
名称描述类型是否必须默认值
probesSpecify the startup probe for multiple containers。[]probestrue
名称描述类型是否必须默认值
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
名称描述类型是否必须默认值
command容器中执行的命令,命令返回 0 则为正常,否则则为失败。[]stringtrue
名称描述类型是否必须默认值
path定义服务端点请求的路径。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
名称描述类型是否必须默认值
nameThe header field name。stringtrue
valueThe header field value。stringtrue
名称描述类型是否必须默认值
portThe port number of the gRPC service。inttrue
serviceThe name of the service to place in the gRPC HealthCheckRequest。stringfalse
名称描述类型是否必须默认值
portNumber or name of the port to access on the container。stringtrue
hostHost name to connect to, defaults to the pod IP。stringfalse

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
  1. # sample.yaml
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: storage-app
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: oamdev/hello-world
  12. ports:
  13. - port: 8000
  14. traits:
  15. - type: storage
  16. properties:
  17. # PVC type storage
  18. pvc:
  19. - name: test1
  20. mountPath: /test/mount/pvc
  21. # EmptyDir type storage
  22. emptyDir:
  23. - name: test1
  24. mountPath: /test/mount/emptydir
  25. # ConfigMap type storage
  26. configMap:
  27. - name: test1
  28. mountPath: /test/mount/cm
  29. # Mount ConfigMap to Env
  30. mountToEnv:
  31. envName: TEST_ENV
  32. configMapKey: key1
  33. data:
  34. key1: value1
  35. key2: value2
  36. # Secret type storage
  37. secret:
  38. - name: test1
  39. mountPath: /test/mount/secret
  40. # Mount Secret to Env
  41. mountToEnv:
  42. envName: TEST_SECRET
  43. secretKey: key1
  44. data:
  45. key1: dmFsdWUx
  46. key2: dmFsdWUy
名称描述类型是否必须默认值
pvc声明 pvc 类型存储。[]pvcfalse
configMap声明 ConfigMap 类型存储。[]configMapfalse
secret声明 Secret 类型存储。[]secretfalse
emptyDir声明 EmptyDir 类型存储。[]emptyDirfalse
hostPathDeclare host path type storage。[]hostPathfalse
名称描述类型是否必须默认值
namestringtrue
mountOnlyboolfalsefalse
mountPathstringtrue
subPathstringfalse
volumeModestringfalseFilesystem
volumeNamestringfalse
accessModes[]stringtrue
storageClassNamestringfalse
resourcesresourcesfalse
dataSourceRefdataSourceReffalse
dataSourcedataSourcefalse
selectorselectorfalse
名称描述类型是否必须默认值
requestsrequeststrue
limitslimitsfalse
名称描述类型是否必须默认值
storagestringtrue
名称描述类型是否必须默认值
storagestringtrue
名称描述类型是否必须默认值
namestringtrue
kindstringtrue
apiGroupstringtrue
名称描述类型是否必须默认值
namestringtrue
kindstringtrue
apiGroupstringtrue
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressionsmatchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
values[]stringtrue
operatorstringtrue
名称描述类型是否必须默认值
namestringtrue
mountOnlyboolfalsefalse
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountPathstringfalse
subPathstringfalse
defaultModeintfalse420
readOnlyboolfalsefalse
datamap[string]_false
items[]itemsfalse
名称描述类型是否必须默认值
envNamestringtrue
configMapKeystringtrue
名称描述类型是否必须默认值
envNamestringtrue
configMapKeystringtrue
名称描述类型是否必须默认值
keystringtrue
pathstringtrue
modeintfalse511
名称描述类型是否必须默认值
namestringtrue
mountOnlyboolfalsefalse
mountToEnvmountToEnvfalse
mountToEnvs[]mountToEnvsfalse
mountPathstringfalse
subPathstringfalse
defaultModeintfalse420
readOnlyboolfalsefalse
stringDatamap[string]false
datamap[string]false
items[]itemsfalse
名称描述类型是否必须默认值
envNamestringtrue
secretKeystringtrue
名称描述类型是否必须默认值
envNamestringtrue
secretKeystringtrue
名称描述类型是否必须默认值
keystringtrue
pathstringtrue
modeintfalse511
名称描述类型是否必须默认值
namestringtrue
mountPathstringtrue
subPathstringfalse
medium“” or “Memory”falseempty
名称描述类型是否必须默认值
namestringtrue
pathstringtrue
mountPathstringtrue
type“Directory” or “DirectoryOrCreate” or “FileOrCreate” or “File” or “Socket” or “CharDevice” or “BlockDevice”falseDirectory

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

基于以下资源的组件:

  • deployments.apps
  • statefulsets.apps
  • daemonsets.apps
  • jobs.batch
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: application-with-topologyspreadconstraints
  5. spec:
  6. components:
  7. - name: busybox-runner
  8. type: worker
  9. properties:
  10. image: busybox
  11. cmd:
  12. - sleep
  13. - '1000'
  14. traits:
  15. - type: topologyspreadconstraints
  16. properties:
  17. constraints:
  18. - topologyKey: zone
  19. labelSelector:
  20. matchLabels:
  21. zone: us-east-1a
  22. maxSkew: 1
  23. whenUnsatisfiable: DoNotSchedule
  24. minDomains: 1
  25. nodeAffinityPolicy: Ignore
  26. nodeTaintsPolicy: Ignore
  27. - topologyKey: node
  28. labelSelector:
  29. matchExpressions:
  30. - key: foo
  31. operator: In
  32. values:
  33. - abc
  34. maxSkew: 1
  35. whenUnsatisfiable: ScheduleAnyway
  36. minDomains: 1
  37. nodeAffinityPolicy: Ignore
  38. nodeTaintsPolicy: Ignore
名称描述类型是否必须默认值
constraints[]constraintstrue
名称描述类型是否必须默认值
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
labelSelectorlabelSelectortrue
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
名称描述类型是否必须默认值
matchLabelsmap[string]stringfalse
matchExpressions[]matchExpressionsfalse
名称描述类型是否必须默认值
keystringtrue
operator“In” or “NotIn” or “Exists” or “DoesNotExist”falseIn
values[]stringfalse

Last updated on 2023年5月6日 by Tianxin Dong