Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ingress class name property part of Ingress config #30007

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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