Skip to content

Commit

Permalink
Merge pull request #30007 from Sgitario/ingress_classname
Browse files Browse the repository at this point in the history
Add ingress class name property part of Ingress config
  • Loading branch information
iocanel authored Jan 4, 2023
2 parents 620db1f + 3f28a4b commit 0942a53
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void visit(KubernetesConfigFluent config) {
KubernetesConfigFluent.IngressNested ingressConfigBuilder = config.withNewIngress();
ingressConfigBuilder.withExpose(true);
ingressConfig.host.ifPresent(ingressConfigBuilder::withHost);
ingressConfig.ingressClassName.ifPresent(ingressConfigBuilder::withIngressClassName);

ingressConfigBuilder.endIngress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public class IngressConfig {
@ConfigItem
Optional<String> host;

/**
* The class of the Ingress. If the ingressClassName is omitted, a default Ingress class is used.
*/
@ConfigItem
Optional<String> ingressClassName;

/**
* Custom annotations to add to exposition (route or ingress) resources
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@

public class KubernetesWithIngressTest {

private static final String APP_NAME = "kubernetes-with-ingress";

@RegisterExtension
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
.setApplicationName("kubernetes-with-ingress")
.setApplicationName(APP_NAME)
.setApplicationVersion("0.1-SNAPSHOT")
.withConfigurationResource("kubernetes-with-ingress.properties")
.withConfigurationResource(APP_NAME + ".properties")
.setLogFileName("k8s.log")
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion())));

Expand All @@ -44,23 +46,19 @@ public void assertGeneratedResources() throws IOException {

assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
assertThat(d.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-with-ingress");
});

assertThat(d.getSpec()).satisfies(deploymentSpec -> {
assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
assertThat(t.getSpec()).satisfies(podSpec -> {

});
});
assertThat(m.getName()).isEqualTo(APP_NAME);
});
});

assertThat(kubernetesList).filteredOn(i -> "Ingress".equals(i.getKind())).singleElement().satisfies(item -> {
assertThat(item).isInstanceOfSatisfying(Ingress.class, ingress -> {
//Check that labels and annotations are also applied to Routes (#10260)
assertThat(ingress.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-with-ingress");
assertThat(m.getName()).isEqualTo(APP_NAME);
});

assertThat(ingress.getSpec()).satisfies(spec -> {
assertThat(spec.getIngressClassName()).isEqualTo("Nginx");
});

assertThat(ingress.getSpec().getRules()).allSatisfy(rule -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
quarkus.kubernetes.ingress.expose=true
quarkus.kubernetes.ingress.expose=true
quarkus.kubernetes.ingress.ingress-class-name=Nginx

0 comments on commit 0942a53

Please sign in to comment.