public List<String> getServices(Predicate<Service> filter) { return kubernetesClientServicesFunction.apply(client).list() .getItems() .stream() .filter(filter) .map(s -> s.getMetadata().getName()) .collect(Collectors.toList()); }
PodList list = client.pods().withLabels(createdByZaleniumMap).list();
@Override protected PodList listSelectedPods(ReplicationController obj) { return pods().inNamespace(namespace).withLabels(obj.getSpec().getSelector()).list(); }
private void deleteBuilds() { if (getName() == null) { return; } String buildConfigLabelValue = getName().substring(0, Math.min(getName().length(), 63)); BuildList matchingBuilds = new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(namespace).withLabel(BUILD_CONFIG_LABEL, buildConfigLabelValue).list(); if (matchingBuilds.getItems() != null) { for (Build matchingBuild : matchingBuilds.getItems()) { if (matchingBuild.getMetadata() != null && matchingBuild.getMetadata().getAnnotations() != null && getName().equals(matchingBuild.getMetadata().getAnnotations().get(BUILD_CONFIG_ANNOTATION))) { new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(matchingBuild.getMetadata().getNamespace()).withName(matchingBuild.getMetadata().getName()).delete(); } } } }
@Override protected PodList listSelectedPods(StatefulSet obj) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podLister = pods().inNamespace(namespace); if (obj.getSpec().getSelector().getMatchLabels() != null) { podLister.withLabels(obj.getSpec().getSelector().getMatchLabels()); } if (obj.getSpec().getSelector().getMatchExpressions() != null) { for (LabelSelectorRequirement req : obj.getSpec().getSelector().getMatchExpressions()) { switch (req.getOperator()) { case "In": podLister.withLabelIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "NotIn": podLister.withLabelNotIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "DoesNotExist": podLister.withoutLabel(req.getKey()); break; case "Exists": podLister.withLabel(req.getKey()); break; } } } return podLister.list(); }
@Override protected PodList listSelectedPods(ReplicaSet obj) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podLister = pods().inNamespace(namespace); if (obj.getSpec().getSelector().getMatchLabels() != null) { podLister.withLabels(obj.getSpec().getSelector().getMatchLabels()); } if (obj.getSpec().getSelector().getMatchExpressions() != null) { for (LabelSelectorRequirement req : obj.getSpec().getSelector().getMatchExpressions()) { switch (req.getOperator()) { case "In": podLister.withLabelIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "NotIn": podLister.withLabelNotIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "DoesNotExist": podLister.withoutLabel(req.getKey()); break; case "Exists": podLister.withLabel(req.getKey()); break; } } } return podLister.list(); }
public Collection<Instance> getInstanceList() throws Exception { List<Instance> result = new ArrayList<Instance>(); for (Endpoints endpoint : client.endpoints().withLabels(labels).list().getItems()) { try { result.addAll(toInstances(endpoint)); } catch (Throwable t) { LOGGER.error("Error processing endpoint", t); } } return result; }
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(); }
private void deletePvc(Map<String, String> labels) { FilterWatchListDeletable<PersistentVolumeClaim, PersistentVolumeClaimList, Boolean, Watch, Watcher<PersistentVolumeClaim>> pvcsToDelete = client.persistentVolumeClaims() .withLabels(labels); if (pvcsToDelete != null && pvcsToDelete.list().getItems() != null) { boolean pvcsDeleted = pvcsToDelete.delete(); logger.debug(String.format("PVC deleted for: %s - %b", labels, pvcsDeleted)); } } }
@Override public void listMaps(Handler<AsyncResult<List<KafkaTopic>>> handler) { vertx.executeBlocking(future -> { try { future.complete(operation().inNamespace(namespace).withLabels(resourcePredicate.labels()).list().getItems()); } catch (Exception e) { future.fail(e); } }, handler); }
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(); }
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(); }
log("Get namespace by label", client.namespaces().withLabel("this", "rocks").list()); log("Get RC by label", client.replicationControllers().withLabel("server", "nginx").list()); log("Get RC without label", client.replicationControllers().withoutLabel("server", "apache").list()); log("Get RC with label in", client.replicationControllers().withLabelIn("server", "nginx").list()); log("Get RC with label not in", client.replicationControllers().withLabelNotIn("server", "apache").list()); log("Get RC by label in namespace", client.replicationControllers().inNamespace("thisisatest").withLabel("server", "nginx").list());
@SuppressWarnings("unused") private ConfigMapList list(String namespace) { return client.configMaps() .inNamespace(client.getNamespace()) .withLabel(LabelKeys.TYPE, "address-space") .withLabel(LabelKeys.NAMESPACE, namespace) .list(); }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { KubernetesClient client = this.clientInstance.get(); Session session = sessionInstance.get(); Map<String, String> labels = getLabels(qualifiers); if( labels.isEmpty() ) { return client.services().inNamespace(session.getNamespace()).list(); } else { return client.services().inNamespace(session.getNamespace()).withLabels(labels).list(); } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { KubernetesClient client = this.clientInstance.get(); Session session = sessionInstance.get(); Map<String, String> labels = getLabels(qualifiers); if( labels.isEmpty() ) { return client.replicationControllers().inNamespace(session.getNamespace()).list(); } else { return client.replicationControllers().inNamespace(session.getNamespace()).withLabels(labels).list(); } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { KubernetesClient client = this.clientInstance.get(); Session session = sessionInstance.get(); Map<String, String> labels = getLabels(qualifiers); if( labels.isEmpty() ) { return client.pods().inNamespace(session.getNamespace()).list(); } else{ return client.pods().inNamespace(session.getNamespace()).withLabels(labels).list(); } } }