client.pods().withLabel("this", "works").list() );
log("Get RC by label", client.replicationControllers().withLabel("server", "nginx").list());
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(); KubernetesClient client = new DefaultKubernetesClient(config); try { log("Create namespace:", client.namespaces().create(new NamespaceBuilder().withNewMetadata().withName("thisisatest").endMetadata().build())); log("Deleted namespace:", client.namespaces().withName("test").delete()); log("Deleted testPod:", client.pods().inNamespace("thisisatest").withName("testpod").delete()); log("Deleted pod by label:", client.pods().withLabel("this", "works").delete()); } catch (KubernetesClientException e) { logger.error(e.getMessage(), e); } finally { client.namespaces().withName("thisisatest").delete(); client.close(); } }
private ConfigMapList getConfigMapList() { KubernetesClient client = kubernetesClient.get(); if( client != null ) { FilterWatchListDeletable<ConfigMap, ConfigMapList, Boolean, Watch, Watcher<ConfigMap>> configMapsSelector = client.configMaps().withLabel(pidLabel); for( String key : filters.keySet() ){ configMapsSelector.withLabelIn(key, filters.get(key).toArray(new String[filters.get(key).size()])); } return configMapsSelector.list(); } else { return null; } }
private void deletePod(String id) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podsToDelete = client.pods() .withLabel(SPRING_APP_KEY, id); if (podsToDelete != null && podsToDelete.list().getItems() != null) { logger.debug(String.format("Deleting Pod for task: %s", id)); boolean podsDeleted = podsToDelete.delete(); logger.debug(String.format("Pod deleted for: %s - %b", id, podsDeleted)); } }
protected PodList listPods() { return client.pods().withLabel(OpenShiftService.COMPONENT_LABEL, "integration").list(); }
public Watch watchPods(String uuid, Watcher<Pod> podWatcher) { return client.pods().withLabel("enmasse.io/infra", uuid).watch(podWatcher); }
private void deleteJob(String id) { FilterWatchListDeletable<Job, JobList, Boolean, Watch, Watcher<Job>> jobsToDelete = client.batch().jobs() .withLabel(SPRING_APP_KEY, id); if (jobsToDelete != null && jobsToDelete.list().getItems() != null) { logger.debug(String.format("Deleting Job for task: %s", id)); boolean jobDeleted = jobsToDelete.delete(); logger.debug(String.format("Job deleted for: %s - %b", id, jobDeleted)); } }
protected Optional<Build> getBuild(String integrationId, String version) { return client.builds() .withLabel(OpenShiftService.INTEGRATION_ID_LABEL, integrationId) .withLabel(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version) .list() .getItems().stream().findFirst(); }
protected Optional<ReplicationController> getReplicationController(String integrationId, String version) { return client.replicationControllers() .withLabel(OpenShiftService.INTEGRATION_ID_LABEL, integrationId) .withLabel(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version) .list().getItems().stream().findFirst(); }
@Override public ConfigMapList list(ListOptions listOptions) { return client.configMaps() .withLabel(LabelKeys.TYPE, "address-config") .withLabel(LabelKeys.INFRA_UUID, infraUuid) .list(); }
protected boolean checkBuildStatus(String name, String status){ String sName = openshiftName(name); return !openShiftClient.builds() .withLabel("openshift.io/build-config.name", sName) .withField("status", status) .list().getItems().isEmpty(); }
protected boolean checkBuildStatus(String name, String status){ String sName = Names.sanitize(name); return !openShiftClient.builds() .withLabel("openshift.io/build-config.name", sName) .withField("status", status) .list().getItems().isEmpty(); }
public void watch() { watch = kubeClient().extensions().deployments().withLabel("kafka-operator", "inject-credentials").watch(new DeploymentWatcher()); log.info("Watching Deployments for credential requests."); }
private Pod getPod(String jobName) { List<Pod> pods = client.pods().withLabel(SPRING_APP_KEY, jobName).list().getItems(); for (Pod pod : pods) { if (jobName.equals((pod.getMetadata().getName()))) { return pod; } } return null; } }
protected PodList getDeploymentPodList(String integrationId, String version) { return client.pods() .withLabel(OpenShiftService.COMPONENT_LABEL, "integration") .withLabel(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version) .withLabel(OpenShiftService.INTEGRATION_ID_LABEL, integrationId).list(); }
@Override public List<Pod> listRouters() { return client.pods().withLabel(LabelKeys.CAPABILITY, "router").withLabel(LabelKeys.INFRA_UUID, infraUuid).list().getItems(); }
private Job getJob(String jobName) { List<Job> jobs = client.batch().jobs().withLabel(SPRING_APP_KEY, jobName).list().getItems(); for (Job job : jobs) { if (jobName.equals(job.getMetadata().getName())) { return job; } } return null; }
@Override public List<Pod> listBrokers(String clusterId) { return client.pods().withLabel(LabelKeys.ROLE, "broker").withLabel(LabelKeys.NAME, clusterId).withLabel(LabelKeys.INFRA_UUID, infraUuid).list().getItems(); }
@Override public io.fabric8.kubernetes.client.Watch watch(io.fabric8.kubernetes.client.Watcher<ConfigMap> watcher, ListOptions listOptions) { RequestConfig requestConfig = new RequestConfigBuilder() .withRequestTimeout(listOptions.getTimeoutSeconds()) .build(); return client.withRequestConfig(requestConfig).call(c -> c.configMaps() .withLabel(LabelKeys.TYPE, "address-config") .withLabel(LabelKeys.INFRA_UUID, infraUuid) .withResourceVersion(listOptions.getResourceVersion()) .watch(watcher)); } }