diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyKubernetesIngressConfigurator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyKubernetesIngressConfigurator.java index e98ff47fefd72..c025ffa88bb1b 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyKubernetesIngressConfigurator.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyKubernetesIngressConfigurator.java @@ -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(); } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/IngressConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/IngressConfig.java index 71072ff1cc935..3fe9fea8b6db5 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/IngressConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/IngressConfig.java @@ -21,6 +21,12 @@ public class IngressConfig { @ConfigItem Optional host; + /** + * The class of the Ingress. If the ingressClassName is omitted, a default Ingress class is used. + */ + @ConfigItem + Optional ingressClassName; + /** * Custom annotations to add to exposition (route or ingress) resources */ diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithIngressTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithIngressTest.java index 8fb44b85173f5..0c7ce2cb16c83 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithIngressTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithIngressTest.java @@ -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()))); @@ -44,15 +46,7 @@ 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); }); }); @@ -60,7 +54,11 @@ public void assertGeneratedResources() throws IOException { 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 -> { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-ingress.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-ingress.properties index ddc494034f0e4..abbb1ba05102e 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-ingress.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-ingress.properties @@ -1 +1,2 @@ -quarkus.kubernetes.ingress.expose=true \ No newline at end of file +quarkus.kubernetes.ingress.expose=true +quarkus.kubernetes.ingress.ingress-class-name=Nginx \ No newline at end of file