이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 1. Deploying your Quarkus applications to OpenShift Container Platform
As an application developer, you can deploy your Quarkus applications to Red Hat OpenShift Container Platform by using a single Maven command. This functionality is provided by the quarkus-openshift extension, which supports multiple deployment options, including the Docker build strategy and the Source-to-Image (S2I) strategy.
Here, you learn the recommended workflows to deploy your Quarkus applications to production environments. To learn about other ways to deploy Quarkus applications, see the Quarkus community documentation.
Prerequisites
- You have OpenJDK 11 or 17 installed.
-
You have set the
JAVA_HOMEenvironment variable to the location of the Java SDK. - You have Apache Maven 3.8.x, where x is 6 or later installed.
You have a Quarkus Maven project that includes the
quarkus-openshiftextension.- To add the Quarkus OpenShift extension, see Adding the Quarkus OpenShift extension.
You have access to an OpenShift Container Platform cluster and the latest compatible version of the
octool installed.-
For information about installing the
octool, see Installing and configuring OpenShift Container Platform clusters.
-
For information about installing the
1.1. OpenShift Container Platform build strategies and Quarkus 링크 복사링크가 클립보드에 복사되었습니다!
Red Hat OpenShift Container Platform is a Kubernetes-based platform for developing and running containerized applications. Although the Kubernetes upstream project provides additional strategies, Red Hat supports only the following strategies in Quarkus:
1.1.1. Overview of OpenShift Container Platform build strategies 링크 복사링크가 클립보드에 복사되었습니다!
- Docker build
- This strategy builds the artifacts outside the OpenShift Container Platform cluster, locally or in a CI environment, and provides them to the OpenShift Container Platform build system together with a Dockerfile. The artifacts include JAR files or a native executable. The container gets built inside the OpenShift Container Platform cluster and is provided as an image stream.
The OpenShift Container Platform Docker build strategy is the preferred build strategy because it supports Quarkus applications targeted for JVM or compiled to native executables. However, for compatibility with earlier Quarkus versions, the default build strategy is S2I. To select the OpenShift Container Platform Docker build strategy, use the quarkus.openshift.build-strategy property.
- Source to Image (S2I)
- The build process is performed inside the OpenShift Container Platform cluster. Red Hat build of Quarkus fully supports using S2I to deploy Red Hat build of Quarkus as a JVM application.
- Binary S2I
- This strategy uses a JAR file as input to the S2I build process, which speeds up building and deploying your application.
1.1.2. Build strategies supported by Quarkus 링크 복사링크가 클립보드에 복사되었습니다!
The following table outlines the build strategies that Red Hat build of Quarkus 2.13 supports:
| Build strategy | Support for Quarkus tools | Support for JVM | Support for native | Support for JVM Serverless | Support for native Serverless |
|---|---|---|---|---|---|
| Docker build | YES | YES | YES | YES | YES |
| S2I Binary | YES | YES | NO | NO | NO |
| Source S2I | NO | YES | NO | NO | NO |
1.2. Adding the Quarkus OpenShift extension 링크 복사링크가 클립보드에 복사되었습니다!
To build and deploy your applications as a container image that runs inside your OpenShift Container Platform cluster, you must add the Red Hat build of Quarkus OpenShift extension quarkus-openshift as a dependency to your project.
The Quarkus OpenShift extension also generates OpenShift Container Platform resources such as image streams, build configuration, deployment configuration, and service definitions. If your Quarkus application includes the quarkus-smallrye-health extension, OpenShift Container Platform can access the health endpoint and verify the liveness and readiness of your application.
Prerequisites
You have a Quarkus Maven project.
- For information about how to create a Quarkus project with Maven, see Developing and compiling your Quarkus applications with Apache Maven.
- You are working in the correct OpenShift project namespace as outlined in Switching to the required OpenShift Container Platform project.
Procedure
-
Log in to OpenShift by using the
octool, then change to the directory that has your Quarkus Maven project. To add the
quarkus-openshiftextension to your project, use one of the following methods:Configure the
pom.xmlfile:pom.xml
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-openshift</artifactId> </dependency><dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-openshift</artifactId> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following command on the OpenShift Container Platform CLI:
./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-openshift"
./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-openshift"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following command on the Quarkus CLI:
quarkus extension add 'quarkus-openshift'
quarkus extension add 'quarkus-openshift'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3. Switching to the required OpenShift Container Platform project 링크 복사링크가 클립보드에 복사되었습니다!
You can use the Red Hat OpenShift Container Platform command-line interface (CLI) to create applications and manage your OpenShift Container Platform projects. Use the information provided to create an OpenShift Container Platform project or to switch to an existing one.
Prerequisites
You have access to an OpenShift Container Platform cluster and the latest compatible version of the
octool installed.-
For information about installing the
octool, see Installing and configuring OpenShift Container Platform clusters.
-
For information about installing the
Procedure
Log in to the
octool:oc login
oc loginCopy to Clipboard Copied! Toggle word wrap Toggle overflow To, show the current project space, enter the following command:
oc project -q
oc project -qCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use one of the following steps to go to the required OpenShift Container Platform project:
If the project already exists, switch to the project:
oc project <project_name>
oc project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the project does not exist, create a new project:
oc new-project <project_name>
oc new-project <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Deploying Quarkus Java applications to OpenShift Container Platform 링크 복사링크가 클립보드에 복사되었습니다!
The Red Hat build of Quarkus OpenShift extension enables you to deploy your Quarkus application to OpenShift Container Platform by using the Docker build strategy. The container gets built inside the OpenShift Container Platform cluster and is provided as an image stream.
Your Quarkus project includes pregenerated Dockerfiles with instructions. When you want to use a custom Dockerfile, you must add the file in the src/main/docker directory or anywhere inside the module. Additionally, you need to set the path to your Dockerfile by using the quarkus.openshift.jvm-dockerfile property.
Prerequisites
-
You have a Red Hat build of Quarkus Maven project that includes the
quarkus-openshiftextension. - You are working in the correct OpenShift project namespace, as outlined in Switching to the required OpenShift Container Platform project.
Procedure
-
Log in to OpenShift Container Platform by using the
octool, then change to the directory that has your Quarkus Maven project. Set the Docker build strategy in your
application.propertiesconfiguration file:quarkus.openshift.build-strategy=docker
quarkus.openshift.build-strategy=dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow (Optional) Set the following properties in the
application.propertiesfile, as required by your environment:If you are using an untrusted certificate, configure the
KubernetesClient:quarkus.kubernetes-client.trust-certs=true
quarkus.kubernetes-client.trust-certs=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the service to create an OpenShift Container Platform route:
quarkus.openshift.route.expose=true
quarkus.openshift.route.expose=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the path to your custom Dockerfile:
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example shows the path to the
Dockerfile.custom-jvm:quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvm
quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvmCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Package and deploy your Quarkus application to the current OpenShift project:
./mvnw clean package -Dquarkus.kubernetes.deploy=true
./mvnw clean package -Dquarkus.kubernetes.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
The verification steps and related terminal outputs are demonstrated on the openshift-helloworld example application.
Display the list of pods associated with your current OpenShift project:
oc get pods
oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NAME READY STATUS RESTARTS AGE getting-started-1-build 0/1 Completed 0 96m openshift-helloworld-1-build 0/1 Completed 0 11m openshift-helloworld-1-deploy 0/1 Completed 0 10m openshift-helloworld-1-gzzrx 1/1 Running 0 10m
NAME READY STATUS RESTARTS AGE getting-started-1-build 0/1 Completed 0 96m openshift-helloworld-1-build 0/1 Completed 0 11m openshift-helloworld-1-deploy 0/1 Completed 0 10m openshift-helloworld-1-gzzrx 1/1 Running 0 10mCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve the log output for your application’s pod, use the
oc logs -fcommand with the<pod_name>value of the pod you are interested in. In this example, we use theopenshift-helloworld-1-gzzrxpod name that corresponds with the latest pod prefixed with the name of your application:oc logs -f openshift-helloworld-1-gzzrx
oc logs -f openshift-helloworld-1-gzzrxCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve a list of services:
oc get svc
oc get svcCopy to Clipboard Copied! Toggle word wrap Toggle overflow NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE getting-started ClusterIP 172.30.178.154 <none> 80/TCP 98m modelmesh-serving ClusterIP None <none> 8033/TCP,8008/TCP,8443/TCP,2112/TCP 25h openshift-helloworld ClusterIP 172.30.64.57 <none> 80/TCP 14m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE getting-started ClusterIP 172.30.178.154 <none> 80/TCP 98m modelmesh-serving ClusterIP None <none> 8033/TCP,8008/TCP,8443/TCP,2112/TCP 25h openshift-helloworld ClusterIP 172.30.64.57 <none> 80/TCP 14mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get a URL to test your application:
oc get routes
oc get routesCopy to Clipboard Copied! Toggle word wrap Toggle overflow NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD openshift-helloworld openshift-helloworld-mmaler-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com openshift-helloworld http None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD openshift-helloworld openshift-helloworld-mmaler-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com openshift-helloworld http NoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBe aware that the route is now listening on port 80 and no longer at port 8080.
The application demonstrated in this example can be tested with a web browser or a terminal by using
curland the complete URL output fromoc get routes:- http://openshift-helloworld-mmaler-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com
-
curl http://openshift-helloworld-mmaler-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com
1.5. Deploying Quarkus applications compiled to native executables 링크 복사링크가 클립보드에 복사되었습니다!
You can deploy your native Red Hat build of Quarkus application to OpenShift Container Platform by using the Docker build strategy. You must create a native executable for your application that targets the Linux AMD64 operating system. If your host operating system is different from this, create a native Linux executable using a container runtime, for example, Docker or Podman.
Your Quarkus project includes pregenerated Dockerfiles with instructions. To use a custom Dockerfile, add the file in the src/main/docker directory or anywhere inside the module, and set the path to your Dockerfile using the quarkus.openshift.native-dockerfile property.
Prerequisites
- You have a Linux AMD64 system or an Open Container Initiative (OCI) compatible container runtime, such as Podman or Docker.
-
You have a Quarkus Maven project that includes the
quarkus-openshiftextension. - You are working in the correct OpenShift project namespace, as outlined in Switching to the required OpenShift Container Platform project.
Procedure
-
Log in to OpenShift Container Platform by using the
octool, and change to the directory that has your Quarkus Maven project. Configure the following properties in your
application.propertiesfile:Set the Docker build strategy:
quarkus.openshift.build-strategy=docker
quarkus.openshift.build-strategy=dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the container runtime:
quarkus.native.container-build=true
quarkus.native.container-build=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you are using an untrusted certificate, configure the
KubernetesClientproperty:quarkus.kubernetes-client.trust-certs=true
quarkus.kubernetes-client.trust-certs=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Expose the service to create an OpenShift Container Platform route:
quarkus.openshift.route.expose=true
quarkus.openshift.route.expose=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Set the path to your custom Dockerfile:
quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>
quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example shows the path to the
Dockerfile.custom-native:quarkus.openshift.jvm-dockerfile=src/main/docker/Dockerfile.custom-native
quarkus.openshift.jvm-dockerfile=src/main/docker/Dockerfile.custom-nativeCopy to Clipboard Copied! Toggle word wrap Toggle overflow (Optional) Specify the container engine:
To build a native executable with Podman:
quarkus.native.container-runtime=podman
quarkus.native.container-runtime=podmanCopy to Clipboard Copied! Toggle word wrap Toggle overflow To build a native executable with Docker:
quarkus.native.container-runtime=docker
quarkus.native.container-runtime=dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Build a native executable, package, and deploy your application to OpenShift Container Platform:
./mvnw clean package -Pnative -Dquarkus.kubernetes.deploy=true
./mvnw clean package -Pnative -Dquarkus.kubernetes.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To view a list of pods associated with your current OpenShift project, enter the following command:
oc get pods
oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve the log output for your application’s pod, enter the following command where
<pod_name>is the name of the latest pod prefixed with the name of your application:oc logs -f <pod_name>
oc logs -f <pod_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.6. Deploying Quarkus applications as an OpenShift Serverless service 링크 복사링크가 클립보드에 복사되었습니다!
You can deploy your Quarkus applications to OpenShift Serverless by using the Docker build strategy. With the Knative Serving feature of OpenShift Serverless, you can scale services up and down depending on the load size. Scaling down services that are currently not requested improves memory capabilities.
Your Quarkus project includes pregenerated Dockerfiles with instructions. When you want to use a custom Dockerfile, you need to add the file in the src/main/docker directory or anywhere inside the module. Additionally, you need to set the path to your Dockerfile by using the quarkus.openshift.jvm-dockerfile property for JVM mode and quarkus.openshift.native-dockerfile property for native mode.
To deploy a Serverless Quarkus Java application or a Serverless application compiled to a native executable by using the Quarkus OpenShift extension, complete the following procedure:
Prerequisites
-
You have a Quarkus Maven project that includes the
quarkus-openshiftextension. - You are working in the correct OpenShift project namespace, as outlined in Switching to the required OpenShift Container Platform project.
- You have installed OpenShift Serverless Operator.
- You have installed and verified OpenShift Knative Serving. For more information, see Installing Knative Serving.
- For native compilation, you have a Linux AMD64 operating system or an Open Container Initiative (OCI) compatible container runtime, for example, Podman or Docker.
Procedure
-
Log in to OpenShift Container Platform by using the
octool, and change to the directory that has your Quarkus Maven project. Configure the following properties in your
application.propertiesfile:Set Knative as a deployment target:
quarkus.kubernetes.deployment-target=knative
quarkus.kubernetes.deployment-target=knativeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Docker build strategy:
quarkus.openshift.build-strategy=docker
quarkus.openshift.build-strategy=dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Direct OpenShift Serverless to pull your container image from the OpenShift internal registry:
quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000
quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf your OpenShift Container Platform
<project_name>is different from theusernameof the host system, set the group for the container image otherwise Quarkus cannot pull the image from the image registry.quarkus.container-image.group=<project_name>
quarkus.container-image.group=<project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow (Optional) If you are using an untrusted certificate, configure the
KubernetesClient:quarkus.kubernetes-client.trust-certs=true
quarkus.kubernetes-client.trust-certs=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow (Optional) Expose the service to create an OpenShift Container Platform route:
quarkus.openshift.route.expose=true
quarkus.openshift.route.expose=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow (Optional) Set the path to your custom Dockerfile:
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example shows the path to the
Dockerfile.custom-jvm:quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvm
quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvmCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Optional: To deploy a Serverless application compiled to a native executable, configure the following properties:
Set the container runtime:
quarkus.native.container-build=true
quarkus.native.container-build=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the container engine:
To build a native executable with Podman:
quarkus.native.container-runtime=podman
quarkus.native.container-runtime=podmanCopy to Clipboard Copied! Toggle word wrap Toggle overflow To build a native executable with Docker:
quarkus.native.container-runtime=docker
quarkus.native.container-runtime=dockerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
(Optional) Set the path to your custom Dockerfile:
quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>
quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Package and deploy your Serverless application to OpenShift Container Platform using one of the following options:
Deploy a Quarkus Java application:
./mvnw clean package -Dquarkus.kubernetes.deploy=true
./mvnw clean package -Dquarkus.kubernetes.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a Quarkus native application:
./mvnw clean package -Pnative -Dquarkus.kubernetes.deploy=true
./mvnw clean package -Pnative -Dquarkus.kubernetes.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To view a list of pods associated with your current OpenShift project:
oc get pods
oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve the log output for your application’s pod, enter the following command where
<pod_name>is the name of the latest pod prefixed with the name of your application:oc logs -f <pod_name>
oc logs -f <pod_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.7. Using S2I to deploy Quarkus applications to OpenShift Container Platform 링크 복사링크가 클립보드에 복사되었습니다!
You can deploy your Red Hat build of Quarkus applications to OpenShift Container Platform using the Source-to-Image (S2I) method. With S2I, you must provide the source code to the build container through a Git repository or by uploading the source at build time.
S2I is not supported for native deployments. For deploying Quarkus applications compiled to native executables, use the Docker build strategy.
The procedure for deploying your Quarkus applications to OpenShift Container Platform by using S2I differs depending on the Java version you are using.
1.7.1. Using S2I to deploy Quarkus applications to OpenShift Container Platform with Java 17 링크 복사링크가 클립보드에 복사되었습니다!
You can deploy your Red Hat build of Quarkus applications running on Java 17 to OpenShift Container Platform by using the Source-to-Image (S2I) method.
Prerequisites
- You have a Quarkus application built with Java 17. For Java 11 applications, see Using S2I to deploy Quarkus applications to OpenShift Container Platform with Java 11.
-
You have a Quarkus Maven project that includes the
quarkus-openshiftextension. - You are working in the correct OpenShift project namespace, as outlined in Switching to the required OpenShift Container Platform project.
- Your Quarkus Maven project is hosted in a Git repository.
Procedure
Open the
pom.xmlfile, and change the Java configuration to version 17, as follows:<maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Log in to OpenShift Container Platform by using the
octool, then change to the directory that contains your Quarkus Maven project. To package your Java 17 application, enter the following command:
./mvnw clean package
./mvnw clean packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create a directory called
.s2iat the same level as thepom.xmlfile. Create a file called
environmentin the.s2idirectory and add the following content:MAVEN_S2I_ARTIFACT_DIRS=target/quarkus-app S2I_SOURCE_DEPLOYMENTS_FILTER=app lib quarkus quarkus-run.jar JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 AB_JOLOKIA_OFF=true JAVA_APP_JAR=/deployments/quarkus-run.jar
MAVEN_S2I_ARTIFACT_DIRS=target/quarkus-app S2I_SOURCE_DEPLOYMENTS_FILTER=app lib quarkus quarkus-run.jar JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 AB_JOLOKIA_OFF=true JAVA_APP_JAR=/deployments/quarkus-run.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Commit and push your changes to the remote Git repository.
To import the supported OpenShift Container Platform image, enter the following command:
oc import-image --confirm ubi8/openjdk-17 --from=registry.access.redhat.com/ubi8/openjdk-17
oc import-image --confirm ubi8/openjdk-17 --from=registry.access.redhat.com/ubi8/openjdk-17Copy to Clipboard Copied! Toggle word wrap Toggle overflow To build the project on OpenShift Container Platform, enter the following command:
oc new-app ubi8/openjdk-17 <git_path> --name=<project_name>
oc new-app ubi8/openjdk-17 <git_path> --name=<project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where:
- <git_path> is the path to the Git repository that hosts your Quarkus project
- <project_name> is the OpenShift project that you created.
To begin the deployment to OpenShift Container Platform, enter the following command:
oc start-build <project_name>
oc start-build <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To view a list of pods associated with your current OpenShift project:
oc get pods
oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve the log output for your application’s pod, enter the following command where
<pod_name>is the name of the latest pod prefixed with the name of your application:oc logs -f <pod_name>
oc logs -f <pod_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.7.2. Using S2I to deploy Quarkus applications to OpenShift Container Platform with Java 11 링크 복사링크가 클립보드에 복사되었습니다!
You can deploy your Red Hat build of Quarkus applications running on Java 11 to OpenShift Container Platform by using the Source-to-Image (S2I) method.
Prerequisites
- You have a Quarkus application built with Java 11. For Java 17 applications, see Using S2I to deploy Quarkus applications to OpenShift Container Platform with Java 17.
-
You have a Quarkus Maven project that includes the
quarkus-openshiftextension. - You are working in the correct OpenShift Container Platform project namespace, as outlined in Switching to the required OpenShift Container Platform project.
- Your Quarkus Maven project is hosted in a Git repository.
Procedure
-
Log in to OpenShift Container Platform by using the
octool, then change to the directory that contains your Quarkus Maven project. To package your Java 11 application, enter the following command:
./mvnw clean package
./mvnw clean packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create a directory called
.s2iat the same level as thepom.xmlfile. Create a file called
environmentin the.s2idirectory and add the following content:MAVEN_S2I_ARTIFACT_DIRS=target/quarkus-app S2I_SOURCE_DEPLOYMENTS_FILTER=app lib quarkus quarkus-run.jar JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 AB_JOLOKIA_OFF=true JAVA_APP_JAR=/deployments/quarkus-run.jar
MAVEN_S2I_ARTIFACT_DIRS=target/quarkus-app S2I_SOURCE_DEPLOYMENTS_FILTER=app lib quarkus quarkus-run.jar JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 AB_JOLOKIA_OFF=true JAVA_APP_JAR=/deployments/quarkus-run.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Commit and push your changes to the remote Git repository.
To import the supported OpenShift Container Platform image, enter the following command:
oc import-image --confirm ubi8/openjdk-11 --from=ubi8/openjdk-11
oc import-image --confirm ubi8/openjdk-11 --from=ubi8/openjdk-11Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are deploying on IBM Z infrastructure, enter
oc import-image --confirm ubi8/openjdk-11 --from=registry.redhat.io/ubi8/openjdk-11instead. For information about this image, see the Red Hat OpenJDK 11 page.To build the project, create the application, and deploy the OpenShift Container Platform service, enter the following command:
oc new-app ubi8/openjdk-11 <git_path> --name=<project_name>
oc new-app ubi8/openjdk-11 <git_path> --name=<project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are deploying on IBM Z infrastructure, enter
oc new-app ubi8/openjdk-11 <git_path> --name=<project_name>instead.To deploy an updated version of the project, push any updates to the Git repository then enter the following command:
oc start-build <project_name>
oc start-build <project_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
To view a list of pods, enter the following command:
oc get pods
oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve the log output for your application’s pod, enter the following command:
oc logs -f <pod_name>
oc logs -f <pod_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
You can customize your deployments on OpenShift Container Platform by defining optional configuration properties. You can configure your Red Hat build of Quarkus project in your applications.properties file or from the command line.
| Property | Description | Default |
|---|---|---|
|
|
The container image group. Must be set if the OpenShift Container Platform |
|
|
| The container registry to use. | |
|
| Kubernetes client certificate authentication. | |
|
|
Deployment target platform. For example, | |
|
| Builds a native Linux executable by using a container runtime. Docker is used by default. |
|
|
| The container runtime used to build the image, for example, Docker. | |
|
| The deployment strategy. |
|
|
| Exposes a route for the Quarkus application. |
|
|
|
Enables debugging and generates debug symbols in a separate |
|