-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract route/ingress configuration into a specific object
- Loading branch information
Showing
12 changed files
with
184 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...s/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ExpositionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.kubernetes.deployment; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class ExpositionConfig { | ||
|
||
/** | ||
* If true, the service will be exposed | ||
*/ | ||
@ConfigItem | ||
boolean expose; | ||
|
||
/** | ||
* The host under which the application is going to be exposed | ||
*/ | ||
@ConfigItem | ||
Optional<String> host; | ||
|
||
/** | ||
* If true, TLS will be enabled on the exposed service | ||
*/ | ||
@ConfigItem(defaultValue = "true") | ||
boolean secure; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithRoutePropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.Service; | ||
import io.fabric8.openshift.api.model.Route; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class OpenshiftWithRoutePropertiesTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(GreetingResource.class)) | ||
.setApplicationName("openshift") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("openshift-with-route.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); | ||
assertThat(kubernetesDir) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml")); | ||
List<HasMetadata> openshiftList = DeserializationUtil | ||
.deserializeAsList(kubernetesDir.resolve("openshift.yml")); | ||
|
||
assertThat(openshiftList).filteredOn(h -> "Service".equals(h.getKind())).singleElement().satisfies(h -> { | ||
assertThat(h).isInstanceOfSatisfying(Service.class, s -> { | ||
assertThat(s.getMetadata()).satisfies(m -> { | ||
assertThat(m.getNamespace()).isEqualTo("applications"); | ||
}); | ||
|
||
assertThat(s.getSpec()).satisfies(spec -> { | ||
assertThat(spec.getSelector()).containsOnly(entry("app.kubernetes.io/name", "test-it")); | ||
assertThat(spec.getPorts()).hasSize(1).singleElement().satisfies(p -> { | ||
assertThat(p.getPort()).isEqualTo(9090); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
assertThat(openshiftList).filteredOn(i -> "Route".equals(i.getKind())).singleElement().satisfies(i -> { | ||
assertThat(i).isInstanceOfSatisfying(Route.class, in -> { | ||
//Check that labels and annotations are also applied to Routes (#10260) | ||
assertThat(i.getMetadata()).satisfies(m -> { | ||
assertThat(m.getName()).isEqualTo("test-it"); | ||
assertThat(m.getLabels()).contains(entry("foo", "bar")); | ||
assertThat(m.getAnnotations()).contains(entry("bar", "baz")); | ||
assertThat(m.getAnnotations()).contains(entry("kubernetes.io/tls-acme", "true")); | ||
assertThat(m.getNamespace()).isEqualTo("applications"); | ||
}); | ||
assertThat(in.getSpec().getHost()).isEqualTo("foo.bar.io"); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-route.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
quarkus.http.port=9090 | ||
quarkus.kubernetes.deployment-target=openshift | ||
quarkus.openshift.name=test-it | ||
quarkus.openshift.namespace=applications | ||
quarkus.openshift.labels.foo=bar | ||
quarkus.openshift.annotations.bar=baz | ||
quarkus.openshift.group=grp | ||
|
||
quarkus.openshift.route.expose=true | ||
quarkus.openshift.route.host=foo.bar.io | ||
quarkus.openshift.route.secure=true | ||
|
||
quarkus.s2i.registry=quay.io |