Пример #1
0
 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);
   }
 }
Пример #2
0
  @Override
  public void deleteService(String serviceId) throws KubernetesClientException {

    try {
      if (log.isDebugEnabled()) {
        log.debug(String.format("Deleting kubernetes service: [service-id] %s", serviceId));
      }

      kubernetesClient.deleteService(serviceId);

      if (log.isDebugEnabled()) {
        log.debug(
            String.format("Kubernetes service deleted successfully: [service-id] %s", serviceId));
      }
    } catch (Exception e) {
      String msg = String.format("Could not delete kubernetes service: [service-id] %s", serviceId);
      log.error(msg, e);
      throw new KubernetesClientException(msg, e);
    }
  }