Skip to content

Commit ac854a7

Browse files
KyriosGN0see-quick
authored andcommitted
add option to use targetPortName in create service port function (strimzi#11510)
Signed-off-by: AvivGuiser <[email protected]>
1 parent 62b1d4d commit ac854a7

File tree

9 files changed

+47
-47
lines changed

9 files changed

+47
-47
lines changed

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public Service generateService() {
303303
labels,
304304
ownerReference,
305305
templateService,
306-
List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT, "TCP"))
306+
List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT_NAME, "TCP"))
307307
);
308308
}
309309

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaBridgeCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public Service generateService() {
234234
labels,
235235
ownerReference,
236236
templateService,
237-
List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, port, port, "TCP")),
237+
List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, port, REST_API_PORT_NAME, "TCP")),
238238
labels.strimziSelectorLabels(),
239239
ModelUtils.getCustomLabelsOrAnnotations(CO_ENV_VAR_CUSTOM_SERVICE_LABELS),
240240
Util.mergeLabelsOrAnnotations(getDiscoveryAnnotation(port), ModelUtils.getCustomLabelsOrAnnotations(CO_ENV_VAR_CUSTOM_SERVICE_ANNOTATIONS))

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ private List<ServicePort> getServicePorts() {
650650
List<GenericKafkaListener> internalListeners = ListenersUtils.internalListeners(listeners);
651651

652652
List<ServicePort> ports = new ArrayList<>(internalListeners.size() + 1);
653-
ports.add(ServiceUtils.createServicePort(REPLICATION_PORT_NAME, REPLICATION_PORT, REPLICATION_PORT, "TCP"));
653+
ports.add(ServiceUtils.createServicePort(REPLICATION_PORT_NAME, REPLICATION_PORT, REPLICATION_PORT_NAME, "TCP"));
654654

655655
for (GenericKafkaListener listener : internalListeners) {
656-
ports.add(ServiceUtils.createServicePort(ListenersUtils.backwardsCompatiblePortName(listener), listener.getPort(), listener.getPort(), "TCP"));
656+
ports.add(ServiceUtils.createServicePort(ListenersUtils.backwardsCompatiblePortName(listener), listener.getPort(), ListenersUtils.backwardsCompatiblePortName(listener), "TCP"));
657657
}
658658

659659
return ports;
@@ -669,12 +669,12 @@ private List<ServicePort> getHeadlessServicePorts() {
669669
List<GenericKafkaListener> internalListeners = ListenersUtils.internalListeners(listeners);
670670

671671
List<ServicePort> ports = new ArrayList<>(internalListeners.size() + 3);
672-
ports.add(ServiceUtils.createServicePort(CONTROLPLANE_PORT_NAME, CONTROLPLANE_PORT, CONTROLPLANE_PORT, "TCP"));
673-
ports.add(ServiceUtils.createServicePort(REPLICATION_PORT_NAME, REPLICATION_PORT, REPLICATION_PORT, "TCP"));
674-
ports.add(ServiceUtils.createServicePort(KAFKA_AGENT_PORT_NAME, KAFKA_AGENT_PORT, KAFKA_AGENT_PORT, "TCP"));
672+
ports.add(ServiceUtils.createServicePort(CONTROLPLANE_PORT_NAME, CONTROLPLANE_PORT, CONTROLPLANE_PORT_NAME, "TCP"));
673+
ports.add(ServiceUtils.createServicePort(REPLICATION_PORT_NAME, REPLICATION_PORT, REPLICATION_PORT_NAME, "TCP"));
674+
ports.add(ServiceUtils.createServicePort(KAFKA_AGENT_PORT_NAME, KAFKA_AGENT_PORT, KAFKA_AGENT_PORT_NAME, "TCP"));
675675

676676
for (GenericKafkaListener listener : internalListeners) {
677-
ports.add(ServiceUtils.createServicePort(ListenersUtils.backwardsCompatiblePortName(listener), listener.getPort(), listener.getPort(), "TCP"));
677+
ports.add(ServiceUtils.createServicePort(ListenersUtils.backwardsCompatiblePortName(listener), listener.getPort(), ListenersUtils.backwardsCompatiblePortName(listener), "TCP"));
678678
}
679679

680680
ports.addAll(jmx.servicePorts());
@@ -747,7 +747,7 @@ public List<Service> generateExternalBootstrapServices() {
747747
List<ServicePort> ports = Collections.singletonList(
748748
ServiceUtils.createServicePort(ListenersUtils.backwardsCompatiblePortName(listener),
749749
listener.getPort(),
750-
listener.getPort(),
750+
ListenersUtils.backwardsCompatiblePortName(listener),
751751
ListenersUtils.bootstrapNodePort(listener),
752752
"TCP")
753753
);
@@ -838,7 +838,7 @@ public List<Service> generatePerPodServices() {
838838
ServiceUtils.createServicePort(
839839
ListenersUtils.backwardsCompatiblePortName(listener),
840840
listener.getPort(),
841-
listener.getPort(),
841+
ListenersUtils.backwardsCompatiblePortName(listener),
842842
ListenersUtils.brokerNodePort(listener, node.nodeId()),
843843
"TCP")
844844
);

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaConnectCluster.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public String getServiceName() {
346346
*/
347347
public Service generateService() {
348348
List<ServicePort> ports = new ArrayList<>(1);
349-
ports.add(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT, "TCP"));
349+
ports.add(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT_NAME, "TCP"));
350350

351351
ports.addAll(jmx.servicePorts());
352352

@@ -366,7 +366,7 @@ public Service generateService() {
366366
* @return The generated Service
367367
*/
368368
public Service generateHeadlessService() {
369-
List<ServicePort> ports = List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT, "TCP"));
369+
List<ServicePort> ports = List.of(ServiceUtils.createServicePort(REST_API_PORT_NAME, REST_API_PORT, REST_API_PORT_NAME, "TCP"));
370370

371371
return ServiceUtils.createHeadlessService(
372372
componentName,

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/ServiceUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,32 +219,32 @@ private static List<IpFamily> ipFamilies(InternalServiceTemplate template) {
219219
*
220220
* @param name Name of the port
221221
* @param port The port on the service which can be accessed by clients
222-
* @param targetPort The port on the container / Pod where the connections will be routed
222+
* @param targetPortName the name of the target port on the container / Pod where the connections will be routed
223223
* @param protocol Protocol used by this port
224224
*
225225
* @return Created port
226226
*/
227-
public static ServicePort createServicePort(String name, int port, int targetPort, String protocol) {
228-
return createServicePort(name, port, targetPort, null, protocol);
227+
public static ServicePort createServicePort(String name, int port, String targetPortName, String protocol) {
228+
return createServicePort(name, port, targetPortName, null, protocol);
229229
}
230230

231231
/**
232232
* Creates Service port with a specific node port
233233
*
234234
* @param name Name of the port
235235
* @param port The port on the service which can be accessed by clients
236-
* @param targetPort The port on the container / Pod where the connections will be routed
236+
* @param targetPortName the name of the target port on the container / Pod where the connections will be routed
237237
* @param nodePort The desired node port number
238238
* @param protocol Protocol used by this port
239239
*
240240
* @return Created port
241241
*/
242-
public static ServicePort createServicePort(String name, int port, int targetPort, Integer nodePort, String protocol) {
242+
public static ServicePort createServicePort(String name, int port, String targetPortName, Integer nodePort, String protocol) {
243243
return new ServicePortBuilder()
244244
.withName(name)
245245
.withProtocol(protocol)
246246
.withPort(port)
247-
.withNewTargetPort(targetPort)
247+
.withNewTargetPort(targetPortName)
248248
.withNodePort(nodePort)
249249
.build();
250250
}

cluster-operator/src/main/java/io/strimzi/operator/cluster/model/jmx/JmxModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public String secretName() {
115115
*/
116116
public List<ServicePort> servicePorts() {
117117
if (isEnabled) {
118-
return List.of(ServiceUtils.createServicePort(JMX_PORT_NAME, JMX_PORT, JMX_PORT, "TCP"));
118+
return List.of(ServiceUtils.createServicePort(JMX_PORT_NAME, JMX_PORT, JMX_PORT_NAME, "TCP"));
119119
} else {
120120
return List.of();
121121
}

0 commit comments

Comments
 (0)