/** @return the lowest container port */
  private ContainerPort getFirstPort(List<ContainerPort> ports) {
    if (ports.isEmpty()) {
      return null;
    }

    final Iterator<ContainerPort> portsIterator = ports.iterator();

    ContainerPort firstPort = portsIterator.next();
    while (portsIterator.hasNext()) {
      final ContainerPort port = portsIterator.next();
      if (port.getContainerPort() < firstPort.getContainerPort()) {
        firstPort = port;
      }
    }

    return firstPort;
  }
 private Service generateService(
     String namespace, ContainerPort port, Map<String, String> labels) {
   final ServicePort servicePort =
       newDto(ServicePort.class)
           .withPort(port.getContainerPort())
           .withTargetPort(port.getContainerPort())
           .withProtocol(port.getProtocol());
   return newDto(Service.class)
       .withApiVersion(API_VERSION)
       .withKind("Service")
       .withMetadata(
           newDto(ObjectMeta.class)
               .withName(osAppName)
               .withLabels(labels)
               .withNamespace(namespace))
       .withSpec(
           newDto(ServiceSpec.class)
               .withPorts(newArrayList(servicePort))
               .withSelector(singletonMap("deploymentconfig", osAppName)));
 }