use of io.fabric8.kubernetes.api.model.ServicePort in project che by eclipse.
the class OpenShiftConnector method getCheServicePorts.
private Map<String, List<PortBinding>> getCheServicePorts(Service service) {
Map<String, List<PortBinding>> networkSettingsPorts = new HashMap<>();
List<ServicePort> servicePorts = service.getSpec().getPorts();
LOG.info("Retrieving {} ports exposed by service {}", servicePorts.size(), service.getMetadata().getName());
for (ServicePort servicePort : servicePorts) {
String protocol = servicePort.getProtocol();
String targetPort = String.valueOf(servicePort.getTargetPort().getIntVal());
String nodePort = String.valueOf(servicePort.getNodePort());
String portName = servicePort.getName();
LOG.info("Port: {}{}{} ({})", targetPort, DOCKER_PROTOCOL_PORT_DELIMITER, protocol, portName);
networkSettingsPorts.put(targetPort + DOCKER_PROTOCOL_PORT_DELIMITER + protocol.toLowerCase(), Collections.singletonList(new PortBinding().withHostIp(CHE_DEFAULT_EXTERNAL_ADDRESS).withHostPort(nodePort)));
}
return networkSettingsPorts;
}
Aggregations