Architecture and Internals
This document provides an overview of the Java Operator SDK’s internal structure and components to help developers understand and contribute to the project. While not a comprehensive reference, it introduces core concepts that should make other components easier to understand.
The Big Picture and Core Components
An Operator is a set of independent controllers.
The Controller
class is an internal class managed by the framework and typically shouldn’t be interacted with directly. It manages all processing units involved with reconciling a single type of Kubernetes resource.
Core Components
- Reconciler - The primary entry point for developers to implement reconciliation logic
- EventSource - Represents a source of events that might trigger reconciliation
- EventSourceManager - Aggregates all event sources for a controller and manages their lifecycle
- ControllerResourceEventSource - Central event source that watches primary resources associated with a given controller for changes, propagates events and caches state
- EventProcessor - Processes incoming events sequentially per resource while allowing concurrent overall processing. Handles rescheduling and retrying
- ReconcilerDispatcher - Dispatches requests to appropriate
Reconciler
methods and handles reconciliation results, making necessary Kubernetes API calls
Typical Workflow
A typical workflow follows these steps:
- Event Generation: An
EventSource
produces an event and propagates it to theEventProcessor
- Resource Reading: The resource associated with the event is read from the internal cache
- Reconciliation Submission: If the resource isn’t already being processed, a reconciliation request is submitted to the executor service in a different thread (encapsulated in a
ControllerExecution
instance) - Dispatching: The
ReconcilerDispatcher
is called, which dispatches the call to the appropriateReconciler
method with all required information - Reconciler Execution: Once the
Reconciler
completes, theReconcilerDispatcher
makes appropriate Kubernetes API server calls based on the returned result - Finalization: The
EventProcessor
is called back to finalize execution and update the controller’s state - Rescheduling Check: The
EventProcessor
checks if the request needs rescheduling or retrying, and whether subsequent events were received for the same resource - Completion: When no further action is needed, event processing is finished
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.