Configuring informers
Reconcilers are notified of changes happening on the cluster by informers, which watch resources of a given type and cache them locally.
The Java Operator SDK (JOSDK) lets you configure these informers with the @Informer annotation (io.javaoperatorsdk.operator.api.config.informer.Informer), which can be used in two places:
-
as the
informerfield of@ControllerConfiguration, to configure the informer watching the primary resources of a reconciler -
as the
informerfield of@KubernetesDependent, to configure the informer watching the secondary resources managed by a dependent resource
@ControllerConfiguration(name = "exposedapp", informer = @Informer(
namespaces = Constants.WATCH_CURRENT_NAMESPACE,
labelSelector = "app.kubernetes.io/managed-by=exposedapp"))
public class ExposedAppReconciler implements Reconciler<ExposedApp> {
// ...
}
@KubernetesDependent(informer = @Informer(labelSelector = "app.kubernetes.io/managed-by=exposedapp"))
public class DeploymentDependent extends CRUDKubernetesDependentResource<Deployment, ExposedApp> {
// ...
}
QOSDK processes the informer configuration of your reconcilers at build time. Some of the parameters can also be overridden using configuration properties, as detailed in Overriding the informer configuration with properties.
@Informer parameters
| Parameter | Default | Description | ||
|---|---|---|---|---|
|
none |
Name of the informer. Mostly useful to identify the informer, for example in logs or health checks. |
||
|
see description |
Namespaces the informer watches.
You can provide a list of namespace names or use one of the constants defined in
If no namespace is specified, a controller’s informer watches all namespaces, while a secondary resource’s informer watches the same namespaces as its controller. |
||
|
none |
Label selector that resources must match to be watched by the informer. Several comma-separated requirements can be specified, in which case resources must match all of them. |
||
|
none |
Label selector used to restrict the informer to a single shard, typically when the same workload is split across several operator instances.
It uses the same syntax as |
||
|
none |
Field selector that resources must match to be watched by the informer, specified as an array of
Set |
||
|
none |
Classes implementing |
||
|
|
Whether the informer should follow the changes when the namespaces watched by the controller are changed at runtime. |
||
|
none |
|
||
|
none |
Maximum number of items returned by a single list call when the informer starts. If set, the initial load of the informer cache is paginated. |
||
|
|
Whether resource versions can be considered as integers and therefore compared with each other. |
||
|
|
Whether to remove the namespace index that the informer maintains by default. JOSDK never reads that index, so removing it saves one entry per cached resource.
It is worth setting when the informer caches a large number of resources and nothing looks them up by namespace, in particular in combination with a custom
|
||
|
Deprecated and not used anymore: ghost resource checking is now triggered by the informer itself. |
|
The filter and item store classes configured on a |
Overriding the informer configuration with properties
The following parameters of a controller’s informer can be overridden without changing the code, using the name of the reconciler (as configured with @ControllerConfiguration(name = …)) to identify it:
| Parameter | Configuration property |
|---|---|
|
|
|
|
|
|
|
|
For example:
quarkus.operator-sdk.controllers."exposedapp".namespaces=team-a,team-b
quarkus.operator-sdk.controllers."exposedapp".selector=app.kubernetes.io/managed-by=exposedapp
quarkus.operator-sdk.controllers."exposedapp".field-selectors=metadata.name!=ignored
These properties are runtime properties: when they are set, they take precedence over the values provided by the annotation.
The operator-level quarkus.operator-sdk.namespaces property is only applied to the controllers for which namespaces are set neither with the annotation nor with a controller-specific property.
See the configuration reference for more details on these properties.