public synchronized static void shutdownOpenShiftClient() { if (openShiftClient != null) { openShiftClient.close(); openShiftClient = null; } }
public void dispose() { delegate.close(); }
public static void main(String[] args) throws InterruptedException { try (OpenShiftClient client = new DefaultOpenShiftClient()) { SecurityContextConstraints scc = new SecurityContextConstraintsBuilder() .withNewMetadata().withName("scc").endMetadata() .withAllowPrivilegedContainer(true) .withNewRunAsUser() .withType("RunAsAny") .endRunAsUser() .withNewSeLinuxContext() .withType("RunAsAny") .endSeLinuxContext() .withNewFsGroup() .withType("RunAsAny") .endFsGroup() .withNewSupplementalGroups() .withType("RunAsAny") .endSupplementalGroups() .addToUsers("admin") .addToGroups("admin-group") .build(); log("Created SecurityContextConstraints", client.securityContextConstraints().create(scc)); client.close(); } catch (KubernetesClientException e) { logger.error(e.getMessage(), e); } }
public static void main(String[] args) throws InterruptedException { String namespace = "myproject"; String master = "CLUSTER_URL"; Config config = new ConfigBuilder().withMasterUrl(master).build(); OpenShiftClient client = new DefaultOpenShiftClient(config); try { ImageStreamTag istag = new ImageStreamTagBuilder().withNewMetadata().withName("bar1:1.0.12").endMetadata() .withNewTag().withNewFrom().withKind("DockerImage").withName("openshift/wildfly-81-centos7:latest").endFrom().endTag() .build(); log("Created istag", client.imageStreamTags().inNamespace(namespace).create(istag)); Thread.sleep(30000); }finally { log("ImageStreamTags are :"); log(client.imageStreamTags().inNamespace(namespace).withName("bar1:1.0.12").get().toString()); log("ImageStreamTags using list are :"); log(client.imageStreamTags().list().getItems().get(0).toString()); log("Deleted istag",client.imageStreamTags().withName("bar1:1.0.12").delete()); client.close(); } }
client.close();
osClient.close();
}finally { client.close();
}finally { client.namespaces().withName("thisisatest").delete(); client.close();