Refine search
@Bean @ConditionalOnMissingBean public KubernetesClient kubernetesClient(Config config) { return new DefaultKubernetesClient(config); }
@Override public NamespacedKubernetesClient inAnyNamespace() { return inNamespace(null); }
@Override public ExtensionsAPIGroupDSL extensions() { return adapt(ExtensionsAPIGroupClient.class); }
@Override public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> resourceList(KubernetesResourceList item) { return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), item, null, null, -1, false) { }; }
@Override public NamespacedKubernetesClient inNamespace(String namespace) { Config updated = new ConfigBuilder(getConfiguration()).withNamespace(namespace).build(); return new DefaultKubernetesClient(httpClient, updated); }
public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: podName [master] [namespace]"); return; } String podName = args[0]; String namespace = "default"; String master = "https://localhost:8443/"; if (args.length > 1) { master = args[1]; } if (args.length > 2) { namespace = args[2]; } System.out.println("Log of pod " + podName + " in " + namespace + " is:"); System.out.println("----------------------------------------------------------------"); Config config = new ConfigBuilder().withMasterUrl(master).build(); try (KubernetesClient client = new DefaultKubernetesClient(config); LogWatch watch = client.pods().inNamespace(namespace).withName(podName).tailingLines(10).watchLog(System.out)) { Thread.sleep(5 * 1000); } catch (Exception e) { logger.error(e.getMessage(), e); } } }
@Activate public void activate(Map<String, Object> properties) { final ConfigBuilder builder = new ConfigBuilder(); builder.withMasterUrl((String) properties.get(KUBERNETES_MASTER_SYSTEM_PROPERTY)); builder.withApiVersion((String) properties.get(KUBERNETES_API_VERSION_SYSTEM_PROPERTY)); delegate = new DefaultKubernetesClient(builder.build());
public NamespacedKubernetesClient createClient() { Config config = new ConfigBuilder() .withMasterUrl(url("/")) .withTrustCerts(true) .withTlsVersions(TLS_1_0) .withNamespace("test") .build(); return new DefaultKubernetesClient(config); }
Config config = new ConfigBuilder().build(); KubernetesClient kubernetesClient = new DefaultKubernetesClient(config); OpenShiftClient client = kubernetesClient.adapt(OpenShiftClient.class);
ConfigBuilder builder = new ConfigBuilder(); if (args.length > 1) { builder.withOauthToken(args[1]); Config config = builder.build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { if (namespace == null) { namespace = client.getNamespace(); List<HasMetadata> resources = client.load(new FileInputStream(fileName)).get(); if (resources.isEmpty()) { System.err.println("No resources loaded from file: " +fileName); Pod pod = (Pod) resource; System.out.println("Creating pod in namespace " + namespace); NonNamespaceOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = client.pods().inNamespace(namespace); Pod result = pods.create(pod); System.out.println("Created pod " + result.getMetadata().getName());
Config config = new ConfigBuilder().withMasterUrl(master).build(); try(final KubernetesClient client = new DefaultKubernetesClient(config)) { final String namespace = client.getNamespace(); cronJob1 = client.batch().cronjobs().inNamespace(namespace).create(cronJob1); log("Successfully created cronjob with name ", cronJob1.getMetadata().getName()); try (Watch watch = client.pods().inNamespace(namespace).withLabel("job-name").watch(new Watcher<Pod>() { @Override public void eventReceived(Action action, Pod aPod) {
public static void main(String[] args) { try (DefaultKubernetesClient kubernetesClient = new DefaultKubernetesClient(new ConfigBuilder() .withMasterUrl("cluster_url") .withUsername("my_username") .withPassword("my_password") .build())) { final OpenShiftClient openShiftClient = kubernetesClient.adapt(OpenShiftClient.class); logger.info(openShiftClient.projects().list().toString()); } } }
Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { try (Watch watch = client.replicationControllers().inNamespace("thisisatest").withResourceVersion("0").watch(new Watcher<ReplicationController>() { @Override public void eventReceived(Action action, ReplicationController resource) { log("Created namespace", client.namespaces().create(ns)); log("Get namespace by name", client.namespaces().withName("thisisatest").get()); log("Get namespace by label", client.namespaces().withLabel("this", "rocks").list());
public static void main(String[] args) { String master = "http://localhost:8080/"; if (args.length == 1) { master = args[0]; } io.fabric8.kubernetes.client.Config config = new io.fabric8.kubernetes.client.ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { StorageClassList storageClassList = client.storage().storageClasses().list(); logger.info(storageClassList.toString()); } catch (KubernetesClientException e) { logger.error(e.getMessage(), e); } } }
public static void main(String[] args) throws InterruptedException { Config config = new ConfigBuilder().build(); KubernetesClient client = new DefaultKubernetesClient(config); String namespace = null; if (args.length > 0) { namespace = args[0]; } if (namespace == null) { namespace = client.getNamespace(); } if (namespace == null) { namespace = "default"; } String name = "cheese"; try { Resource<ConfigMap, DoneableConfigMap> configMapResource = client.configMaps().inNamespace(namespace).withName(name); ConfigMap configMap = configMapResource.createOrReplace(new ConfigMapBuilder(). withNewMetadata().withName(name).endMetadata(). addToData("foo", "" + new Date()). addToData("bar", "beer"). build()); log("Upserted ConfigMap at " + configMap.getMetadata().getSelfLink() + " data " + configMap.getData()); } finally { client.close(); } }
public static void main(String[] args) throws InterruptedException { Config config = new ConfigBuilder().build(); KubernetesClient client = new DefaultKubernetesClient(config); log("Created namespace", client.namespaces().createOrReplace(ns)); client.serviceAccounts().inNamespace("thisisatest").createOrReplace(fabric8); for (int i = 0; i < 2; i++) { System.err.println("Iteration:" + (i+1)); deployment = client.apps().deployments().inNamespace("thisisatest").create(deployment); log("Created deployment", deployment);
public static void main(String args[]) throws InterruptedException { String master = "https://192.168.99.100:8443/"; if (args.length == 1) { master = args[0]; } log("Using master with url ", master); Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { final String namespace = "default"; PodDisruptionBudget podDisruptionBudget = new PodDisruptionBudgetBuilder() .withNewMetadata().withName("zk-pkb").endMetadata() .withNewSpec() .withMaxUnavailable(new IntOrString("1%")) .withNewSelector() .withMatchLabels(Collections.singletonMap("app", "zookeeper")) .endSelector() .endSpec() .build(); log("Current namespace is", namespace); client.policy().podDisruptionBudget().inNamespace(namespace).create(podDisruptionBudget); } catch (KubernetesClientException e) { log("Could not create resource", e.getMessage()); } }
public static void main(String[] args) throws InterruptedException { final CountDownLatch closeLatch = new CountDownLatch(1); Config config = new ConfigBuilder().build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { try (Watch watch = client.replicationControllers().inNamespace("default").withName("test").watch(new Watcher<ReplicationController>() { @Override public void eventReceived(Action action, ReplicationController resource) {
public static void main(String args[]) { String master = "https://localhost:8443/"; if (args.length == 1) { master = args[0]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); try(final KubernetesClient client = new DefaultKubernetesClient(config)) { VersionInfo versionInfo = client.getVersion(); log("Version details of this Kubernetes cluster :-"); log("Major : ", versionInfo.getMajor()); log("Minor : ", versionInfo.getMinor()); log("GitVersion : ", versionInfo.getGitVersion()); log("BuildDate : ", versionInfo.getBuildDate()); log("GitTreeState : ", versionInfo.getGitTreeState()); log("Platform : ", versionInfo.getPlatform()); log("GitVersion : ", versionInfo.getGitVersion()); log("GoVersion : ", versionInfo.getGoVersion()); log("GitCommit : ", versionInfo.getGitCommit()); } }
Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config)) { log("Creating persistent volume object"); PersistentVolume pv = new PersistentVolumeBuilder() .build(); client.persistentVolumes().create(pv); log("Successfully created Persistent Volume object"); } catch (KubernetesClientException e) {