이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 2. Deploying Red Hat build of Quarkus applications to OpenShift Container Platform in a single step
As an application developer, you build and deploy your Quarkus applications to OpenShift Container Platform in a single step. Complete one of the following commands:
Using the Quarkus CLI:
quarkus build quarkus deploy openshift
quarkus build quarkus deploy openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using Maven:
./mvnw install -Dquarkus.openshift.deploy=true
./mvnw install -Dquarkus.openshift.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using Gradle:
./gradlew build -Dquarkus.openshift.deploy=true
./gradlew build -Dquarkus.openshift.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
With these commands, you build your application locally, trigger a container image build, and apply the generated OpenShift Container Platform resources automatically.
The generated resources use a Kubernetes Deployment, but still make use of OpenShift-specific resources, such as Route, BuildConfig, and so on.
2.1. Prerequisites 링크 복사링크가 클립보드에 복사되었습니다!
- You have OpenJDK 17 or later installed.
-
You have set the
JAVA_HOMEenvironment variable to the location of the Java SDK. -
You have access to an OpenShift Container Platform cluster and the latest compatible version of the
ocCLI tool installed. - You are working in the correct OpenShift project namespace.
To run this deployment, it is not necessary to have the quarkus-openshift extension included in your Quarkus project.
2.2. Procedure 링크 복사링크가 클립보드에 복사되었습니다!
- Trigger a build and deployment in a single step:
Using the Quarkus CLI:
quarkus build quarkus deploy openshift
quarkus build quarkus deploy openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using Maven:
./mvnw install -Dquarkus.openshift.deploy=true
./mvnw install -Dquarkus.openshift.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using Gradle:
./gradlew build -Dquarkus.openshift.deploy=true
./gradlew build -Dquarkus.openshift.deploy=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If you want to test your application immediately, set the quarkus.openshift.route.expose configuration property to true to expose the service automatically.
For example, add -Dquarkus.openshift.route.expose=true to the above command. For more information, see Exposing routes.
As of OpenShift Container Platform 4.14, the DeploymentConfig object is deprecated. Deployment is now the default and preferred deployment kind for the quarkus-openshift extension.
Because of this change, consider the following:
-
If you redeploy applications that you previously deployed by using
DeploymentConfig, by default, those applications useDeploymentbut do not remove the previousDeploymentConfig. This leads to a deployment of both new and old applications, so, you must remove the oldDeploymentConfigmanually. If you want to continue to useDeploymentConfig, it is still possible to do so by explicitly settingquarkus.openshift.deployment-kindtoDeploymentConfig. -
Deploymentis a Kubernetes resource and not OpenShift specific, so it cannot leverageImageStreamresources, as is the case withDeploymentConfig. Therefore, the image references must include the container image registry that hosts the image.
For more information about the deprecation, how to set up and use automatic rollbacks, triggers, lifecycle hooks, and custom strategies, see the Red Hat Knowledgebase article DeploymentConfig API is being deprecated in Red Hat OpenShift Container Platform 4.14.
2.3. Verification 링크 복사링크가 클립보드에 복사되었습니다!
Verify that an image stream and a service resource are created and the application is deployed by using the OpenShift Container Platform web console.
quarkus.container-image.group=<project/namespace name>
quarkus.container-image.group=<project/namespace name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, run the following OpenShift Container Platform command-line interface (CLI) commands:
oc get is oc get pods oc get svc
oc get is1 oc get pods2 oc get svc3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow To get 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 By default, the service is not exposed to the outside world. Therefore, if you did not expose the created service automatically by setting the
quarkus.openshift.route.expose=trueproperty before building the application, you can expose the service manually.oc expose svc/openshift-quickstart oc get routes curl http://<route>/hello
oc expose svc/openshift-quickstart1 oc get routes2 curl http://<route>/hello3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow