From a412c5b5694b0d49238a2f48cad7d6bd3c0d7bec Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 04:08:27 -0500 Subject: [PATCH 1/9] Adding gitignore for project. --- micro-java/.gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 micro-java/.gitignore diff --git a/micro-java/.gitignore b/micro-java/.gitignore new file mode 100644 index 0000000..e67baac --- /dev/null +++ b/micro-java/.gitignore @@ -0,0 +1,41 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties + +mvnw + +# 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 From 60556228fb40d3f3261903a29dbc20788cae02f5 Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 04:09:05 -0500 Subject: [PATCH 2/9] Ignore more files. --- micro-java/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micro-java/.gitignore b/micro-java/.gitignore index e67baac..b5467a2 100644 --- a/micro-java/.gitignore +++ b/micro-java/.gitignore @@ -5,7 +5,7 @@ pom.xml.releaseBackup pom.xml.versionsBackup release.properties -mvnw +mvnw* # Eclipse .project From 3c429abb4fc2ed4917b5c1aa01854b6430157e2c Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 04:10:51 -0500 Subject: [PATCH 3/9] Ignore vs codium and more mvn files. --- micro-java/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/micro-java/.gitignore b/micro-java/.gitignore index b5467a2..23876f1 100644 --- a/micro-java/.gitignore +++ b/micro-java/.gitignore @@ -6,6 +6,9 @@ pom.xml.versionsBackup release.properties mvnw* +.mvn/ +# VS Code +.vscode/ # Eclipse .project From 7ec6c4616f948babc8c8e7626bd1432ae3bf254a Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 04:12:24 -0500 Subject: [PATCH 4/9] Ignore vs code from root directory. --- .gitignore | 7 +- micro-java/.dockerignore | 5 + micro-java/pom.xml | 182 ++++++++----- .../src/main/docker/Dockerfile.fast-jar | 54 ++++ micro-java/src/main/docker/Dockerfile.jvm | 51 ++++ micro-java/src/main/docker/Dockerfile.native | 27 ++ .../openshift/hello/HelloResource.java | 21 +- .../openshift/hello/JaxRsActivator.java | 8 - .../resources/META-INF/resources/index.html | 242 ++++++++++++++++++ .../application.properties} | 0 .../openshift/hello/HelloResourceTest.java | 21 ++ .../hello/NativeHelloResourceIT.java | 9 + 12 files changed, 538 insertions(+), 89 deletions(-) create mode 100644 micro-java/.dockerignore create mode 100644 micro-java/src/main/docker/Dockerfile.fast-jar create mode 100644 micro-java/src/main/docker/Dockerfile.jvm create mode 100644 micro-java/src/main/docker/Dockerfile.native delete mode 100644 micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java create mode 100644 micro-java/src/main/resources/META-INF/resources/index.html rename micro-java/src/main/{fabric8/.gitkeep => resources/application.properties} (100%) create mode 100644 micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java create mode 100644 micro-java/src/test/java/com/redhat/training/openshift/hello/NativeHelloResourceIT.java diff --git a/.gitignore b/.gitignore index edaa9c6..541a8b1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,11 @@ *.ear hs_err_pid* +########################## +# VS Code +########################## +.vscode/ + ########################## ## Maven ########################## @@ -57,4 +62,4 @@ nb-configuration.xml ########################## ## OS X ########################## -.DS_Store \ No newline at end of file +.DS_Store diff --git a/micro-java/.dockerignore b/micro-java/.dockerignore new file mode 100644 index 0000000..94810d0 --- /dev/null +++ b/micro-java/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/* \ No newline at end of file diff --git a/micro-java/pom.xml b/micro-java/pom.xml index 9c8b9cd..b3c81f0 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -1,96 +1,150 @@ - - - + + 4.0.0 - - com.redhat.training.openshift - hello - 1.0 - war - Red Hat Training Hello Java app - Hello microservice using Thorntail - + com.redhat.training.openshift.hello + micro-java2 + 1.0.0-SNAPSHOT - - + 3.8.1 + true + 11 + 11 UTF-8 - false - - - 2.4.0.Final - - - 3.1 - 2.16 - 2.5 - 4.1.0 - - - 1.8 - 1.8 + UTF-8 + 1.11.6.Final-redhat-00001 + quarkus-universe-bom + com.redhat.quarkus + 1.11.6.Final-redhat-00001 + 3.0.0-M5 - - - io.thorntail - bom-all - ${version.thorntail} - import + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} pom + import - - io.thorntail - cdi + io.quarkus + quarkus-arc - io.thorntail - jaxrs + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test - + + + + true + + + false + + redhat + https://maven.repository.redhat.com/ga + + + + + + true + + + false + + redhat + https://maven.repository.redhat.com/ga + + - - hello - - - io.thorntail - thorntail-maven-plugin - ${version.thorntail} + io.quarkus + quarkus-maven-plugin + ${quarkus-plugin.version} + true - package + build + generate-code + generate-code-tests - io.fabric8 - fabric8-maven-plugin - ${version.fabric8.plugin} - - - fmp - - resource - build - - - + maven-compiler-plugin + ${compiler-plugin.version} + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + org.eclipse.jkube + openshift-maven-plugin + 1.2.0 - + + + native + + + native + + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + + + native + + + diff --git a/micro-java/src/main/docker/Dockerfile.fast-jar b/micro-java/src/main/docker/Dockerfile.fast-jar new file mode 100644 index 0000000..5fa2aef --- /dev/null +++ b/micro-java/src/main/docker/Dockerfile.fast-jar @@ -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" ] diff --git a/micro-java/src/main/docker/Dockerfile.jvm b/micro-java/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..ce8612b --- /dev/null +++ b/micro-java/src/main/docker/Dockerfile.jvm @@ -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" ] diff --git a/micro-java/src/main/docker/Dockerfile.native b/micro-java/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..f6f3935 --- /dev/null +++ b/micro-java/src/main/docker/Dockerfile.native @@ -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"] diff --git a/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java index 41084a4..99cccae 100644 --- a/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java +++ b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java @@ -1,27 +1,16 @@ package com.redhat.training.openshift.hello; -import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; -@Path("/") +@Path("/api") public class HelloResource { @GET - @Path("/hello") - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) public String hello() { - String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown"); - String message = System.getenv().getOrDefault("APP_MSG", null); - String response = ""; - - if (message == null) { - response = "Hello world from host "+hostname+"\n"; - } else { - response = "Hello world from host ["+hostname+"].\n"; - response += "Message received = "+message+"\n"; - } - return response; + return "Hello RESTEasy"; } -} +} \ No newline at end of file diff --git a/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java b/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java deleted file mode 100644 index 7a6a14a..0000000 --- a/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java +++ /dev/null @@ -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 { -} diff --git a/micro-java/src/main/resources/META-INF/resources/index.html b/micro-java/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000..0202a31 --- /dev/null +++ b/micro-java/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,242 @@ + + + + + micro-java2 - 1.0.0-SNAPSHOT + + + + + + +
+
+

Congratulations, you have created a new Quarkus cloud application.

+ +

Why do you see this?

+ +

This page is served by Quarkus. The source is in + src/main/resources/META-INF/resources/index.html.

+ +

What can I do from here?

+ +

If not already done, run the application in dev mode using: ./mvnw compile quarkus:dev. +

+
    +
  • Play with your example code in src/main/java: +
    +
    +
    +

    RESTEasy JAX-RS

    + Guide +
    +
    +

    A Hello World RESTEasy resource

    + +
    +
    + GET /api +
    +
    + +
    +
  • +
  • Your static assets are located in src/main/resources/META-INF/resources.
  • +
  • Configure your application in src/main/resources/application.properties.
  • +
+

Do you like Quarkus?

+

Go give it a star on GitHub.

+
+
+
+

Application

+
    +
  • GroupId: com.redhat.training.openshift.hello
  • +
  • ArtifactId: micro-java2
  • +
  • Version: 1.0.0-SNAPSHOT
  • +
  • Quarkus Version: 1.11.6.Final-redhat-00001
  • +
+
+ +
+
+ + \ No newline at end of file diff --git a/micro-java/src/main/fabric8/.gitkeep b/micro-java/src/main/resources/application.properties similarity index 100% rename from micro-java/src/main/fabric8/.gitkeep rename to micro-java/src/main/resources/application.properties diff --git a/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java b/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java new file mode 100644 index 0000000..d32cb12 --- /dev/null +++ b/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java @@ -0,0 +1,21 @@ +package com.redhat.training.openshift.hello; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +public class HelloResourceTest { + + @Test + public void testHelloEndpoint() { + given() + .when().get("/api") + .then() + .statusCode(200) + .body(is("Hello RESTEasy")); + } + +} \ No newline at end of file diff --git a/micro-java/src/test/java/com/redhat/training/openshift/hello/NativeHelloResourceIT.java b/micro-java/src/test/java/com/redhat/training/openshift/hello/NativeHelloResourceIT.java new file mode 100644 index 0000000..82f180a --- /dev/null +++ b/micro-java/src/test/java/com/redhat/training/openshift/hello/NativeHelloResourceIT.java @@ -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. +} \ No newline at end of file From 98139f4401301bada10317bfb55652b5f929abe4 Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 04:21:31 -0500 Subject: [PATCH 5/9] Fix name. --- micro-java/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micro-java/pom.xml b/micro-java/pom.xml index b3c81f0..28554ef 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 com.redhat.training.openshift.hello - micro-java2 + micro-java 1.0.0-SNAPSHOT 3.8.1 From 408c9919b1ecae66a5872c4e920fe3c949bc71cd Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 06:51:34 -0500 Subject: [PATCH 6/9] Fix file mess. Update micro-java endpoints, test, deployment file and pom. --- micro-java/pom.xml | 13 + .../openshift/hello/HelloResource.java | 24 +- micro-java/src/main/jkube/deployment.yml | 41 +++ .../resources/META-INF/resources/index.html | 242 ------------------ .../openshift/hello/HelloResourceTest.java | 8 +- 5 files changed, 81 insertions(+), 247 deletions(-) create mode 100644 micro-java/src/main/jkube/deployment.yml delete mode 100644 micro-java/src/main/resources/META-INF/resources/index.html diff --git a/micro-java/pom.xml b/micro-java/pom.xml index 28554ef..8c59632 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -108,6 +108,19 @@ org.eclipse.jkube openshift-maven-plugin 1.2.0 + + + + configmap-hello + + + APP_MSG + My custom application message. + + + + + diff --git a/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java index 99cccae..a3623cd 100644 --- a/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java +++ b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java @@ -1,16 +1,36 @@ package com.redhat.training.openshift.hello; +import java.util.Optional; + +import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.eclipse.microprofile.config.inject.ConfigProperty; + @Path("/api") +@Produces(MediaType.TEXT_PLAIN) +@Consumes(MediaType.TEXT_PLAIN) public class HelloResource { + @ConfigProperty(name = "HOSTNAME", defaultValue = "unknown") + String hostname; + @ConfigProperty(name = "APP_MSG") + Optional message; + @GET - @Produces(MediaType.TEXT_PLAIN) + @Path("/hello") public String hello() { - return "Hello RESTEasy"; + String response = ""; + + if (!message.isPresent()) { + response = "Hello world from host " + hostname + "\n"; + } else { + response = "Hello world from host [" + hostname + "].\n"; + response += "Message received = " + message.get() + "\n"; + } + return response; } } \ No newline at end of file diff --git a/micro-java/src/main/jkube/deployment.yml b/micro-java/src/main/jkube/deployment.yml new file mode 100644 index 0000000..ad926ba --- /dev/null +++ b/micro-java/src/main/jkube/deployment.yml @@ -0,0 +1,41 @@ +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + app: micro-java + provider: jkube + group: com.redhat.training.openshift.hello + strategy: + rollingParams: + timeoutSeconds: 3600 + type: Rolling + template: + metadata: + annotations: + app.openshift.io/vcs-ref: master + jkube.io/git-url: git@github.com:maudemor/DO288-apps.git + app.openshift.io/vcs-uri: git@github.com:maudemor/DO288-apps.git + jkube.io/git-commit: 3bffad109a77ebd72831d8f791c38df68db28e60 + jkube.io/git-branch: master + labels: + app: micro-java + provider: jkube + version: 1.0.0-SNAPSHOT + group: com.redhat.training.openshift.hello + spec: + containers: + - envFrom: + - configMapRef: + name: configmap-hello + env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: micro-java:latest + imagePullPolicy: IfNotPresent + name: quarkus + ports: + - containerPort: 8080 + name: http + protocol: TCP diff --git a/micro-java/src/main/resources/META-INF/resources/index.html b/micro-java/src/main/resources/META-INF/resources/index.html deleted file mode 100644 index 0202a31..0000000 --- a/micro-java/src/main/resources/META-INF/resources/index.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - - micro-java2 - 1.0.0-SNAPSHOT - - - - - - -
-
-

Congratulations, you have created a new Quarkus cloud application.

- -

Why do you see this?

- -

This page is served by Quarkus. The source is in - src/main/resources/META-INF/resources/index.html.

- -

What can I do from here?

- -

If not already done, run the application in dev mode using: ./mvnw compile quarkus:dev. -

-
    -
  • Play with your example code in src/main/java: -
    -
    -
    -

    RESTEasy JAX-RS

    - Guide -
    -
    -

    A Hello World RESTEasy resource

    - -
    -
    - GET /api -
    -
    - -
    -
  • -
  • Your static assets are located in src/main/resources/META-INF/resources.
  • -
  • Configure your application in src/main/resources/application.properties.
  • -
-

Do you like Quarkus?

-

Go give it a star on GitHub.

-
-
-
-

Application

-
    -
  • GroupId: com.redhat.training.openshift.hello
  • -
  • ArtifactId: micro-java2
  • -
  • Version: 1.0.0-SNAPSHOT
  • -
  • Quarkus Version: 1.11.6.Final-redhat-00001
  • -
-
- -
-
- - \ No newline at end of file diff --git a/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java b/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java index d32cb12..4ba6649 100644 --- a/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java +++ b/micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java @@ -1,21 +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.is; +import static org.hamcrest.CoreMatchers.containsString; @QuarkusTest +@TestHTTPEndpoint(HelloResource.class) public class HelloResourceTest { @Test public void testHelloEndpoint() { given() - .when().get("/api") + .when().get("/hello") .then() .statusCode(200) - .body(is("Hello RESTEasy")); + .body(containsString("Hello world from")); } } \ No newline at end of file From dbc0d2d8ef9eded76dcbc78435172f075dd05c60 Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Fri, 7 May 2021 07:28:19 -0500 Subject: [PATCH 7/9] Change to use YAML file for the ConfigMap. --- micro-java/pom.xml | 13 ------------- micro-java/src/main/jkube/cm.yml | 6 ++++++ micro-java/src/main/jkube/deployment.yml | 14 ++++---------- 3 files changed, 10 insertions(+), 23 deletions(-) create mode 100644 micro-java/src/main/jkube/cm.yml diff --git a/micro-java/pom.xml b/micro-java/pom.xml index 8c59632..28554ef 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -108,19 +108,6 @@ org.eclipse.jkube openshift-maven-plugin 1.2.0 - - - - configmap-hello - - - APP_MSG - My custom application message. - - - - - diff --git a/micro-java/src/main/jkube/cm.yml b/micro-java/src/main/jkube/cm.yml new file mode 100644 index 0000000..3aadd12 --- /dev/null +++ b/micro-java/src/main/jkube/cm.yml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap-hello +data: + APP_MSG: sample external configuration diff --git a/micro-java/src/main/jkube/deployment.yml b/micro-java/src/main/jkube/deployment.yml index ad926ba..7d0355e 100644 --- a/micro-java/src/main/jkube/deployment.yml +++ b/micro-java/src/main/jkube/deployment.yml @@ -11,12 +11,6 @@ spec: type: Rolling template: metadata: - annotations: - app.openshift.io/vcs-ref: master - jkube.io/git-url: git@github.com:maudemor/DO288-apps.git - app.openshift.io/vcs-uri: git@github.com:maudemor/DO288-apps.git - jkube.io/git-commit: 3bffad109a77ebd72831d8f791c38df68db28e60 - jkube.io/git-branch: master labels: app: micro-java provider: jkube @@ -24,14 +18,14 @@ spec: group: com.redhat.training.openshift.hello spec: containers: - - envFrom: - - configMapRef: - name: configmap-hello - env: + - env: - name: KUBERNETES_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace + envFrom: + - configMapRef: + name: configmap-hello image: micro-java:latest imagePullPolicy: IfNotPresent name: quarkus From 6af1de04313df35b7f8f723cae911620db1dbf7d Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Thu, 20 May 2021 06:22:19 -0500 Subject: [PATCH 8/9] Applied version changes to micro-java app, as well as updated deployment file to use the specific version. --- micro-java/pom.xml | 2 +- micro-java/src/main/jkube/deployment.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/micro-java/pom.xml b/micro-java/pom.xml index 28554ef..4958b1c 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.redhat.training.openshift.hello micro-java - 1.0.0-SNAPSHOT + 1.0 3.8.1 true diff --git a/micro-java/src/main/jkube/deployment.yml b/micro-java/src/main/jkube/deployment.yml index 7d0355e..88c6d1b 100644 --- a/micro-java/src/main/jkube/deployment.yml +++ b/micro-java/src/main/jkube/deployment.yml @@ -14,7 +14,7 @@ spec: labels: app: micro-java provider: jkube - version: 1.0.0-SNAPSHOT + version: 1.0 group: com.redhat.training.openshift.hello spec: containers: @@ -26,7 +26,7 @@ spec: envFrom: - configMapRef: name: configmap-hello - image: micro-java:latest + image: micro-java:1.0 imagePullPolicy: IfNotPresent name: quarkus ports: From f854f3ee70040b02e33c93c42520ec2b6c77640d Mon Sep 17 00:00:00 2001 From: Manuel Aude Morales Date: Tue, 25 May 2021 06:48:02 -0500 Subject: [PATCH 9/9] Removed configuration to be added by student during the activity. --- micro-java/pom.xml | 5 ---- micro-java/src/main/jkube/cm.yml | 1 - micro-java/src/main/jkube/deployment.yml | 35 ++++++++++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/micro-java/pom.xml b/micro-java/pom.xml index 4958b1c..92d220b 100644 --- a/micro-java/pom.xml +++ b/micro-java/pom.xml @@ -104,11 +104,6 @@ - - org.eclipse.jkube - openshift-maven-plugin - 1.2.0 - diff --git a/micro-java/src/main/jkube/cm.yml b/micro-java/src/main/jkube/cm.yml index 3aadd12..3565c20 100644 --- a/micro-java/src/main/jkube/cm.yml +++ b/micro-java/src/main/jkube/cm.yml @@ -3,4 +3,3 @@ kind: ConfigMap metadata: name: configmap-hello data: - APP_MSG: sample external configuration diff --git a/micro-java/src/main/jkube/deployment.yml b/micro-java/src/main/jkube/deployment.yml index 88c6d1b..6398686 100644 --- a/micro-java/src/main/jkube/deployment.yml +++ b/micro-java/src/main/jkube/deployment.yml @@ -1,20 +1,26 @@ -spec: - replicas: 1 - revisionHistoryLimit: 2 - selector: +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: app: micro-java provider: jkube + version: "1.0" group: com.redhat.training.openshift.hello - strategy: - rollingParams: - timeoutSeconds: 3600 - type: Rolling + 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 + version: "1.0" group: com.redhat.training.openshift.hello spec: containers: @@ -23,9 +29,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - envFrom: - - configMapRef: - name: configmap-hello image: micro-java:1.0 imagePullPolicy: IfNotPresent name: quarkus @@ -33,3 +36,11 @@ spec: - containerPort: 8080 name: http protocol: TCP + - containerPort: 9779 + name: prometheus + protocol: TCP + - containerPort: 8778 + name: jolokia + protocol: TCP + securityContext: + privileged: false \ No newline at end of file