Map<String, Service> servicesById; Service httpService = servicesById.get("http"); System.out.println("The status of service http is " + httpService.getStatus());
/** * Checks if the Service already has assigned ingress address. * * @param namespace The namespace. * @param name The route name. */ public boolean isIngressAddressReady(String namespace, String name) { ServiceResource<Service, DoneableService> resourceOp = operation().inNamespace(namespace).withName(name); Service resource = resourceOp.get(); if (resource != null && resource.getStatus() != null && resource.getStatus().getLoadBalancer() != null && resource.getStatus().getLoadBalancer().getIngress() != null && resource.getStatus().getLoadBalancer().getIngress().size() > 0) { if (resource.getStatus().getLoadBalancer().getIngress().get(0).getHostname() != null || resource.getStatus().getLoadBalancer().getIngress().get(0).getIp() != null) { return true; } } return false; }
/** * Adds the LoadBalancer Endpoint to the endpointList * * @param serviceName name of the service the endpoint belongs to * @param service service object instance * @param port port number * @param protocol whether http or https * @param namespace namespace of the service * @param labels labels of the service * @param endpointList endpointList which the endpoint has to be added to * @throws MalformedURLException if protocol unknown, therefore will not get thrown */ private void addLoadBalancerEndpoint(String serviceName, Service service, int port, String protocol, String namespace, String labels, List<Endpoint> endpointList) throws MalformedURLException { List<LoadBalancerIngress> loadBalancerIngresses = service.getStatus().getLoadBalancer().getIngress(); if (!loadBalancerIngresses.isEmpty()) { for (LoadBalancerIngress loadBalancerIngress : loadBalancerIngresses) { String hostname = loadBalancerIngress.getHostname(); String host = (hostname == null || "".equals(hostname)) ? loadBalancerIngress.getIp() : hostname; URL url = new URL(protocol, host, port, ""); endpointList.add(constructEndpoint(serviceName, namespace, protocol, LOAD_BALANCER, url, labels)); } } else { log.debug("Service:{} Namespace:{} Port:{}/{} has no loadBalancer ingresses available.", serviceName, namespace, port, protocol); } }
/** * Adds the LoadBalancer Endpoint to the endpointList * * @param serviceName name of the service the endpoint belongs to * @param service service object instance * @param port port number * @param protocol whether http or https * @param namespace namespace of the service * @param labels labels of the service * @param endpointList endpointList which the endpoint has to be added to * @throws MalformedURLException if protocol unknown, therefore will not get thrown */ private void addLoadBalancerEndpoint(String serviceName, Service service, int port, String protocol, String namespace, String labels, List<Endpoint> endpointList) throws MalformedURLException { List<LoadBalancerIngress> loadBalancerIngresses = service.getStatus().getLoadBalancer().getIngress(); if (!loadBalancerIngresses.isEmpty()) { for (LoadBalancerIngress loadBalancerIngress : loadBalancerIngresses) { String hostname = loadBalancerIngress.getHostname(); String host = (hostname == null || "".equals(hostname)) ? loadBalancerIngress.getIp() : hostname; URL url = new URL(protocol, host, port, ""); endpointList.add(constructEndpoint(serviceName, namespace, protocol, LOAD_BALANCER, url, labels)); } } else { log.debug("Service:{} Namespace:{} Port:{}/{} has no loadBalancer ingresses available.", serviceName, namespace, port, protocol); } }
int maxWait = properties.getMinutesToWaitForLoadBalancer() * 6; // we check 6 times per minute while (tries++ < maxWait) { if (svc.getStatus() != null && svc.getStatus().getLoadBalancer() != null && svc.getStatus().getLoadBalancer().getIngress() != null && svc.getStatus() .getLoadBalancer().getIngress().isEmpty()) { if (tries % 6 == 0) { svc.getStatus().getLoadBalancer().getIngress().toString()));
result.put("service.name", service.getMetadata().getName()); if ("LoadBalancer".equals(service.getSpec().getType())) { if (service.getStatus() != null && service.getStatus().getLoadBalancer() != null && service.getStatus().getLoadBalancer().getIngress() != null && !service.getStatus() .getLoadBalancer().getIngress().isEmpty()) { String externalIp = service.getStatus().getLoadBalancer().getIngress().get(0).getIp(); result.put("service.external.ip", externalIp); List<ServicePort> ports = service.getSpec().getPorts();
@Override public Boolean call() { Service svc = client.services().inNamespace(namespace).withName(serviceName).get(); if (svc == null || svc.getStatus() == null) { return false; } Endpoints endpoints = client.endpoints().inNamespace(namespace).withName(serviceName).get(); if (endpoints == null || endpoints.getSubsets().isEmpty()) { return false; } for (EndpointSubset subset : endpoints.getSubsets()) { if (subset.getNotReadyAddresses().size() > 0) { return false; } } return true; }
public ServiceBuilder( ServiceFluent<?> fluent , Service instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ServiceBuilder( Service instance ){
public ServiceBuilder(Service instance,Boolean validationEnabled){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; }
public ServiceBuilder(ServiceFluent<?> fluent,Service instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; } public ServiceBuilder(Service instance){
public ServiceFluentImpl(Service instance){ this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ServiceBuilder( ServiceFluent<?> fluent , Service instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ServiceBuilder( Service instance ){
public ServiceBuilder( Service instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ServiceBuilder( Service instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
ServiceStatus status = srv.getStatus(); if (status != null) { LoadBalancerStatus loadBalancerStatus = status.getLoadBalancer();
Service service = serviceResource.get(); if (service != null) { ServiceStatus status = service.getStatus(); } else { kube.services().inNamespace(namespace).createNew()