Skip to content

Commit

Permalink
Lift restriction of HTTP application for Kubernetes manifest generation
Browse files Browse the repository at this point in the history
Resolves: quarkusio#19442
  • Loading branch information
geoand committed Aug 24, 2021
1 parent fb575c1 commit 593b4e1
Show file tree
Hide file tree
Showing 15 changed files with 558 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig,
.filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
.findFirst();

if (!openshiftYml.isPresent()) {
if (openshiftYml.isEmpty()) {
LOG.warn(
"No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no openshift process will be taking place");
"No Openshift manifests were generated so no openshift build process will be taking place");
return;
}

Expand Down Expand Up @@ -298,9 +298,9 @@ public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig
.filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
.findFirst();

if (!openshiftYml.isPresent()) {
if (openshiftYml.isEmpty()) {
LOG.warn(
"No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no openshift process will be taking place");
"No Openshift manifests were generated so no openshift build process will be taking place");
return;
}
//The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ public void s2iBuildFromJar(S2iConfig s2iConfig, ContainerImageConfig containerI
.filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
.findFirst();

if (!openshiftYml.isPresent()) {
if (openshiftYml.isEmpty()) {
LOG.warn(
"No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no s2i process will be taking place");
"No Openshift manifests were generated so no s2i process will be taking place");
return;
}

Expand Down Expand Up @@ -224,9 +224,9 @@ public void s2iBuildFromNative(S2iConfig s2iConfig, ContainerImageConfig contain
.filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml"))
.findFirst();

if (!openshiftYml.isPresent()) {
if (openshiftYml.isEmpty()) {
LOG.warn(
"No Openshift manifests were generated (most likely due to the fact that the service is not an HTTP service) so no s2i process will be taking place");
"No Openshift manifests were generated so no s2i process will be taking place");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ public static List<DecoratorBuildItem> createDecorators(Optional<Project> projec
result.addAll(createArgsDecorator(project, target, name, config, command));

//Handle Probes
result.addAll(createProbeDecorators(name, target, config.getLivenessProbe(), config.getReadinessProbe(),
livenessProbePath, readinessProbePath));
if (!ports.isEmpty()) {
result.addAll(createProbeDecorators(name, target, config.getLivenessProbe(), config.getReadinessProbe(),
livenessProbePath, readinessProbePath));
}

//Handle RBAC
if (!roleBindings.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public void build(ApplicationInfoBuildItem applicationInfo,
List<ConfiguratorBuildItem> allConfigurationRegistry = new ArrayList<>(configurators);
List<DecoratorBuildItem> allDecorators = new ArrayList<>(decorators);

if (kubernetesPorts.isEmpty()) {
log.debug("The service is not an HTTP service so no Kubernetes manifests will be generated");
return;
}

final Path root;
try {
root = Files.createTempDirectory("quarkus-kubernetes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
.findFirst().orElse(DEFAULT_HTTP_PORT);
result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyHttpGetActionPortDecorator(name, name, port)));

// Hanlde non-s2i
// Handle non-s2i
if (!capabilities.isPresent(Capability.CONTAINER_IMAGE_S2I)
&& !capabilities.isPresent("io.quarkus.openshift")
&& !capabilities.isPresent(Capability.CONTAINER_IMAGE_OPENSHIFT)) {
Expand Down
1 change: 1 addition & 0 deletions integration-tests/kubernetes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<modules>
<module>maven-invoker-way</module>
<module>quarkus-standard-way</module>
<module>quarkus-standard-way-kafka</module>
</modules>

</project>
227 changes: 227 additions & 0 deletions integration-tests/kubernetes/quarkus-standard-way-kafka/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-test-kubernetes-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-integration-test-kubernetes-standard-kafka</artifactId>
<name>Quarkus - Integration Tests - Kubernetes - Standard - Kafka</name>
<description>Kubernetes integration tests that use @QuarkusProdModeTest for dummy Kafka messaing only application</description>

<properties>
<!-- quarkus-container-image-*-deployment deps (see dependencies section) are important for proper build order.
But due to the nature of the tests in this module, the runtime siblings must not be on the classpath.
Therefore the following property instructs RequiresMinimalDeploymentDependency enforcer rule to _not_
consider the respective deployment deps "superfluous" (because their runtime siblings are not present). -->
<enforcer.requiresMinimalDeploymentDependency.nonSuperfluous>
quarkus-container-image-docker-deployment,
quarkus-container-image-jib-deployment,
quarkus-container-image-openshift-deployment,
quarkus-container-image-s2i-deployment
</enforcer.requiresMinimalDeploymentDependency.nonSuperfluous>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>knative-model</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.xml.bind</groupId>
<artifactId>jboss-jaxb-api_2.3_spec</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<!-- needed for the customization of the build chain -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-spi</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-kafka-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-openshift-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-s2i-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<profiles>
<profile>
<id>basic-test-suite</id>
<activation>
<property>
<name>basicTests</name>
</property>
</activation>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.it.kubernetes.kafka;

import java.util.Random;

import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Outgoing;

import io.smallrye.common.annotation.Blocking;

public class DummyProcessor {

private final Random random = new Random();

@Incoming("requests")
@Outgoing("quotes")
@Blocking
public int process(String quoteRequest) throws InterruptedException {
// simulate some hard working task
Thread.sleep(200);
return random.nextInt(100);
}
}
Loading

0 comments on commit 593b4e1

Please sign in to comment.