Interface ResourceReconciler<ApiType extends io.kubernetes.client.common.KubernetesObject>

Type Parameters:
ApiType - api type of the reconciler

public interface ResourceReconciler<ApiType extends io.kubernetes.client.common.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, apiListType = V1ConfigMapList.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);
   }
}
 
Since:
3.3
Author:
Pavol Gressa
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull io.kubernetes.client.extended.controller.reconciler.Result
    reconcile(@NonNull io.kubernetes.client.extended.controller.reconciler.Request request, @NonNull OperatorResourceLister<ApiType> lister)
    Reconcile the resource identified by the Request.
  • Method Details

    • reconcile

      @NonNull @NonNull io.kubernetes.client.extended.controller.reconciler.Result reconcile(@NonNull @NonNull io.kubernetes.client.extended.controller.reconciler.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 - request
      lister - lister for given operator's reconciler
      Returns:
      result