Skip to content

Commit

Permalink
fix (jkube-kit/enricher) : Add 8443 as default web port to be conside…
Browse files Browse the repository at this point in the history
…red in Route Generation (eclipse-jkube#1459)

Add 8443 port to list of default web ports.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Nov 24, 2022
1 parent 997629e commit e42475b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Usage:
### 1.10.0 (2022-11-10)
* Fix #443: Add health check enricher for SmallRye Health
* Fix #508: Kubernetes Remote Development (inner-loop)
* Fix #1459: Route Generation should support `8443` as default web port
* Fix #1668: Allow additional services (via fragments) besides the default
* Fix #1684: Podman builds with errors are correctly processed and reported
* Fix #1704: `k8s:watch` with `jkube.watch.mode=copy` works as expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface ServiceExposer extends Enricher {
String EXPOSE_LABEL = "expose";

final class Util {
private static final Set<Integer> WEB_PORTS = new HashSet<>(Arrays.asList(80, 443, 8080, 9080, 9090, 9443));
private static final Set<Integer> WEB_PORTS = new HashSet<>(Arrays.asList(80, 443, 8443, 8080, 9080, 9090, 9443));

private Util() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.Map;
import java.util.Properties;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -293,19 +295,39 @@ void routeTargetPortFromServicePort() {
.contains("test-svc", "example.com", "Service", "test-svc", 80);
}

@Test
public void create_withNoExposeLabelPort8443_shouldCreateRoute() {
// Given
mockJKubeEnricherContext();
klb.addToItems(getMockServiceBuilder(8443, Collections.emptyMap()).build());

// When
new RouteEnricher(context).create(PlatformMode.openshift, klb);

// Then
assertThat(klb.build().getItems())
.hasSize(2)
.extracting("kind")
.containsExactly("Service", "Route");
}

private ServiceBuilder getMockServiceBuilder() {
return getMockServiceBuilder(8080, Collections.singletonMap("expose", "true"));
}

private ServiceBuilder getMockServiceBuilder(int port, Map<String, String> labels) {
// @formatter:off
return new ServiceBuilder()
.editOrNewMetadata()
.withName("test-svc")
.addToLabels("expose", "true")
.withLabels(labels)
.endMetadata()
.editOrNewSpec()
.addNewPort()
.withName("http")
.withPort(8080)
.withPort(port)
.withProtocol("TCP")
.withTargetPort(new IntOrString(8080))
.withTargetPort(new IntOrString(port))
.endPort()
.addToSelector("group", "test")
.withType("LoadBalancer")
Expand Down

0 comments on commit e42475b

Please sign in to comment.