Docs: add inputs and outputs in workflow (#266)
* Docs: add inputs and outputs in workflow * optimize the en version * fix the doc
This commit is contained in:
parent
eecc8f5625
commit
2a48f3a9fb
|
@ -4,6 +4,50 @@ title: Data Pass Between Components
|
|||
|
||||
This section will introduce how to pass data between components.
|
||||
|
||||
## Inputs and Outputs
|
||||
|
||||
In KubeVela, we can use inputs and outputs in Components to pass data.
|
||||
|
||||
### Outputs
|
||||
|
||||
Outputs is made of `name` and `valueFrom`. Input will use `name` to reference output.
|
||||
|
||||
We can write `valueFrom` in the following ways:
|
||||
1. Fill string value in the field, eg. `valueFrom: testString`.
|
||||
2. Use expression, eg. `valueFrom: output.metadata.name`. Note that `output` is a built-in field referring to the resource in the component that is rendered and deployed to the cluster.
|
||||
3. Use `+` to combine above two ways, the computed value will be the result, eg. `valueFrom: output.metadata.name + "testString"`.
|
||||
|
||||
### Inputs
|
||||
|
||||
Inputs is made of `name` and `parameterKey`. Input uses `name` to reference output, `parameterKey` is a expression that assigns the value of the input to the corresponding field.
|
||||
|
||||
eg.
|
||||
|
||||
1. Specify inputs:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: wordpress
|
||||
type: helm
|
||||
inputs:
|
||||
- from: mysql-svc
|
||||
parameterKey: properties.values.externalDatabase.host
|
||||
```
|
||||
|
||||
2. The field parameterKey specifies the field path of the parameter key in component to be assigned after rendering:
|
||||
|
||||
Which means the input value will be passed into the below properties:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: wordpress
|
||||
type: helm
|
||||
properties:
|
||||
values:
|
||||
externalDatabase:
|
||||
host: <input value>
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
In the following we will apply a WordPress server with the MySQL address passed from a MySQL component:
|
||||
|
|
|
@ -130,8 +130,8 @@ spec:
|
|||
type: my-helm
|
||||
outputs:
|
||||
- name: msg
|
||||
# export the deployment status in my-helm
|
||||
exportKey: resource.value.status.conditions[0].message
|
||||
# get value from the deployment status in my-helm
|
||||
valueFrom: resource.value.status.conditions[0].message
|
||||
- name: send-message
|
||||
type: webhook-notification
|
||||
inputs:
|
||||
|
|
|
@ -4,6 +4,47 @@ title: 应用组件间的依赖和参数传递
|
|||
|
||||
本节将介绍如何在 KubeVela 中进行组件间的参数传递。
|
||||
|
||||
## 参数传递
|
||||
|
||||
在 KubeVela 中,可以在组件中通过 outputs 和 inputs 来指定要传输的数据。
|
||||
|
||||
### Outputs
|
||||
|
||||
outputs 由 `name` 和 `valueFrom` 组成。`name` 声明了这个 output 的名称,在 input 中将通过 `name` 引用 output。
|
||||
|
||||
`valueFrom` 有以下几种写法:
|
||||
1. 直接通过字符串表示值,如:`valueFrom: testString`。
|
||||
2. 通过表达式来指定值,如:`valueFrom: output.metadata.name`。注意,`output` 为固定内置字段,指向组件中被部署在集群里的资源。
|
||||
3. 通过 `+` 来任意连接以上两种写法,最终值是计算后的字符串拼接结果,如:`valueFrom: output.metadata.name + "testString"`。
|
||||
|
||||
### Inputs
|
||||
|
||||
inputs 由 `name` 和 `parameterKey` 组成。`name` 声明了这个 input 从哪个 output 中取值,`parameterKey` 为一个表达式,将会把 input 取得的值赋给对应的字段。
|
||||
|
||||
如:
|
||||
1. 指定 inputs:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: wordpress
|
||||
type: helm
|
||||
inputs:
|
||||
- from: mysql-svc
|
||||
parameterKey: properties.values.externalDatabase.host
|
||||
```
|
||||
|
||||
2. 经过渲染后,该组件的 `properties.values.externalDatabase.host` 字段中会被赋上值,效果如下所示:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: wordpress
|
||||
type: helm
|
||||
properties:
|
||||
values:
|
||||
externalDatabase:
|
||||
host: <input value>
|
||||
```
|
||||
|
||||
## 如何使用
|
||||
|
||||
假设我们希望在本地启动一个 WordPress,而这个 Wordpress 的数据存放在一个 MySQL 数据库中,我们需要将这个 MySQL 的地址传递给 WordPress。
|
||||
|
@ -23,7 +64,7 @@ spec:
|
|||
outputs:
|
||||
# 将 service 地址作为 output
|
||||
- name: mysql-svc
|
||||
exportKey: output.metadata.name + ".default.svc.cluster.local"
|
||||
valueFrom: output.metadata.name + ".default.svc.cluster.local"
|
||||
properties:
|
||||
repoType: helm
|
||||
url: https://charts.bitnami.com/bitnami
|
||||
|
|
|
@ -131,7 +131,7 @@ spec:
|
|||
outputs:
|
||||
- name: msg
|
||||
# 将 my-helm 中读取到的 deployment status 作为信息导出
|
||||
exportKey: resource.value.status.conditions[0].message
|
||||
valueFrom: resource.value.status.conditions[0].message
|
||||
- name: send-message
|
||||
type: webhook-notification
|
||||
inputs:
|
||||
|
|
Loading…
Reference in New Issue