serviceSpecBuilder.withClusterIP("None");
private Service getDefaultService() { // No image config, no service if (!hasImageConfiguration()) { return null; } String serviceName = getConfig(Config.name, MavenUtil.createDefaultResourceName(getContext().getGav().getSanitizedArtifactId())); // Create service only for all images which are supposed to live in a single pod List<ServicePort> ports = extractPorts(getImages().get()); ServiceBuilder builder = new ServiceBuilder() .withNewMetadata() .withName(serviceName) .withLabels(extractLabels()) .endMetadata(); ServiceFluent.SpecNested<ServiceBuilder> specBuilder = builder.withNewSpec(); if (!ports.isEmpty()) { specBuilder.withPorts(ports); } else if (Configs.asBoolean(getConfig(Config.headless))) { specBuilder.withClusterIP("None"); } else { // No ports, no headless --> no service return null; } if (hasConfig(Config.type)) { specBuilder.withType(getConfig(Config.type)); } specBuilder.endSpec(); return builder.build(); }
protected Service createHeadlessService(List<ServicePort> ports, Map<String, String> annotations) { Service service = new ServiceBuilder() .withNewMetadata() .withName(headlessServiceName) .withLabels(getLabelsWithName(headlessServiceName, templateHeadlessServiceLabels)) .withNamespace(namespace) .withAnnotations(mergeAnnotations(annotations, templateHeadlessServiceAnnotations)) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withType("ClusterIP") .withClusterIP("None") .withSelector(getSelectorLabels()) .withPorts(ports) .endSpec() .build(); log.trace("Created headless service {}", service); return service; }
private Service getDefaultService() { // No image config, no service if (!hasImageConfiguration()) { return null; } // Create service only for all images which are supposed to live in a single pod List<ServicePort> ports = extractPorts(getImages()); ServiceBuilder builder = new ServiceBuilder() .withNewMetadata() .withName(getConfig(Config.name, MavenUtil.createDefaultResourceName(getProject()))) .withLabels(extractLabels()) .endMetadata(); ServiceFluent.SpecNested<ServiceBuilder> specBuilder = builder.withNewSpec(); if (!ports.isEmpty()) { specBuilder.withPorts(ports); } else if (Configs.asBoolean(getConfig(Config.headless))) { specBuilder.withClusterIP("None"); } else { // No ports, no headless --> no service return null; } if (hasConfig(Config.type)) { specBuilder.withType(getConfig(Config.type)); } specBuilder.endSpec(); return builder.build(); }
public void onTemplate(TemplateBuilder builder) { builder.addNewServiceObject() .withNewMetadata() .withName("elasticsearch-cluster") .endMetadata() .withNewSpec() .withClusterIP("None") .addNewPort() .withName("") .withProtocol("TCP") .withPort(9300) .withNewTargetPort(9300) .endPort() .addToSelector("component", "elasticsearch") .addToSelector("provider", "fabric8") .endSpec() .and() .build(); }
@Override public Service patch(Service item) { try { Service old = getMandatory(); return super.patch(new ServiceBuilder(item) .editSpec() .withClusterIP(old.getSpec().getClusterIP()) .endSpec() .build()); } catch (Exception e) { throw KubernetesClientException.launderThrowable(e); } }
@Override public Service replace(Service item) { try { Service old = getMandatory(); return super.replace(new ServiceBuilder(item) .editSpec() .withClusterIP(old.getSpec().getClusterIP()) .endSpec() .build()); } catch (Exception e) { throw KubernetesClientException.launderThrowable(e); } }
@Override public Service patch(Service item) { try { Service old = getMandatory(); return super.patch(new ServiceBuilder(item) .editSpec() .withClusterIP(old.getSpec().getClusterIP()) .endSpec() .build()); } catch (Exception e) { throw KubernetesClientException.launderThrowable(forOperationType("patch"), e); } }
@Override public Service replace(Service item) { try { Service old = getMandatory(); return super.replace(new ServiceBuilder(item) .editSpec() .withClusterIP(old.getSpec().getClusterIP()) .endSpec() .build()); } catch (Exception e) { throw KubernetesClientException.launderThrowable(forOperationType("replace"), e); } }