Search in sources :

Example 1 with IpFamily

use of io.strimzi.api.kafka.model.template.IpFamily in project strimzi by strimzi.

the class AbstractModel method createHeadlessService.

/**
 * Creates a headless service
 *
 * Uses Alpha annotation service.alpha.kubernetes.io/tolerate-unready-endpoints for older versions of Kubernetes still supported by Strimzi,
 * replaced by the publishNotReadyAddresses field in the spec,  annotation is ignored in later versions of Kubernetes
 */
protected Service createHeadlessService(List<ServicePort> ports) {
    Map<String, String> annotations = Collections.singletonMap("service.alpha.kubernetes.io/tolerate-unready-endpoints", "true");
    Service service = new ServiceBuilder().withNewMetadata().withName(headlessServiceName).withLabels(getLabelsWithStrimziName(name, templateHeadlessServiceLabels).toMap()).withNamespace(namespace).withAnnotations(Util.mergeLabelsOrAnnotations(annotations, templateHeadlessServiceAnnotations)).withOwnerReferences(createOwnerReference()).endMetadata().withNewSpec().withType("ClusterIP").withClusterIP("None").withSelector(getSelectorLabels().toMap()).withPorts(ports).withPublishNotReadyAddresses(true).endSpec().build();
    if (templateHeadlessServiceIpFamilyPolicy != null) {
        service.getSpec().setIpFamilyPolicy(templateHeadlessServiceIpFamilyPolicy.toValue());
    }
    if (templateHeadlessServiceIpFamilies != null && !templateHeadlessServiceIpFamilies.isEmpty()) {
        service.getSpec().setIpFamilies(templateHeadlessServiceIpFamilies.stream().map(IpFamily::toValue).collect(Collectors.toList()));
    }
    LOGGER.traceCr(reconciliation, "Created headless service {}", service);
    return service;
}
Also used : IpFamily(io.strimzi.api.kafka.model.template.IpFamily) Service(io.fabric8.kubernetes.api.model.Service) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Example 2 with IpFamily

use of io.strimzi.api.kafka.model.template.IpFamily in project strimzi-kafka-operator by strimzi.

the class AbstractModel method createHeadlessService.

/**
 * Creates a headless service
 *
 * Uses Alpha annotation service.alpha.kubernetes.io/tolerate-unready-endpoints for older versions of Kubernetes still supported by Strimzi,
 * replaced by the publishNotReadyAddresses field in the spec,  annotation is ignored in later versions of Kubernetes
 */
protected Service createHeadlessService(List<ServicePort> ports) {
    Map<String, String> annotations = Collections.singletonMap("service.alpha.kubernetes.io/tolerate-unready-endpoints", "true");
    Service service = new ServiceBuilder().withNewMetadata().withName(headlessServiceName).withLabels(getLabelsWithStrimziName(name, templateHeadlessServiceLabels).toMap()).withNamespace(namespace).withAnnotations(Util.mergeLabelsOrAnnotations(annotations, templateHeadlessServiceAnnotations)).withOwnerReferences(createOwnerReference()).endMetadata().withNewSpec().withType("ClusterIP").withClusterIP("None").withSelector(getSelectorLabels().toMap()).withPorts(ports).withPublishNotReadyAddresses(true).endSpec().build();
    if (templateHeadlessServiceIpFamilyPolicy != null) {
        service.getSpec().setIpFamilyPolicy(templateHeadlessServiceIpFamilyPolicy.toValue());
    }
    if (templateHeadlessServiceIpFamilies != null && !templateHeadlessServiceIpFamilies.isEmpty()) {
        service.getSpec().setIpFamilies(templateHeadlessServiceIpFamilies.stream().map(IpFamily::toValue).collect(Collectors.toList()));
    }
    LOGGER.traceCr(reconciliation, "Created headless service {}", service);
    return service;
}
Also used : IpFamily(io.strimzi.api.kafka.model.template.IpFamily) Service(io.fabric8.kubernetes.api.model.Service) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Example 3 with IpFamily

use of io.strimzi.api.kafka.model.template.IpFamily in project strimzi by strimzi.

the class AbstractModel method createService.

protected Service createService(String name, String type, List<ServicePort> ports, Labels labels, Labels selector, Map<String, String> annotations, IpFamilyPolicy ipFamilyPolicy, List<IpFamily> ipFamilies) {
    Service service = new ServiceBuilder().withNewMetadata().withName(name).withLabels(labels.toMap()).withNamespace(namespace).withAnnotations(annotations).withOwnerReferences(createOwnerReference()).endMetadata().withNewSpec().withType(type).withSelector(selector.toMap()).withPorts(ports).endSpec().build();
    if (ipFamilyPolicy != null) {
        service.getSpec().setIpFamilyPolicy(ipFamilyPolicy.toValue());
    }
    if (ipFamilies != null && !ipFamilies.isEmpty()) {
        service.getSpec().setIpFamilies(ipFamilies.stream().map(IpFamily::toValue).collect(Collectors.toList()));
    }
    LOGGER.traceCr(reconciliation, "Created service {}", service);
    return service;
}
Also used : IpFamily(io.strimzi.api.kafka.model.template.IpFamily) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Example 4 with IpFamily

use of io.strimzi.api.kafka.model.template.IpFamily in project strimzi-kafka-operator by strimzi.

the class AbstractModel method createService.

protected Service createService(String name, String type, List<ServicePort> ports, Labels labels, Labels selector, Map<String, String> annotations, IpFamilyPolicy ipFamilyPolicy, List<IpFamily> ipFamilies) {
    Service service = new ServiceBuilder().withNewMetadata().withName(name).withLabels(labels.toMap()).withNamespace(namespace).withAnnotations(annotations).withOwnerReferences(createOwnerReference()).endMetadata().withNewSpec().withType(type).withSelector(selector.toMap()).withPorts(ports).endSpec().build();
    if (ipFamilyPolicy != null) {
        service.getSpec().setIpFamilyPolicy(ipFamilyPolicy.toValue());
    }
    if (ipFamilies != null && !ipFamilies.isEmpty()) {
        service.getSpec().setIpFamilies(ipFamilies.stream().map(IpFamily::toValue).collect(Collectors.toList()));
    }
    LOGGER.traceCr(reconciliation, "Created service {}", service);
    return service;
}
Also used : IpFamily(io.strimzi.api.kafka.model.template.IpFamily) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Aggregations

Service (io.fabric8.kubernetes.api.model.Service)4 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)4 IpFamily (io.strimzi.api.kafka.model.template.IpFamily)4 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2