Answers for "fabric8 kubernetes patch finalizer"

0

fabric8 kubernetes patch finalizer

MixedOperation<Dummy, DummyList, DoneableDummy, Resource<Dummy, DoneableDummy>> 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);
Posted by: Guest on August-10-2020
0

fabric8 kubernetes patch finalizer

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<String, Object> 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());
}
Posted by: Guest on August-10-2020

Browse Popular Code Answers by Language