Skip to content

Commit 9080152

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent a1573ae commit 9080152

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/content/en/docs/documentation/dependent-resource-and-workflows/dependent-resources.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,42 @@ as [integration tests](https://github.com/operator-framework/java-operator-sdk/t
355355
To see how bulk dependent resources interact with workflow conditions, please refer to this
356356
[integration test](https://github.com/operator-framework/java-operator-sdk/tree/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/bulkdependent/conidition).
357357

358+
## Dependent Resources with External Resource
359+
360+
Dependent resources are designed to manage also non-Kubernetes or external resources.
361+
To implement such dependent you can extend `AbstractExternalDependentResource` or one of it
362+
[subclasses](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external).
363+
364+
While with kubernetes resources we do some nice assumptions about the resources, like
365+
if there are multiple resources of the same type, we can select the target resource
366+
that dependent resource manages based on the name and namespace of the desired resource;
367+
or we can use a matcher based SSA in most of the cases if the resource is managed using SSA.
368+
369+
### Selecting the target resource
370+
371+
Unfortunately this is not true for external resources. So to make sure we are selecting
372+
the target resources from an event source, we provide a [mechanism](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java#L114-L138) that helps with that logic.
373+
Your POJO representing an external resource can implement [`ExternalResourceIDProvider`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/ExternalDependentIDProvider.java) :
374+
375+
```java
376+
377+
public interface ExternalDependentIDProvider<T> {
378+
379+
T externalResourceId();
380+
}
381+
```
382+
383+
That will provide an ID, what is used to check for equality for desired state and resources from event source caches.
384+
Not that if some reason this mechanism does not suit for you, you can simply
385+
override [`selectTargetSecondaryResource`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java)
386+
method.
387+
388+
### Matching external resources
389+
390+
By default, external resources are matched using [equality](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java#L88-L92).
391+
So you can override equals of you POJO representing an external resource.
392+
As an alternative you can always override the whole `match` method to completely customize matching.
393+
358394
## External State Tracking Dependent Resources
359395

360396
It is sometimes necessary for a controller to track external (i.e. non-Kubernetes) state to

0 commit comments

Comments
 (0)