<p>I'm using fabric8 and java operator sdk.
I'd like to remove one custom finalizer in the <code>deleteResource</code> handler of the <code>ResourceController</code>. 
What is the suggested way to remove the finalizer and save the custom resource?</p>

<p>I think you should be able to add finalizers using Fabric8 Kubernetes Client. For example, if you want to add/remove finalizers like these in your Custom Resource's metadata:</p>

<pre><code>  finalizers:
  - finalizer.stable.example.com
</code></pre>

<p>You can use either our typed API or typeless API for achieving this. I'm adding examples of both the approaches below using a <a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/crds/Dummy.java" rel="nofollow noreferrer"><code>Dummy</code></a> Custom Resource provided in our <a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java#L121" rel="nofollow noreferrer">CRDExample</a>:</p>

<h3>Typed API (Requires POJOs of Custom Resources)</h3>

<pre><code>MixedOperation&lt;Dummy, DummyList, DoneableDummy, Resource&lt;Dummy, DoneableDummy&gt;&gt; dummyCRClient = client
  .customResources(dummyCRD, Dummy.class, DummyList.class, DoneableDummy.class);
// Fetch resource fom Kubernetes API server
Dummy dummy2 = dummyCRClient.inNamespace("default").withName("second-dummy").get();
// Get metadata
ObjectMeta objectMeta = dummy2.getMetadata();
// Modify metadata
objectMeta.setFinalizers(Collections.singletonList("finalizer.stable.example.com"));
// Patch it back in Custom Resource
dummy2.setMetadata(objectMeta);

// Patch to Kubernetes
dummyCRClient.inNamespace("default").withName("second-dummy").patch(dummy2);
</code></pre>

<h3>Typeless API (Provides way to access raw JSON Custom Resources)</h3>

<pre><code>try (KubernetesClient client = new DefaultKubernetesClient()) {
    CustomResourceDefinitionContext crdContext = new CustomResourceDefinitionContext.Builder()
            .withGroup("demo.fabric8.io")
            .withPlural("dummies")
            .withScope("Namespaced")
            .withVersion("v1")
            .withName("dummies.demo.fabric8.io")
            .build();
    // Fetch resource fom Kubernetes API server
    Map&lt;String, Object&gt; dummy2  = client.customResource(crdContext).get("default", "second-dummy");
    JSONObject dummy2JsonObj = new JSONObject(dummy2);
    // Get metadata
    JSONObject dummy2ObjectMeta = dummy2JsonObj.getJSONObject("metadata");
    // Modify metadata
    dummy2ObjectMeta.put("finalizers", new String[] { "finalizer.stable.example.com"});
    // Patch it back in Custom Resource
    dummy2JsonObj.put("metadata", dummy2ObjectMeta);

    // Patch to Kubernetes
    client.customResource(crdContext).edit("default", "second-dummy", dummy2JsonObj.toString());
}

</code></pre>
