KubernetesConstants.KUBERNETES_SERVICE_LABELS, Map.class); Service serviceCreating = new ServiceBuilder() .withNewMetadata().withName(serviceName).withLabels(labels) .endMetadata().withSpec(serviceSpec).build(); service = getEndpoint().getKubernetesClient().services()
.withLabels(idMap).withAnnotations(annotations).addToLabels(SPRING_MARKER_KEY, SPRING_MARKER_VALUE) .endMetadata().withSpec(spec.build()).done();
.withName(service.getName()) .withAnnotations(getAnnotations(service)) .withLabels(getLabels(service)) .endMetadata();
.withName(serviceName) .withNamespace(namespace) .withLabels(serviceLabels) .endMetadata() .withNewSpec()
.withName(serviceName) .withNamespace(namespace) .withLabels(serviceLabels) .endMetadata() .withNewSpec()
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(); }
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(); }
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; }
protected Service createService(String name, String type, List<ServicePort> ports, Map<String, String> labels, Map<String, String> selector, Map<String, String> annotations) { Service service = new ServiceBuilder() .withNewMetadata() .withName(name) .withLabels(labels) .withNamespace(namespace) .withAnnotations(annotations) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withType(type) .withSelector(selector) .withPorts(ports) .endSpec() .build(); log.trace("Created service {}", service); return service; }