Dependency and Data Passing
This section will introduce the dependencies in components and how to pass data between components.
We use helm in the examples, make sure you enable the fluxcd addon:
#
DependencyWe can use dependsOn
to specify the dependencies between components.
For example, component A depends on component B:
In this case, KubeVela will deploy B first, and then deploy A when the component B is running.
#
How to useIf we want to apply a MySQL cluster, we need:
- Apply a secret for MySQL password.
- Apply MySQL controller.
- Apply MySQL cluster.
Apply the following file:
#
Expected OutcomeCheck the application in the cluster:
In the beginning, the status is running workflow since the mysql-controller is not ready.
After a while, all components is running successfully. The mysql-cluster
will be deployed after mysql-controller
and mysql-secret
is healthy
.
dependsOn
usehealthy
to check status. If the component ishealthy
, then KubeVela will deploy the next component. If you want to customize the healthy status of the component, please refer to Status Write Back
#
Inputs and OutputsIn KubeVela, we can use inputs and outputs in Components to pass data.
#
OutputsOutputs is made of name
and valueFrom
. Input will use name
to reference output.
We can write valueFrom
in the following ways:
- Fill string value in the field, eg.
valueFrom: testString
. - Use expression, eg.
valueFrom: output.metadata.name
. Note thatoutput
is a built-in field referring to the resource in the component that is rendered and deployed to the cluster. - Use
+
to combine above two ways, the computed value will be the result, eg.valueFrom: output.metadata.name + "testString"
.
#
InputsInputs is made of from
and parameterKey
. Input uses from
to reference output, parameterKey
is a expression that assigns the value of the input to the corresponding field.
eg.
- Specify inputs:
- 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:
#
How to useIn the following we will apply a WordPress server with the MySQL address passed from a MySQL component:
#
Expected OutcomeCheck the application in the cluster:
The WordPress with MySQL has been successfully applied.