private void deleteSeleniumPods() { logger.info("About to clean up any left over docker-selenium pods created by Zalenium"); client.pods().withLabels(createdByZaleniumMap).delete(); }
@Bean public KubernetesClientServicesFunction servicesFunction(KubernetesDiscoveryProperties properties) { if (properties.getServiceLabels().isEmpty()) { return KubernetesClient::services; } return (client) -> client.services().withLabels(properties.getServiceLabels()); }
PodList list = client.pods().withLabels(createdByZaleniumMap).list();
client.secrets().withLabels(config.getLabels()).list().getItems() .forEach(s -> putAll(s, result));
if (StringUtils.isEmpty(namespace)) { client.secrets() .withLabels(config.getLabels()) .list() .getItems()
@Override public void deleteAddressSpaces(String namespace) { Map<String, String> labels = new LinkedHashMap<>(); labels.put(LabelKeys.TYPE, "address-space"); labels.put(LabelKeys.NAMESPACE, namespace); client.configMaps().withLabels(labels).delete(); }
@Override public void deleteAddresses(String namespace) { Map<String, String> labels = new LinkedHashMap<>(); labels.put(LabelKeys.TYPE, "address-config"); labels.put(LabelKeys.INFRA_UUID, infraUuid); labels.put(LabelKeys.NAMESPACE, namespace); client.configMaps().withLabels(labels).delete(); }
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)); } } }
public List<Pod> listPods(Map<String, String> labelSelector, Map<String, String> annotationSelector) { return client.pods().withLabels(labelSelector).list().getItems().stream().filter(pod -> { for (Map.Entry<String, String> entry : annotationSelector.entrySet()) { return pod.getMetadata().getAnnotations() != null && pod.getMetadata().getAnnotations().get(entry.getKey()) != null && pod.getMetadata().getAnnotations().get(entry.getKey()).equals(entry.getValue()); } return true; }).collect(Collectors.toList()); }
@Override public List<Topic> get() { log.debug("Scanning {} for ConfigMaps.", kubeClient().getNamespace()); ConfigMapList list = kubeClient().configMaps().withLabels(labels()).list(); log.debug("Scanned {}", list); return list.getItems().stream().map(this::topicBuilder).filter(Objects::nonNull) .collect(toList()); }
private void deleteReplicationController(Map<String, String> labels) { FilterWatchListDeletable<ReplicationController, ReplicationControllerList, Boolean, Watch, Watcher<ReplicationController>> replicationControllersToDelete = client.replicationControllers() .withLabels(labels); if (replicationControllersToDelete != null && replicationControllersToDelete.list().getItems() != null) { boolean replicationControllersDeleted = replicationControllersToDelete.delete(); logger.debug(String.format("ReplicationController deleted for: %s - %b", labels, replicationControllersDeleted)); } }
private Set<AddressSpace> listAddressSpacesMatching(Map<String, String> labels) { Set<AddressSpace> instances = new LinkedHashSet<>(); ConfigMapList list = client.configMaps().withLabels(labels).list(); for (ConfigMap map : list.getItems()) { instances.add(getAddressSpaceFromConfig(map)); } return instances; }
private void deleteService(Map<String, String> labels) { FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>> servicesToDelete = client.services().withLabels(labels); if (servicesToDelete != null && servicesToDelete.list().getItems() != null) { boolean servicesDeleted = servicesToDelete.delete(); logger.debug(String.format("Service deleted for: %s - %b", labels, servicesDeleted)); } }
private void deletePod(Map<String, String> labels) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podsToDelete = client.pods() .withLabels(labels); if (podsToDelete != null && podsToDelete.list().getItems() != null) { boolean podsDeleted = podsToDelete.delete(); logger.debug(String.format("Pod deleted for: %s - %b", labels, podsDeleted)); } }
private void deleteStatefulSet(Map<String, String> labels) { FilterWatchListDeletable<StatefulSet, StatefulSetList, Boolean, Watch, Watcher<StatefulSet>> ssToDelete = client.apps().statefulSets().withLabels(labels); if (ssToDelete != null && ssToDelete.list().getItems() != null) { boolean ssDeleted = ssToDelete.delete(); logger.debug(String.format("StatefulSet deleted for: %s - %b", labels, ssDeleted)); } }
@Override public List<DeploymentConfig> getDeploymentsByLabel(Map<String, String> labels) { return openShiftClient.deploymentConfigs().withLabels(labels).list().getItems(); }
private void deleteDeployment(Map<String, String> labels) { FilterWatchListDeletable<Deployment, DeploymentList, Boolean, Watch, Watcher<Deployment>> deploymentsToDelete = client.apps().deployments().withLabels(labels); if (deploymentsToDelete != null && deploymentsToDelete.list().getItems() != null) { boolean deploymentsDeleted = deploymentsToDelete.delete(); logger.debug(String.format("Deployment deleted for: %s - %b", labels, deploymentsDeleted)); } }
@Override public Watch watch(io.fabric8.kubernetes.client.Watcher<io.fabric8.kubernetes.api.model.Pod> watcher, ListOptions listOptions) { return client.pods().withLabels(labelFilter).withResourceVersion(listOptions.getResourceVersion()).watch(watcher); } }
@Override public void watch() { log.debug("Watcihing {} for {} changes", resourceKind(), kubeClient().getNamespace()); getClient().withLabels(labels()).watch(this); }
@Override public void watch() { log.debug("Watcihing {} for ConfigMap changes", kubeClient().getNamespace()); watch = kubeClient().configMaps().withLabels(labels()).watch(this); }