Skip to content

Dependent resources initial support #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
metacosm opened this issue Dec 20, 2021 · 1 comment
Closed

Dependent resources initial support #771

metacosm opened this issue Dec 20, 2021 · 1 comment

Comments

@metacosm
Copy link
Collaborator

Most operators need to deal with dependent (also called secondary) resources. The goal of this feature is to support common use cases as simply as possible, in particular using a declarative API.

Right now, dependent resources are implemented using EventSources. This introduce complexity because the EventSource interface doesn't provide any hint as to what it might be used for. The feature is therefore not very discoverable.

Moreover, dealing with dependent resources involves quite a bit of boiler plate and is very often done similarly for a lot of operators. In essence, the process very often boils down to retrieving the resources associated with the primary resource and reconcile their state based on the state of the primary resource. The status of the primary resource is also very often computed based on the aggregate status of the dependent resources.

We propose to introduce specific support for dependent resources that would simplify their handling for simple yet common cases. That support wouldn't interfere with the rest of the framework in the sense that it should still be possible to write reconcilers without ever using the dependent resources support.

We have a prototype implementation that limits the scope of the support to only Kubernetes resources (i.e. external resources are not currently supported with the current implementation, though it could be extended to support such resources at some later time) but provides declarative support for dependent resources (via child fields of the ControllerConfiguration annotation).

In essence, a reconciler defines which is its primary resource (via its parameter type) and can additionally opt-in declaring dependent resources. The DependentResourceConfiguration annotation allows you to specify the behavior of your dependent resource by providing updater / builder "functions" (along with some other aspects of the dependent) that are called automatically by the framework when needed, thus allowing you to focus on the salient parts of the state management instead of having to deal with the low-level wiring of the events.

PR #726 provides a prototype of how things could look like. To get a feel of how this could look like more concretely, please look at https://github.com/java-operator-sdk/java-operator-sdk/pull/726/files#diff-2b32527ca84105529bced8f05e575c973c00abb045b30beb578aaa29cb3fd65b which shows the diff between the updated version of the TomcatReconciler class with its associated DeploymentDependentResource and ServiceDependentResource classes. Similarly, take a look at the WebappReconciler diff implementation: https://github.com/java-operator-sdk/java-operator-sdk/pull/726/files#diff-00b61e3c421a88aa771a8b8f9f7e8ba18d81b751e4cfc85062954dbfd81e1095

@metacosm metacosm self-assigned this Dec 20, 2021
@metacosm
Copy link
Collaborator Author

metacosm commented Jan 5, 2022

I'm re-working the implementation since the changes that were made in the mean time made it too difficult to merge back and also made me reconsider some things. See #785.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants