public static void deleteServices(KubernetesClient client, Logger logger, Filter<Service> filter) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (Service service : client.getServices().getItems()) { if (filter.matches(service)) { try { logger.info("Deleting service:" + getId(service)); client.deleteService(getId(service)); } catch (Exception e) { e.printStackTrace(); } } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting services", errors); } }
public static void deletePods(KubernetesClient client, Logger logger, Filter<Pod> filter) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (Pod pod : client.getPods().getItems()) { if (filter.matches(pod)) { try { logger.info("Deleting pod:" + getId(pod)); client.deletePod(getId(pod)); } catch (Exception e) { errors.add(e); } } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting pods", errors); } }
public static void deleteReplicationControllers( KubernetesClient client, Logger logger, Filter<ReplicationController> filter) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (ReplicationController replicationController : client.getReplicationControllers().getItems()) { if (filter.matches(replicationController)) { try { logger.info("Deleting replication controller:" + getId(replicationController)); client.deleteReplicationController(getId(replicationController)); } catch (Exception e) { e.printStackTrace(); } } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting replication controllers", errors); } }