use of io.fabric8.maven.core.config.ServiceConfig in project fabric8-maven-plugin by fabric8io.
the class ServiceHandler method getServices.
public List<Service> getServices(List<ServiceConfig> services) {
ArrayList<Service> ret = new ArrayList<>();
for (ServiceConfig service : services) {
ServiceBuilder serviceBuilder = new ServiceBuilder().withNewMetadata().withName(service.getName()).withAnnotations(getAnnotations(service)).withLabels(getLabels(service)).endMetadata();
ServiceFluent.SpecNested<ServiceBuilder> serviceSpecBuilder = serviceBuilder.withNewSpec();
List<ServicePort> servicePorts = new ArrayList<>();
for (ServiceConfig.Port port : service.getPorts()) {
ServicePort servicePort = new ServicePortBuilder().withName(port.getName()).withProtocol(port.getProtocol() != null ? port.getProtocol().name() : "TCP").withTargetPort(new IntOrString(port.getTargetPort())).withPort(port.getPort()).withNodePort(port.getNodePort()).build();
servicePorts.add(servicePort);
}
if (!servicePorts.isEmpty()) {
serviceSpecBuilder.withPorts(servicePorts);
}
if (service.isHeadless()) {
serviceSpecBuilder.withClusterIP("None");
}
if (!Strings.isNullOrBlank(service.getType())) {
serviceSpecBuilder.withType(service.getType());
}
serviceSpecBuilder.endSpec();
if (service.isHeadless() || !servicePorts.isEmpty()) {
ret.add(serviceBuilder.build());
}
}
return ret;
}
use of io.fabric8.maven.core.config.ServiceConfig in project fabric8-maven-plugin by fabric8io.
the class ResourceMojo method addServices.
private void addServices(KubernetesListBuilder builder, List<ServiceConfig> serviceConfig) {
if (serviceConfig != null) {
ServiceHandler serviceHandler = handlerHub.getServiceHandler();
builder.addToServiceItems(toArray(serviceHandler.getServices(serviceConfig)));
}
}
Aggregations