Merge pull request #128 from RedHatTraining/maudemor/base-micro-java
Maudemor/micro-java new version.
This commit is contained in:
commit
48ab8007c7
14 changed files with 402 additions and 83 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -8,6 +8,11 @@
|
||||||
*.ear
|
*.ear
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# VS Code
|
||||||
|
##########################
|
||||||
|
.vscode/
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
## Maven
|
## Maven
|
||||||
##########################
|
##########################
|
||||||
|
|
|
||||||
5
micro-java/.dockerignore
Normal file
5
micro-java/.dockerignore
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
*
|
||||||
|
!target/*-runner
|
||||||
|
!target/*-runner.jar
|
||||||
|
!target/lib/*
|
||||||
|
!target/quarkus-app/*
|
||||||
44
micro-java/.gitignore
vendored
Normal file
44
micro-java/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#Maven
|
||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
release.properties
|
||||||
|
|
||||||
|
mvnw*
|
||||||
|
.mvn/
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Eclipse
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
bin/
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
.idea
|
||||||
|
*.ipr
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# NetBeans
|
||||||
|
nb-configuration.xml
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Vim
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# patch
|
||||||
|
*.orig
|
||||||
|
*.rej
|
||||||
|
|
||||||
|
# Local environment
|
||||||
|
.env
|
||||||
|
|
@ -1,96 +1,145 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.redhat.training.openshift.hello</groupId>
|
||||||
<groupId>com.redhat.training.openshift</groupId>
|
<artifactId>micro-java</artifactId>
|
||||||
<artifactId>hello</artifactId>
|
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>war</packaging>
|
|
||||||
<name>Red Hat Training Hello Java app</name>
|
|
||||||
<description>Hello microservice using Thorntail</description>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Explicitly declaring the source encoding eliminates the following
|
<compiler-plugin.version>3.8.1</compiler-plugin.version>
|
||||||
message: -->
|
<maven.compiler.parameters>true</maven.compiler.parameters>
|
||||||
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
resources, i.e. build is platform dependent! -->
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<quarkus-plugin.version>1.11.6.Final-redhat-00001</quarkus-plugin.version>
|
||||||
<!-- Thorntail dependency versions -->
|
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
|
||||||
<version.thorntail>2.4.0.Final</version.thorntail>
|
<quarkus.platform.group-id>com.redhat.quarkus</quarkus.platform.group-id>
|
||||||
|
<quarkus.platform.version>1.11.6.Final-redhat-00001</quarkus.platform.version>
|
||||||
<!-- other plugin versions -->
|
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
|
||||||
<version.compiler.plugin>3.1</version.compiler.plugin>
|
|
||||||
<version.surefire.plugin>2.16</version.surefire.plugin>
|
|
||||||
<version.war.plugin>2.5</version.war.plugin>
|
|
||||||
<version.fabric8.plugin>4.1.0</version.fabric8.plugin>
|
|
||||||
|
|
||||||
<!-- maven-compiler-plugin -->
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.thorntail</groupId>
|
<groupId>${quarkus.platform.group-id}</groupId>
|
||||||
<artifactId>bom-all</artifactId>
|
<artifactId>${quarkus.platform.artifact-id}</artifactId>
|
||||||
<version>${version.thorntail}</version>
|
<version>${quarkus.platform.version}</version>
|
||||||
<scope>import</scope>
|
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.thorntail</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>cdi</artifactId>
|
<artifactId>quarkus-arc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.thorntail</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>jaxrs</artifactId>
|
<artifactId>quarkus-resteasy</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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<id>redhat</id>
|
||||||
|
<url>https://maven.repository.redhat.com/ga</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<id>redhat</id>
|
||||||
|
<url>https://maven.repository.redhat.com/ga</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
<build>
|
<build>
|
||||||
<!-- Maven will append the version to the finalName (which is the name
|
|
||||||
given to the generated war, and hence the context root) -->
|
|
||||||
<finalName>hello</finalName>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- The Thorntail Maven plugin creates an uber jar -->
|
|
||||||
<!-- To use, run: mvn thorntail:run -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.thorntail</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>thorntail-maven-plugin</artifactId>
|
<artifactId>quarkus-maven-plugin</artifactId>
|
||||||
<version>${version.thorntail}</version>
|
<version>${quarkus-plugin.version}</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>package</goal>
|
<goal>build</goal>
|
||||||
|
<goal>generate-code</goal>
|
||||||
|
<goal>generate-code-tests</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.fabric8</groupId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<artifactId>fabric8-maven-plugin</artifactId>
|
<version>${compiler-plugin.version}</version>
|
||||||
<version>${version.fabric8.plugin}</version>
|
</plugin>
|
||||||
<executions>
|
<plugin>
|
||||||
<execution>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<id>fmp</id>
|
<version>${surefire-plugin.version}</version>
|
||||||
<goals>
|
<configuration>
|
||||||
<goal>resource</goal>
|
<systemPropertyVariables>
|
||||||
<goal>build</goal>
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
</goals>
|
<maven.home>${maven.home}</maven.home>
|
||||||
</execution>
|
</systemPropertyVariables>
|
||||||
</executions>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>native</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>native</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${surefire-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||||
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
|
<maven.home>${maven.home}</maven.home>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<quarkus.package.type>native</quarkus.package.type>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
54
micro-java/src/main/docker/Dockerfile.fast-jar
Normal file
54
micro-java/src/main/docker/Dockerfile.fast-jar
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
####
|
||||||
|
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
|
||||||
|
#
|
||||||
|
# Before building the container image run:
|
||||||
|
#
|
||||||
|
# ./mvnw package -Dquarkus.package.type=fast-jar
|
||||||
|
#
|
||||||
|
# Then, build the image with:
|
||||||
|
#
|
||||||
|
# docker build -f src/main/docker/Dockerfile.fast-jar -t quarkus/micro-java2-fast-jar .
|
||||||
|
#
|
||||||
|
# Then run the container using:
|
||||||
|
#
|
||||||
|
# docker run -i --rm -p 8080:8080 quarkus/micro-java2-fast-jar
|
||||||
|
#
|
||||||
|
# If you want to include the debug port into your docker image
|
||||||
|
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
|
||||||
|
#
|
||||||
|
# Then run the container using :
|
||||||
|
#
|
||||||
|
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/micro-java2-fast-jar
|
||||||
|
#
|
||||||
|
###
|
||||||
|
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
|
||||||
|
|
||||||
|
ARG JAVA_PACKAGE=java-11-openjdk-headless
|
||||||
|
ARG RUN_JAVA_VERSION=1.3.8
|
||||||
|
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
|
||||||
|
# Install java and the run-java script
|
||||||
|
# Also set up permissions for user `1001`
|
||||||
|
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
|
||||||
|
&& microdnf update \
|
||||||
|
&& microdnf clean all \
|
||||||
|
&& mkdir /deployments \
|
||||||
|
&& chown 1001 /deployments \
|
||||||
|
&& chmod "g+rwX" /deployments \
|
||||||
|
&& chown 1001:root /deployments \
|
||||||
|
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
|
||||||
|
&& chown 1001 /deployments/run-java.sh \
|
||||||
|
&& chmod 540 /deployments/run-java.sh \
|
||||||
|
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
|
||||||
|
|
||||||
|
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
|
||||||
|
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
|
||||||
|
# We make four distinct layers so if there are application changes the library layers can be re-used
|
||||||
|
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
|
||||||
|
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
|
||||||
|
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
|
||||||
|
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
USER 1001
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
||||||
51
micro-java/src/main/docker/Dockerfile.jvm
Normal file
51
micro-java/src/main/docker/Dockerfile.jvm
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
####
|
||||||
|
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
|
||||||
|
#
|
||||||
|
# Before building the container image run:
|
||||||
|
#
|
||||||
|
# ./mvnw package
|
||||||
|
#
|
||||||
|
# Then, build the image with:
|
||||||
|
#
|
||||||
|
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/micro-java2-jvm .
|
||||||
|
#
|
||||||
|
# Then run the container using:
|
||||||
|
#
|
||||||
|
# docker run -i --rm -p 8080:8080 quarkus/micro-java2-jvm
|
||||||
|
#
|
||||||
|
# If you want to include the debug port into your docker image
|
||||||
|
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
|
||||||
|
#
|
||||||
|
# Then run the container using :
|
||||||
|
#
|
||||||
|
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/micro-java2-jvm
|
||||||
|
#
|
||||||
|
###
|
||||||
|
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
|
||||||
|
|
||||||
|
ARG JAVA_PACKAGE=java-11-openjdk-headless
|
||||||
|
ARG RUN_JAVA_VERSION=1.3.8
|
||||||
|
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
|
||||||
|
# Install java and the run-java script
|
||||||
|
# Also set up permissions for user `1001`
|
||||||
|
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
|
||||||
|
&& microdnf update \
|
||||||
|
&& microdnf clean all \
|
||||||
|
&& mkdir /deployments \
|
||||||
|
&& chown 1001 /deployments \
|
||||||
|
&& chmod "g+rwX" /deployments \
|
||||||
|
&& chown 1001:root /deployments \
|
||||||
|
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
|
||||||
|
&& chown 1001 /deployments/run-java.sh \
|
||||||
|
&& chmod 540 /deployments/run-java.sh \
|
||||||
|
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
|
||||||
|
|
||||||
|
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
|
||||||
|
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
|
||||||
|
COPY target/lib/* /deployments/lib/
|
||||||
|
COPY target/*-runner.jar /deployments/app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
USER 1001
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
||||||
27
micro-java/src/main/docker/Dockerfile.native
Normal file
27
micro-java/src/main/docker/Dockerfile.native
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
####
|
||||||
|
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
|
||||||
|
#
|
||||||
|
# Before building the container image run:
|
||||||
|
#
|
||||||
|
# ./mvnw package -Pnative
|
||||||
|
#
|
||||||
|
# Then, build the image with:
|
||||||
|
#
|
||||||
|
# docker build -f src/main/docker/Dockerfile.native -t quarkus/micro-java2 .
|
||||||
|
#
|
||||||
|
# Then run the container using:
|
||||||
|
#
|
||||||
|
# docker run -i --rm -p 8080:8080 quarkus/micro-java2
|
||||||
|
#
|
||||||
|
###
|
||||||
|
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
|
||||||
|
WORKDIR /work/
|
||||||
|
RUN chown 1001 /work \
|
||||||
|
&& chmod "g+rwX" /work \
|
||||||
|
&& chown 1001:root /work
|
||||||
|
COPY --chown=1001:root target/*-runner /work/application
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
USER 1001
|
||||||
|
|
||||||
|
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
|
||||||
|
|
@ -1,26 +1,35 @@
|
||||||
package com.redhat.training.openshift.hello;
|
package com.redhat.training.openshift.hello;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
@Path("/")
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
|
|
||||||
|
@Path("/api")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
@Consumes(MediaType.TEXT_PLAIN)
|
||||||
public class HelloResource {
|
public class HelloResource {
|
||||||
|
|
||||||
|
@ConfigProperty(name = "HOSTNAME", defaultValue = "unknown")
|
||||||
|
String hostname;
|
||||||
|
@ConfigProperty(name = "APP_MSG")
|
||||||
|
Optional<String> message;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/hello")
|
@Path("/hello")
|
||||||
@Produces("text/plain")
|
|
||||||
public String hello() {
|
public String hello() {
|
||||||
String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown");
|
String response = "";
|
||||||
String message = System.getenv().getOrDefault("APP_MSG", null);
|
|
||||||
String response = "";
|
|
||||||
|
|
||||||
if (message == null) {
|
if (!message.isPresent()) {
|
||||||
response = "Hello world from host "+hostname+"\n";
|
response = "Hello world from host " + hostname + "\n";
|
||||||
} else {
|
} else {
|
||||||
response = "Hello world from host ["+hostname+"].\n";
|
response = "Hello world from host [" + hostname + "].\n";
|
||||||
response += "Message received = "+message+"\n";
|
response += "Message received = " + message.get() + "\n";
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package com.redhat.training.openshift.hello;
|
|
||||||
|
|
||||||
import javax.ws.rs.ApplicationPath;
|
|
||||||
import javax.ws.rs.core.Application;
|
|
||||||
|
|
||||||
@ApplicationPath("/api")
|
|
||||||
public class JaxRsActivator extends Application {
|
|
||||||
}
|
|
||||||
5
micro-java/src/main/jkube/cm.yml
Normal file
5
micro-java/src/main/jkube/cm.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: configmap-hello
|
||||||
|
data:
|
||||||
46
micro-java/src/main/jkube/deployment.yml
Normal file
46
micro-java/src/main/jkube/deployment.yml
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: micro-java
|
||||||
|
provider: jkube
|
||||||
|
version: "1.0"
|
||||||
|
group: com.redhat.training.openshift.hello
|
||||||
|
name: micro-java
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: micro-java
|
||||||
|
provider: jkube
|
||||||
|
group: com.redhat.training.openshift.hello
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: micro-java
|
||||||
|
provider: jkube
|
||||||
|
version: "1.0"
|
||||||
|
group: com.redhat.training.openshift.hello
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: KUBERNETES_NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
|
image: micro-java:1.0
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
name: quarkus
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
name: http
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 9779
|
||||||
|
name: prometheus
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8778
|
||||||
|
name: jolokia
|
||||||
|
protocol: TCP
|
||||||
|
securityContext:
|
||||||
|
privileged: false
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.redhat.training.openshift.hello;
|
||||||
|
|
||||||
|
import io.quarkus.test.common.http.TestHTTPEndpoint;
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
|
|
||||||
|
@QuarkusTest
|
||||||
|
@TestHTTPEndpoint(HelloResource.class)
|
||||||
|
public class HelloResourceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHelloEndpoint() {
|
||||||
|
given()
|
||||||
|
.when().get("/hello")
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.body(containsString("Hello world from"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.redhat.training.openshift.hello;
|
||||||
|
|
||||||
|
import io.quarkus.test.junit.NativeImageTest;
|
||||||
|
|
||||||
|
@NativeImageTest
|
||||||
|
public class NativeHelloResourceIT extends HelloResourceTest {
|
||||||
|
|
||||||
|
// Execute the same tests but in native mode.
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue