Interface ResourceReconciler<ApiType extends KubernetesObject>

Type Parameters:
ApiType - kubernetes api type

public interface ResourceReconciler<ApiType extends KubernetesObject>
The ResourceReconciler defines an interface for reconciling the resource. In general a reconciler works by comparing the desired state of the resource against the actual cluster state, and then perform operations to make the actual cluster state reflect the desired specified state.

The ResourceReconciler operations are required to be idempotent as the reconciliation loop is executed every time there is a change of the resource.

This interface is meant to be used in combination with the Operator annotation where the subject of reconciliation is specified:

 @Operator(informer = @Informer(apiType = V1ConfigMap.class)))
 public class MyReconciler implements ResourceReconciler<V1ConfigMap> {
   @Override
   public Result reconcile(@NonNull Request request, @NonNull OperatorResourceLister<V1ConfigMap> lister) {
      Optional<V1ConfigMap> resource = lister.get(request);
      // reconcile
      return new Result(false);
   }
}
 
Author:
Pavol Gressa
  • Method Details

    • reconcile

      @NonNull @NonNull Result reconcile(@NonNull @NonNull Request request, @NonNull @NonNull OperatorResourceLister<ApiType> lister)
      Reconcile the resource identified by the Request. This operation is required to be idempotent.

      The OperatorResourceLister lister is used to retrieve resource from the local Cache.

      The lister returns empty optional if the resource was deleted. Always use finalizers to properly reconcile on resource deletion.

      Parameters:
      request - the reconciliation request
      lister - the lister for given operator's reconciler
      Returns:
      the reconciliation result