Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
use native fields dataInput and dataOutput
Browse files Browse the repository at this point in the history
Signed-off-by: Hongchao Deng <[email protected]>
  • Loading branch information
hongchaodeng committed Jun 12, 2020
1 parent f3ce699 commit b2f29d7
Showing 1 changed file with 31 additions and 56 deletions.
87 changes: 31 additions & 56 deletions design/resource-dependency.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,47 +132,35 @@ To achieve this, we propose:
fieldPath: status.connSecret
```
2. Add a field `valueFrom.dataOutputName` in Component ParameterValue to specify the dependency on data outputs:
2. Add a field `dataInputs` in Component configuration to specify a data input:

```yaml
parameterValues:
- name: <parameter-name>
valueFrom:
dataInputs:
- valueFrom:
dataOutputName: <dataoutput-object-name>
toFieldPaths: <field-paths-to-fill>
```

For example, web app's dependency on RDS's database secret could be specified as:

```yaml
kind: Component
metadata:
name: my-web
spec:
workload:
kind: MyWorkload
metadata:
name: my-web
parameters:
- name: database-secret # workload's fieldPaths needs to be filled
fieldPaths:
- spec.connSecret
---
kind: ApplicationConfiguration
spec:
components:
- componentName: my-rds
dataOutputs:
- name: mysql-conn-secret
fieldPath: status.connSecret
- componentName: my-web
parameterValues:
- name: database-secret
valueFrom:
dataInputs:
- valueFrom:
# Specify the dependency on a data output.
# The component's workload won't be created until the data output has returned value to fill workload's fieldPaths.
dataOutputName: mysql-conn-secret
toFieldPaths:
- "spec.connSecret"
- componentName: my-rds
dataOutputs:
- name: mysql-conn-secret
fieldPath: status.connSecret
```

In this case, the OAM runtime will automatically build a dependency from `my-web` to `my-rds`.
Expand All @@ -199,17 +187,7 @@ To achieve this, we propose:
connSecret: mysql-conn # patched by OAM runtime
```

3. Similary, add fields `dataOutputs` and `parameters` in Trait configuration to specify the dependency on data output objects.

```yaml
parameters:
- valueFrom:
dataOutputName: <dataoutput-object-name>
toFieldPaths: <field-paths-to-fill>
dataOutputs:
- name: <dataoutput-name>
fieldPath: <object-field-path>
```
3. Similary, add fields `dataOutputs` and `dataInputs` in Trait configuration to specify the dependency on data output objects.

For example, we have an etcd backup trait that relies on the data output from an etcd cluster resource.
We can specify it as:
Expand All @@ -229,7 +207,7 @@ To achieve this, we propose:
kind: EtcdBackup
metadata:
name: my-etcd-backup
parameters:
dataInputs:
- valueFrom: # An EtcdBackup trait has dependency on some DataOutput to fill its fields.
dataOutputName: etcd-conn-secret
toFieldPaths:
Expand All @@ -247,10 +225,17 @@ To achieve this, we propose:
### Generic core engine consideration

The design of resource dependency is a pretty generic engine that works for any k8s resources.
Even though we use OAM native fields like `Parameters` or `Outputs` fields, those are just representation layer.
Even though we use OAM native fields like `dataInputs` or `dataOutputs` fields, those are just representation layer.
The underlying dependency engine along with the DataInput and DataOutput model is the core implementation,
which should be generic enough to convert or adopt future concepts or fields.


## Impact to existing system

This proposal is additional to existing OAM runtime. It would not affect any existing deployments.

If dataOutputName in a data input doesn't match any name of the data outputs, it would fail the deployment.

### Spec upgrade path consideration

Initially the feature will be experimental. It might change iteratively.
Expand Down Expand Up @@ -290,19 +275,17 @@ In this section we are providing more solution examples for dependency use cases
kind: MyWorkload
metadata:
name: my-web
parameters:
- name: database-secret
fieldPaths: ["spec.connSecret"]
---
kind: ApplicationConfiguration
spec:
components:
- componentName: my-web
parameterValues:
- name: database-secret
valueFrom:
dataInputs:
- valueFrom:
dataOutputName: mysql-conn-secret
toFieldPaths:
- "spec.connSecret"
- componentName: my-rds
dataOutputs:
- name: mysql-conn-secret
Expand All @@ -318,6 +301,10 @@ In this section we are providing more solution examples for dependency use cases
spec:
components:
- componentName: my-web
dataInputs:
- fieldPaths: [] # This data input is for ordering purpose only
valueFrom:
dataOutputName: my-secret-binding
traits:
- trait:
apiVersion: core.oam.dev/v1alpha1
Expand All @@ -334,15 +321,3 @@ In this section we are providing more solution examples for dependency use cases
- name: my-secret-binding
fieldPath: status.ready
```

Component:

```yaml
kind: Component
metadata:
name: my-web
spec:
parameters:
- name: my-secret-binding
fieldPaths: [] # This parameter is for ordering purpose only
```

0 comments on commit b2f29d7

Please sign in to comment.