Skip to content
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
9 changes: 7 additions & 2 deletions bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<awssdk.version>2.10.3</awssdk.version>
<azure-functions-java-library.version>1.3.0</azure-functions-java-library.version>
<kotlin.version>1.3.41</kotlin.version>
<dekorate.version>0.9.4</dekorate.version>
<dekorate.version>0.9.9</dekorate.version>
<maven-artifact-transfer.version>0.10.0</maven-artifact-transfer.version>
<jline.version>2.14.6</jline.version>
<maven-invoker.version>3.0.1</maven-invoker.version>
Expand Down Expand Up @@ -739,7 +739,12 @@
<version>${dekorate.version}</version>
<classifier>noapt</classifier>
</dependency>

<dependency>
<groupId>io.dekorate</groupId>
<artifactId>knative-annotations</artifactId>
<version>${dekorate.version}</version>
<classifier>noapt</classifier>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand Down
85 changes: 85 additions & 0 deletions docs/src/main/asciidoc/kubernetes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,88 @@ The OpenShift resources can be customized in a similar approach with Kubernetes.
| s2i.auto-push-enabled | boolean | | false
| s2i.auto-build-enabled | boolean | | false
|====

=== Knative

To enable the generation of Knative resources, you need to include Knative in the target platforms:

[source]
----
kubernetes.deployment.target=knative
----

Following the execution of `./mvnw package` you will notice amongst the other files that are created, two files named
`knative.json` and `knative.yml` in the `target/kubernetes/` directory.

If you look at either file you will see that it contains a Knative `Service`.

The full source of the `knative.json` file looks something like this:

[source,json]
----
{
"apiVersion" : "v1",
"kind" : "List",
"items" : [ {
"apiVersion" : "serving.knative.dev/v1alpha1",
"kind" : "Service",
"metadata" : {
"labels" : {
"app" : "test-quarkus-app",
"version" : "0.1-SNAPSHOT",
"group" : "yourDockerUsername"
},
"name" : "knative"
},
"spec" : {
"runLatest" : {
"configuration" : {
"revisionTemplate" : {
"spec" : {
"container" : {
"image" : "dev.local/yourDockerUsername/test-quarkus-app:1.0-SNAPSHOT",
"imagePullPolicy" : "IfNotPresent"
}
}
}
}
}
}
} ]
}
----

The generated service can be customized using the following properties:

.Knative
|====
| Property | Type | Description | Default Value
| knative.group | String | |
| knative.name | String | |
| knative.version | String | |
| knative.labels | Label[] | |
| knative.annotations | Annotation[] | |
| knative.env-vars | Env[] | |
| knative.working-dir | String | |
| knative.command | String[] | |
| knative.arguments | String[] | |
| knative.service-account | String | |
| knative.host | String | |
| knative.ports | Port[] | |
| knative.service-type | ServiceType | | ClusterIP
| knative.pvc-volumes | PersistentVolumeClaimVolume[] | |
| knative.secret-volumes | SecretVolume[] | |
| knative.config-map-volumes | ConfigMapVolume[] | |
| knative.git-repo-volumes | GitRepoVolume[] | |
| knative.aws-elastic-block-store-volumes | AwsElasticBlockStoreVolume[] | |
| knative.azure-disk-volumes | AzureDiskVolume[] | |
| knative.azure-file-volumes | AzureFileVolume[] | |
| knative.mounts | Mount[] | |
| knative.image-pull-policy | ImagePullPolicy | | IfNotPresent
| knative.image-pull-secrets | String[] | |
| knative.liveness-probe | Probe | | ( see Probe )
| knative.readiness-probe | Probe | | ( see Probe )
| knative.sidecars | Container[] | |
| knative.expose | boolean | | false
| knative.auto-deploy-enabled | boolean | | false
|====
15 changes: 15 additions & 0 deletions extensions/kubernetes/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.dekorate</groupId>
<artifactId>knative-annotations</artifactId>
<classifier>noapt</classifier>
<exclusions>
<exclusion>
<groupId>io.sundr</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions integration-tests/kubernetes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<artifactId>openshift-annotations</artifactId>
<classifier>noapt</classifier>
</dependency>
<dependency>
<groupId>io.dekorate</groupId>
<artifactId>knative-annotations</artifactId>
<classifier>noapt</classifier>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
117 changes: 117 additions & 0 deletions integration-tests/kubernetes/src/it/knative/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>knative</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>@project.version@</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the docker image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/kubernetes-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/kubernetes-jvm
#
###
FROM fabric8/java-alpine-openjdk8-jre
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
ENTRYPOINT [ "/deployments/run-java.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
#
# Before building the docker image run:
#
# mvn package -Pnative -Dnative-image.docker-build=true
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native -t quarkus/kubernetes .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/kubernetes
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY target/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class Hello {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello";
}
}
Loading