이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 6. Using S2I to deploy Quarkus applications to OpenShift
You can deploy your Quarkus applications to OpenShift using the Source-to-Image (S2I) method. With S2I, you must provide the source code to the build container either through a Git repository or by uploading the source at build time.
For deploying Quarkus applications compiled to native executables, use the Docker build strategy. The S2I is not the supported method for native deployments.
Prerequisites
-
Have a Quarkus Maven project that includes the
quarkus-openshiftextension. - Host your Quarkus Maven project in a Git repository.
Login to OpenShift using
ocand select your project.- To verify the OpenShift project namespace, see Verifying the OpenShift project namespace.
Procedure
- Change to the directory that contains your Quarkus Maven project.
-
Create a hidden directory called
.s2iat the same level as thepom.xmlfile. Create a file called
environmentin the.s2idirectory and add the following content:ARTIFACT_COPY_ARGS=-p -r lib/ *-runner.jar
ARTIFACT_COPY_ARGS=-p -r lib/ *-runner.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Commit and push your changes to the remote Git repository.
To import the supported OpenShift image, enter the following command:
oc import-image --confirm ubi8/openjdk-11 --from=registry.access.redhat.com/ubi8/openjdk-11
oc import-image --confirm ubi8/openjdk-11 --from=registry.access.redhat.com/ubi8/openjdk-11Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are deploying on IBM Z infrastructure, enter
oc import-image --confirm openj9/openj9-11-rhel8 --from=registry.redhat.io/openj9/openj9-11-rhel8.For information about this image, see the Red Hat OpenJ9 11 Java Applications on RHEL8 page.
To build the project in OpenShift, enter the following command where
<git_path>is the path to the Git repository that hosts your Quarkus project and<project_name>is the OpenShift project that you created.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 openj9/openj9-11-rhel8 <git_path> --name=<project_name>.This command builds the project, creates the application, and deploys the OpenShift service.
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
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