use of io.fabric8.kubernetes.api.model.Endpoints in project camel by apache.
the class KubernetesClientServiceDiscovery method getServices.
@Override
public List<ServiceDefinition> getServices(String name) {
LOG.debug("Discovering endpoints from namespace: {} with name: {}", getNamespace(), name);
Endpoints endpoints = client.endpoints().inNamespace(getNamespace()).withName(name).get();
List<ServiceDefinition> result = new ArrayList<>();
if (endpoints != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Found {} endpoints in namespace: {} for name: {} and portName: {}", endpoints.getSubsets().size(), getNamespace(), name, getPortName());
}
for (EndpointSubset subset : endpoints.getSubsets()) {
if (subset.getPorts().size() == 1) {
addServers(name, result, subset.getPorts().get(FIRST), subset);
} else {
final List<EndpointPort> ports = subset.getPorts();
final int portSize = ports.size();
EndpointPort port;
for (int p = 0; p < portSize; p++) {
port = ports.get(p);
if (ObjectHelper.isEmpty(getPortName()) || getPortName().endsWith(port.getName())) {
addServers(name, result, port, subset);
}
}
}
}
}
return result;
}
Aggregations