/** * Generates service for pod. This service is used for exposing it externally. * * @param pod Number of the pod for which this service should be generated * @return The generated Service */ public Service generateExternalService(int pod) { if (isExposed()) { String perPodServiceName = externalServiceName(cluster, pod); List<ServicePort> ports = new ArrayList<>(1); ports.add(createServicePort(EXTERNAL_PORT_NAME, EXTERNAL_PORT, EXTERNAL_PORT, "TCP")); Labels selector = Labels.fromMap(getSelectorLabels()).withStatefulSetPod(kafkaPodName(cluster, pod)); return createService(perPodServiceName, getExternalServiceType(), ports, getLabelsWithName(perPodServiceName, templatePerPodServiceLabels), selector.toMap(), mergeAnnotations(Collections.EMPTY_MAP, templatePerPodServiceAnnotations)); } return null; }