Source:
<code>public static void main(String[] args) throws InterruptedException { Config config = new ConfigBuilder().build(); try (KubernetesClient kubernetesClient = new DefaultKubernetesClient(config)) { OpenShiftClient client = kubernetesClient.adapt(OpenShiftClient.class); ProjectRequest projectRequest = new ProjectRequestBuilder() .withNewMetadata() .withName("thisisatest") .addToLabels("project", "thisisatest") .endMetadata() .build(); log("Created project", client.projectrequests().create(projectRequest)); ServiceAccount fabric8 = new ServiceAccountBuilder().withNewMetadata().withName("fabric8").endMetadata().build(); client.serviceAccounts().inNamespace("thisisatest").createOrReplace(fabric8); log("Created deployment", client.deploymentConfigs().inNamespace("thisisatest").createOrReplaceWithNew() .withNewMetadata() .withName("nginx") .endMetadata() .withNewSpec() .withReplicas(1) .addNewTrigger() .withType("ConfigChange") .endTrigger() .addToSelector("app", "nginx") .withNewTemplate() .withNewMetadata() .addToLabels("app", "nginx") .endMetadata() .withNewSpec() .addNewContainer() .withName("nginx") .withImage("nginx") .addNewPort() .withContainerPort(80) .endPort() .endContainer() .endSpec() .endTemplate() .endSpec() .done()); client.deploymentConfigs().inNamespace("thisisatest").withName("nginx").scale(2, true); log("Created pods:", client.pods().inNamespace("thisisatest").list().getItems()); client.deploymentConfigs().inNamespace("thisisatest").withName("nginx").delete(); log("Pods:", client.pods().inNamespace("thisisatest").list().getItems()); log("Replication Controllers:", client.replicationControllers().inNamespace("thisisatest").list().getItems()); log("Done."); <START> }finally { <END> client.close(); } }</code><technical_language>is need explicitly close client in finally block try resources handles it</technical_language>

Target:
public static void main(String[] args) throws InterruptedException { Config config = new ConfigBuilder().build(); try (KubernetesClient kubernetesClient = new DefaultKubernetesClient(config)) { OpenShiftClient client = kubernetesClient.adapt(OpenShiftClient.class); ProjectRequest projectRequest = new ProjectRequestBuilder() .withNewMetadata() .withName("thisisatest") .addToLabels("project", "thisisatest") .endMetadata() .build(); log("Created project", client.projectrequests().create(projectRequest)); ServiceAccount fabric8 = new ServiceAccountBuilder().withNewMetadata().withName("fabric8").endMetadata().build(); client.serviceAccounts().inNamespace("thisisatest").createOrReplace(fabric8); log("Created deployment", client.deploymentConfigs().inNamespace("thisisatest").createOrReplaceWithNew() .withNewMetadata() .withName("nginx") .endMetadata() .withNewSpec() .withReplicas(1) .addNewTrigger() .withType("ConfigChange") .endTrigger() .addToSelector("app", "nginx") .withNewTemplate() .withNewMetadata() .addToLabels("app", "nginx") .endMetadata() .withNewSpec() .addNewContainer() .withName("nginx") .withImage("nginx") .addNewPort() .withContainerPort(80) .endPort() .endContainer() .endSpec() .endTemplate() .endSpec() .done()); client.deploymentConfigs().inNamespace("thisisatest").withName("nginx").scale(2, true); log("Created pods:", client.pods().inNamespace("thisisatest").list().getItems()); client.deploymentConfigs().inNamespace("thisisatest").withName("nginx").delete(); log("Pods:", client.pods().inNamespace("thisisatest").list().getItems()); log("Replication Controllers:", client.replicationControllers().inNamespace("thisisatest").list().getItems()); log("Done."); } }