/** * Checks if there is an endpoint for the service available. * @param s The target service. * @return Returns true if a connection to at least one of the endpoints is possible. */ private boolean isEndpointAvailable(Service s) { String serviceStatus = null; boolean result = false; for (String endpoit : kubernetesClient.endpointsForService(s.getId(), s.getNamespace()).getEndpoints()) { String addr = endpoit.substring(0, endpoit.indexOf(":")); Integer port = Integer.parseInt(endpoit.substring(endpoit.indexOf(":") + 1)); try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(addr, port), configuration.getServiceConnectionTimeout()); serviceStatus = "Service: " + s.getId() + " is ready. Provider:"+ addr+"."; return true; } catch (Exception e) { serviceStatus = "Service: " + s.getId() + " is not ready! Error: " + e.getMessage(); } finally { session.getLogger().warn(serviceStatus); } } return result; }
public AppServiceSummaryDTO(Service service) { this.id = KubernetesHelper.getId(service); this.name = KubernetesHelper.getName(service); this.namespace = service.getNamespace(); this.portalIP = KubernetesHelper.getPortalIP(service); this.port = KubernetesHelper.getPort(service); this.labels = service.getLabels(); }
String appPath = getAppPath(getId(service)); if (appPath != null) { AppViewDetails dto = snapshot.getOrCreateAppView(appPath, service.getNamespace()); dto.addService(service);