Skip to content

Commit b0425a7

Browse files
committed
wip
1 parent c7f2ff6 commit b0425a7

File tree

2 files changed

+53
-11
lines changed

2 files changed

+53
-11
lines changed

docs/documentation/dependent-resources.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,15 @@ See the full source code [here](https://github.com/java-operator-sdk/java-operat
137137

138138
## Managed Dependent Resources
139139

140-
As mentioned previously, one goal of this implementation is to make it possible to semi-declaratively create and wire
140+
As mentioned previously, one goal of this implementation is to make it possible to declaratively create and wire
141141
dependent resources. You can annotate your reconciler with
142142
`@Dependent` annotations that specify which `DependentResource` implementation it depends upon. JOSDK will take the
143143
appropriate steps to wire everything together and call your
144144
`DependentResource` implementations `reconcile` method before your primary resource is reconciled. This makes sense in
145145
most use cases where the logic associated with the primary resource is usually limited to status handling based on the
146146
state of the secondary resources and the resources are not dependent on each other.
147147

148-
Note that all dependents will be reconciled in order. If an exception happens in one or more reconciliations, the
149-
followup resources will be reconciled.
148+
See [Workflows](https://javaoperatorsdk.io/docs/dependent-resources) how/ in what order the resources are reconciled.
150149

151150
This behavior and automated handling is referred to as "managed" because the `DependentResource` instances
152151
are managed by JOSDK.
@@ -186,15 +185,16 @@ sample [here](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/s
186185

187186
## Standalone Dependent Resources
188187

189-
To use dependent resources in more complex workflows, when there are some resources needs to be created only in certain
190-
conditions the standalone mode is available or the dependent resources are not independent of each other.
191-
For example if calling an API needs to happen if a service is already up and running
192-
(think configuring a running DB instance).
188+
In case just some or sub-set of the resources are desired to be managed by dependent resources use standalone mode.
193189
In practice this means that the developer is responsible to initializing and managing and
194-
calling `reconcile` method. However, this gives possibility for developers to fully customize the workflow for
190+
calling `reconcile` method. However, this gives possibility for developers to fully customize the process for
195191
reconciliation. Use standalone dependent resources for cases when managed does not fit.
196192

197-
The sample is similar to one above it just performs additional checks, and conditionally creates an `Ingress`:
193+
Note that [Workflows](https://javaoperatorsdk.io/docs/dependent-resources) support also standalone mode using
194+
standalone resources.
195+
196+
The sample is similar to one above it just performs additional checks, and conditionally creates an `Ingress`:
197+
(Note that now this condition creation is also possible with Workflows)
198198

199199
```java
200200

docs/documentation/workflows.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,55 @@ permalink: /docs/workflows
77

88
## Overview
99

10+
Kubernetes (k8s) does not have notion of a resource "depends on" on another k8s resource,
11+
in terms of in what order a set of resources should be reconciled. However, Kubernetes operators are used to manage also
12+
external (non 8s) resources. Typically, when an operator manages a service, where after the service is first deployed
13+
some additional API calls are required to configure it. In this case the configuration step depends
14+
on the service and related resources, in other words the configuration needs to be reconciled after the service is
15+
up and running.
16+
17+
The intention behind workflows is to make it easy to describe more complex, almost arbitrary scenarios in a declarative
18+
way. While [dependent resources](https://javaoperatorsdk.io/docs/dependent-resources) describes a logic how a single
19+
resources should be reconciled, workflows describes the process how a set of target resources should be reconciled in
20+
a generic way.
21+
22+
Workflows are defined as a set of [dependent resources](https://javaoperatorsdk.io/docs/dependent-resources) (DR)
23+
and dependencies between them, along with some conditions that mainly helps define optional resources and
24+
pre- and post-conditions to describe expected states of a resource at a certain point in the workflow.
25+
26+
1027
## Elements of Workflow
1128

29+
- **Dependent resource** (DR) - are the resources which are reconciled.
30+
- **Depends on relation** - if a DR B depends on another DR A, means that B will be reconciled after A is successfully
31+
reconciled.
32+
- **Reconcile precondition** - is a condition that needs to be fulfilled before the DR is reconciled. This allows also
33+
to define optional resources, that for example only created if a flag in a custom resource `.spec` has some
34+
specific value.
35+
- **Ready postcondition** - checks if a resource could be considered "ready", typically if pods of a deployment are up
36+
and running.
37+
- **Delete postcondition** - during the cleanup phase it can be used to check if the resources is successfully deleted,
38+
so the next resource on which the target resources depends can be deleted as next step.
39+
1240
## Defining Workflows
1341

14-
## Reconcile
42+
As for dependent resource there are two ways to define workflows, in managed and standalone way.
43+
44+
### Managed
45+
46+
47+
### Standalone
48+
49+
50+
## Reconciliation
51+
52+
[//]: # (todo mention parallelism)
1553

1654
## Cleanup
1755

18-
## Notes and some Caveats
56+
## Notes
57+
58+
- Workflows can be seen as a Directed Acyclic Graph (DAG) - or more precisely a set of DAGs - where nodes are the
59+
dependent resources and edges are the dependencies.
1960

61+
[//]: # (ready vs precondition)

0 commit comments

Comments
 (0)